Dynamic query in stored procedure
Date: Tue, 14 Oct 2008 07:57:16 +0200
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.
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