|
I am new to creating DB2 SQL Procedures and I need a little help.
This works perfectly when I am just using it through my SQL Editor:
SELECT * FROM SALESTABLE
WHERE VENDOR LIKE 'ELK' || '%' AND CUSTOMER LIKE 'HOO' || '%'
It will not work for my procedure. Here it is:
CREATE PROCEDURE SALES_HISTORY (
IN I_VENDOR CHAR(6) ,
IN I_CUST CHAR(6))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE CURSOR1 CURSOR FOR SELECT * FROM SALESTABLE
WHERE VENDOR LIKE I_VENDOR || '%' AND CUSTOMER LIKE I_CUST || '%' ;
OPEN CURSOR1 ;
END ;
If I call the procedure as CALL SALES_HISTORY('ELK','HOO') it returns
nothing.
Interesting enough, if I pass in the full vendor and customer numbers
it works. CALL SALES_HISTORY('ELK050','HOO050')
Can anybody help me create this procedure so I can pass only part of
the vendor and customer numbers and still retrieve results?
My DB2 database resides on an ISeries server running V5R4. |