Deleting streams

whwar9739

Member
Is there any way to delete old streams so that I can create more than the limit of 50? Essentially I am creating a program to export from tables and defining streams as slo-table. Unfortunately I am dealing with more than 50 tables. I am sure I could recycle streams but I would prefer not to if at all possible.
 
just put define stream command to external procedure, run it, at the end of execution stream will be deleted.

<code>
OUTPUT TO VALUE(tblprocname).
put unformatted "/* Dump procedure for " tblname " */" skip.
put unformatted "/* " tblprocname " - created " TODAY " " STRING(TIME,"HH:MM:SS") " by " PROGRAM-NAME(1) " */" skip.
put unformatted " " skip.
put unformatted "define input parameter dumpfile as character. " skip.
put unformatted " " skip.
put unformatted "define variable i as integer." skip.
put unformatted "define stream outfile." skip(1).

find first _File where _File._File-Name = tblname NO-LOCK NO-ERROR.
if NOT available _File then
do:
put unformatted 'message STRING(TIME, "HH:MM:SS") ' + "Error. Table not found " + tblname' skip.
OUTPUT CLOSE.
RETURN "ERROR".
end.

put unformatted 'message STRING(TIME, "HH:MM:SS") ' + '"Dumping ' + _File._File-Name + ' ...".' skip.
put unformatted "i = 0." skip.
put unformatted "run src/cr_dir.p (dumpfile)." skip.
put unformatted "output stream outfile to value(dumpfile)." skip.
put unformatted "for each " + _File._File-Name + " no-lock:" skip.
put unformatted " export stream outfile" skip.
for each _Field OF _File NO-LOCK:
if _Field._Extent = ? OR _Field._Extent = 0 then
do:
put unformatted " " _File._File-Name + "." + _Field._Field-Name skip.
end.
else do:
do i = 1 to _Field._Extent :
put unformatted " " _File._File-Name + "." + _Field._Field-Name + "[" + STRING(i) + "]" skip.
end.
end.
end.
put unformatted " ." skip.
put unformatted " i = i + 1." skip.
put unformatted " if i MODULO 10000 = 0 then" skip.
put unformatted ' message STRING(TIME, "HH:MM:SS") ' + '"Processed "' + ' i "records".' skip.
put unformatted "end." skip.
put unformatted "output stream outfile close." skip.
put unformatted 'message STRING(TIME, "HH:MM:SS") ' + '"Total dumped "' + ' i "records".' skip.
put unformatted "if i = 0 then os-delete value(dumpfile)." skip.
OUTPUT CLOSE.
</code>
 
That would work, except, I something closer to the following scenario:

Code:
for each maintable:
   for each table1 of maintable:
      export stream slo-table2 table1.
   end.
   for each table2 of maintable:
      export stream slo-table2 table2.
   end.
   export slo-maintable maintable.
end.

And i would like be certian that everytime through i keep appending to the files.
 
I see no reason to use many streams on this scenario.

for each maintable:
run Export_reltable.p (ROWID(maintable),file-name).
export slo-maintable maintable.
end.

Export_reltable.p

define input parameter rid as ROWID.
define input parameter file-name as character.
define stream slo-table2.
output stream slo-table2 to value(filename) append.
find first maintable where ROWID(maintable) = rid NO-LOCK.
for each table1 of maintable:
export stream slo-table2 table1.
end.
for each table2 of maintable:
export stream slo-table2 table2.
end.
end.
output stream slo-table2 close.
 
Back
Top