Re: Dynamic SQL vs. ESQL/C
Posted in 1996
In article <31EF1C43.3B4E@informix.com>, davek@informix.com says... >On the other hand, dynamic esql/c would look like: > >declare structs >get query string >prepare query string >describe prepared string into structs >malloc space for vars in structs >declare cursor for prepared statement >open/fetch/close Let me offer up my own disagreement in this thread of continuing mild disagreements. :-) If you're really concerned about performance, the case I outline below is the most common use of dynamic ESQL. Only in exceptional circumstances does one get a completely fresh query string or completely different query criteria every time a particular query is done. Most of the "dynamic" SQL I've encountered knows what the query looks like, is building a query that may differ in what particular fields need to be selected or what query criteria has been specified, but once that information is determined remains pretty static for the duration of the application. It can can do something like this: if(first_time_through) { declare structs get query string prepare query string describe prepared string into structs malloc space for vars in structs declare cursor for prepared statement first_time_through = FALSE } open/fetch/close Performance of something like this is, over the long run, going to be almost indistinguishable from the performance of a similarly coded static SQL approach, is it not? Both dynamic and static can be coded to do the cursor setup once. -- William Harris william@carsinfo.com CARS Information Systems 4000 Executive Park Drive Cincinnati, OH (USA) 45241