Why use USING? (was Re: ORDER BY ?, ?, ? DESC)
Posted in 1995
Topics: Performance & Tuning, Connectivity: ESQL/C, 4GL & Embedded SQL
Jonathan Leffler <johnl@informix.com> wrote (edited): >Someone else wrote (edited heavily): >} I am trying the following method and it is not working. >} ............. >} PREPARE stmt FROM "SELECT * FROM emp_tab ORDER BY ?, ?, ?" >} >} PROMPT "enter col1" FOR c1 >} PROMPT "enter col2" FOR c2 >} PROMPT "enter col3" FOR c3 >} >} DECLARE cur1 SCROLL CURSOR FOR stmt >} >} OPEN cur1 USING c1, c2, c3 > >You cannot use ? in the ORDER BY clause. > >You can, of course, reverse the order of the PROMPT statements and the >PREPARE, and build the string using the input data from the prompts. The >cursor would not need a USING clause for the ORDER BY clause. (though it >might still need it for other reasons). At the risk of sounding stupid (what else is new?), does one ever _have_ to use USING? Is it ever _better_ to use USING? Even in a looping situation, I can't imagine that the performance is that much different (but that may be where I'm way off). It seems like I used USING a lot when first starting in 4GL, but later almost exclusively built a character string out of the changing variables (redundant, no?) and PREPAREd that. Anyone? Thanks, rodney