It is possible to read IFS files directly with embedded SQL by using
LOB-files or LOB Locators.
... but a LOB-file or a LOB Locator can only be handled with SQL functions
as if it would be a character field, that means you need to split the *.csv
file into columns by yourself.
Example:
D MyCLOBFile S SQLTYPE(CLOB_File)
D MyText S 50A
D Start S 10I 0
D RowLen S 5I 0 inz(120)
D Index S 3U 0
D ParIFSFile S 256A Varying
D inz('/home/Hauser/MyText.csv')
*---------------------------------------------------------------------------
----------------------
/Free
MyCLOBFile_Name = %Trim(ParIFSFile);
MyCLOBFile_NL = %Len(%Trim(MyCLOBFile_Name));
MyCLOBFile_FO = SQFRD; //Read Only
DOU %Len(%Trim(MyText)) = *Zeros;
Start = (Index-1) * RowLen + 1;
Exec SQL Set :MyText = Substr(:MyCLOBFile, :Start, :RowLen);
If SQLCODE = 100 or SQLCODE < *Zeros
or %Len(%Trim(MyText)) = *Zeros;
Leave;
EndIf;
//Do whatever you want
EndDO;
*InLR = *On;
/END-FREE
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Darryl Freinkel
Gesendet: Wednesday, 15.8 2012 16:09
An: midrange-l@xxxxxxxxxxxx
Betreff: Is there a way to use SQL to read files directly of the IFS
I have some large files on the IFS that I create from the native database.
Periodically there is a problem with that data but it's only discovered days
later when the original data is gone but in the IFS. I could copy it back to
the data base file but it would be more convenient if we could read directly
from the IFS. The files are in a CSV format.
TIA
Darryl Freinkel | Assignment 400 Group, Inc.
Tel: 770.321.8562 ext 111 | Fax 770.321.8562
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.