Re: How to write a java stored procedure in Informix?
Posted in 1999
4GL - Esql Q:- In 4gl, a foreach inside a foreach can have the cursors prepared and declared thus:- PREPARE t_s from SELECT * FROM systables WHERE tabid < 100 DECLARE t_c cursor for t_s PREPARE c_s from SELECT * FROM syscolumns WHERE tabid = tr.tabid DECLARE c_c cursor for c_s FOREACH t_c into tr.* FOREACH c_c into cr.* whatever END FOREACH ENDFOREACH This has everything the compiler needs (tr.tabid) to open cursor c_c. In Esql, however, there must be a way to do the same functionality. My current method is:- $PREPARE t_s from SELECT * FROM systables WHERE tabid < 100; $DECLARE t_c cursor for t_s; $PREPARE c_s from SELECT * FROM syscolumns WHERE tabid = ?; $DECLARE c_c cursor for c_s; $OPEN t_c; while (!SQLCODE) { $FETCH t_c into rt.*; $OPEN using tr.tabid; while (!SQLCODE) { $FETCH c_c into cr.*; whatever; } } Here the compiler has no notion of what the ? is. This must force the open to a lot more work to form the correct select statement. It is inside a loop, so I wonder what the overheads are compared to the 4gl version! The Esql manual(s) is quiet specific in its examples:- Programmers manual V 7.2 P.10.7 gives two types of prepare 1. sprintf(sp_call, "SELECT *\\ FROM %s:syscolumns\\ WHERE tabname = %s", dbsB, rt.tabname); Here the declare would have to go inside the first while, and declares are expensive on system resources, are they not!. 2. sprintf(sp_call, "SELECT *\\ FROM %s:syscolumns\\ WHERE tabid = ?", dbsB); I guess my question is:- When inside an iteration, what is the method to get a cursor open using known variable. In high expectations Regards Ian A many year's 4gl'er being forced to get a buck from the C (Real ?) world.