Subject Re: [firebird-support] Prepare for queries that will be run once
Author Helen Borrie
At 11:23 PM 28/12/2004 +0000, you wrote:


>I'm writing SQL dynamically at runtime. Should I "prepare" a query if
>it will only be run once?

Yes, in most cases. That's why dynamically assembled, run-once queries are
wasteful. It's a fairly rare requirement to need to do this and it's
risky, e.g. if you make it possible for some idiot user, at will, to
assemble a query that selects all of the columns and rows in a huge table.

You *can* do run-once, unprepared I/U/D queries using calls to
isc_dsql_execute_immediate() (no return structures allowed) or
isc_dsql_exec_immed2() (allows a singleton structure to be returned). The
first would be used to whip off a quick insert, update or delete statement
or to invoke an executable SP that has no return values. The second would
be used for an executable SP that has return values.

./hb