Subject Stored Procedures - Including variables to form part of the query
Author russx2
Hellom

I'm currently using Firebird 1.5.1 and am writing some stored procedures.

My question is best explained by a quick example. I'm writing a
procedure to generate a list of books. I wish to allow the client app
to specify an order and order direction (ASC/DESC) as a parameter.

The following doesn't (surprisingly) work:

SELECT ...
ORDERBY :order :orderdir;

I take it is not possible to build parts of the query as variables in
this manner? Thinking about it, this would negate the pre-compiled
nature of the queries.

So... am I stuck with generating and performing the query in the
client? I have a couple of instances where this sort of thing is
necessary (e.g. generating a WHERE clause when certain parameters are
passed).

Any advice/ideas appreciated.

Russ