RE: Stored Procedures
Posted in 1995
Sanjay,
There isn't any type of dynamic SQL within stored procedures.
(At least, not yet!) But, if the number of search columns is
small, you could implement it the hard way. That is,
pass in values for customer #, customer name and customer state.
Then, in the procedure, have a large if statement which covers
all 7 of the permutations.
IF( cust_num IS NOT NULL AND cust_name IS NULL and cust_state IS NULL ) THEN
SELECT ...
WHERE customer_num = cust_num...
ELIF( cust_num IS NOT NULL AND cust_name IS NOT NULL and cust_state IS NULL)
THEN
SELECT ...
WHERE customer_num = cust_num
AND customer_name = cust_name...
ELIF...
You get the idea. Extremely ugly but it works.
--Craig (craig@chemistry.utah.edu)
>
> I want to create a stored procedure in informix SPL where i dont know
> the WHERE clause of the select statement. As far as I could gather
> from the manuals ; I can only select if the where clause is known.
>
> My requirement is as follows :-
>
> I want to write a stored procedure to get all the customers based on
> the user input . He/she can search it based on Customer # ( char (6),
> Customer name ( char (40 ) or Customer State ( char(2) ).
>