Page 1 of 1

Using READBLK

Posted: Thu Nov 07, 2002 9:16 pm
by nilotpalr
I need to use the READBLK routine of DataStage BASIC. My File size is of about 200 KB. What block size should I use to that I am abe to read the file at one shot. I am unable to read the file completely with block size 300000. Else what is the alternative to read the file of such size using READBLK.

Thanks in advance..
Nilotpal.

Posted: Fri Nov 08, 2002 12:55 am
by ray.wurlod
Without having all the manuals to hand (I'm on vacation) I believe there is an upper limit (32K? 64K?) that READBLK can handle.

To read the file in a single shot you can treat it as a record in a table. Open its directory with OPENPATH or OPEN, then read the record with READ, using the file name as the record key. For example, to read /etc/passwd in a single shot:

Equate RoutineName To "MyRoutine"
OpenPath "/etc" To filevariable
On Error
Message = 'Unable to open "/etc". Code ' : Status()
Call DSLogWarn(Message, RoutineName)
End
Then
Read PasswdFile From filevariable, "passwd"
On Error
Message = 'Cannot read "/etc/passwd". Code ' : Status()
Call DSLogWarn(Message, RoutineName)
End
Then
GoSub ProcessFile
End
Else
Message = '"/etc/passwd" not found. Eek!'
Call DSLogWarn(Message, RoutineName)
End ; * end of Read statement
End
Else
Message = 'Cannot open "/etc".'
Call DSLogWarn(Message, RoutineName)
End ; * end of OpenPath statement

The upper limit is now really only limited by how much string space can be allocated by DSEngine - it will be Megabytes.