Re: Why use USING? (was Re: ORDER BY ?, ?, ? DESC)
Posted in 1995
Rodney (rodney@worf.netins.net) wrote: : At the risk of sounding stupid (what else is new?), does one ever : _have_ to use USING? Is it ever _better_ to use USING? ... : 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? Advantages with USING ( fetch USING & execute USING ) : - You don't have to worry about formatting your variables in the prepared string e.g.: let s = "select ... where column1 = '", mycolumn1, "'" What if mycolumn1 contains single or double quotes or any other special character (e.g. backslash)? You may get a syntax error at run-time... - You don't have to worry about the size (in chars) of the prepared statement string. Placeholders take one character, s requires the same number of bytes every time you run (unless you change the statement) Placeholders: let s = "select ... where column1 = ?" Manually Prepared: let s = "select ... where column1 = '", mycolumn1, "'" - Performance benefits: You can prepare the SQL statement once and re-use it with different arguments. Catalin. =========================================================================== Catalin Badea _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/ _/ _/ _/ _/ _/_/ _/ Senior Technical Architect _/ _/_/ _/ _/_/_/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ Tecsys Inc. _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/_/ ====== cat@tecsys.com =========== include system "disclaimer.4gh" ======