Dynamic query in stored procedure

From: Tim Mickelson <tim_mickelson_at_hotmail.com>
Date: Tue, 14 Oct 2008 07:57:16 +0200
Message-ID: <4xWIk.30763$Uo5.13737@tornado.fastwebnet.it>

   Hi

   This question is about stored procedures. I know i can make a query such as:

   query := SELECT A, B, C FROM USERS WHERE NAME = :a AND SURNAME = :b    OPEN my_cursor FOR query USING var_a, var_b

   But my question is, if I don't know how many parameters I have in the where part, how do I do? I do not want to concatenate part by part.

   E.g.

   query := SELECT A, B, C FROM USERS WHERE 1 > 0    IF(var_a IS NOT NULL) THEN

        query := query || ' AND NAME = :name'
   END IF;    ....

   How do I open this query, I don't know how many params I have? Received on Tue Oct 14 2008 - 00:57:16 CDT

Original text of this message