Guys,
The simplest way I have found to do this is using the SQLSELECT.
(Use a cmd shell to redirect output).
You'll find some environment variables in the SQL documentation that control
the outputs in terms of headers, delimiters etc.
i.e.
CT DICT COMPANY
CC
001 A
002 0
003 Code
004
005
006
007
008
009 R
010 3
sh John ~ -->SQLSELECT CC FROM COMPANY
CC
---
361
360
141
sh John ~ -->SQLSELECT CC FROM COMPANY > jcc.txt
sh John ~ -->type jcc.txt
CC
---
361
360
141
sh John ~ -->SQLSELECT CC,SORTCODE, BAL FROM COMPANY > jcc.txt
sh John ~ -->TYPE JCC.TXT
CC SOR MAINT
--- --- -------
361 360 152.51
360 360 15.25
141 141 40.40
John
From: [email protected] [mailto:[email protected]] On Behalf Of
Kevin Powick
Sent: Monday, 25 June 2012 11:49 PM
To: [email protected]
Subject: Re: SELECT into a file
On Monday, 25 June 2012 06:16:57 UTC-4, foxy.md wrote:
what I'm trying to avoid is segmentation violation when millions records are
returned using EXECUTE "SELECT... WITH ..." RTNLIST ID.LIST in a routine
In many situations, you would be better off to avoid EXECUTE / SELECT /
RTNLIST entirely, and simply code the conditions for valid record
processing. By using an EXECUTE statement, then processing the resulting
list, you're reading every record twice, taking a hit on performance. Why
not read them just once by using the jBC SELECT statement? Example:
OPEN 'MYFILE' TO MY.FL ELSE ...
SELECT MY.FL
LOOP
READNEXT ID ELSE EXIT
READ REC FROM MY.FL, ID THEN
IF REC<5> = MY.VALUE THEN
DoSomething
END
END
REPEAT
While there is a performance benefit to this method, there is also a caveat.
The jBC SELECT statement does not scan the entire file to create a full list
of item IDs before processing begins. Instead, it just scans in the first
few IDs of the file. Once these IDs are taken from the list, a few more are
scanned until the entire file has been processed. A potential "problem"
with this, depending on your processing logic, is that you could end up with
records added to the file prior to when the SELECT was started.
--
Kevin Powick
--
-- IMPORTANT: T24/Globus posts are no longer accepted on this forum. To
post, send email to [email protected] To unsubscribe, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/jBASE?hl=en
--
--
IMPORTANT: T24/Globus posts are no longer accepted on this forum.
To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en