Return to the SQL Tips
Simulated SETLL with SQL - For sorting a subfile.
Look at the PREPARE statement.
D HostVar S 200 D SortCol S 10A D fileds E DS extname(aaakey) C eval SortCol='loc' C exsr test C eval SortCol='comp' C exsr test C eval *inlr=*on ********************************************************* C test BegSr C eval HostVar='Select loc, comp, coname ' + C 'from aaakey ' + C 'order by ' + SortCol + C 'for fetch only' C/EXEC SQL C+ prepare stmt from :hostvar C/END-EXEC C/EXEC SQL C+ Declare C1 cursor for stmt C/END-EXEC C/EXEC SQL C+ Open C1 C/END-EXEC C/EXEC SQL C+ Fetch C1 into :loc, :comp, :coname C/END-EXEC C dow sqlcod=*zeros C* load subfile record C/EXEC SQL C+ Fetch C1 into :loc, :comp, :coname C/END-EXEC C enddo C/EXEC SQL C+ Close C1 C/END-EXEC C EndSr
[report a broken link by clicking here]