Hello all -
DB2 UDB SP.
Need help with passing a string into the SP.
The user could enter V, P or V,P
I got confused with ',' || .... , please help
Here is my code:
thanks a lot, cristi
DB2 UDB SP.
Need help with passing a string into the SP.
The user could enter V, P or V,P
I got confused with ',' || .... , please help
Here is my code:
Code:
CREATE PROCEDURE BASYS.ILGW ( IN CHECK_TYPE varchar (10),
IN DATE_FROM DATE,
IN DATE_TO DATE )
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- SQL Stored Procedure
-- CHECK_TYPE
-- DATE_FROM
-- DATE_TO
------------------------------------------------------------------------
P1: BEGIN
-- Declare cursor
DECLARE stmt VARCHAR(4000);
declare v_stmt statement;
DECLARE cursor1 CURSOR WITH RETURN FOR v_stmt;
set stmt =
'SELECT ILGW_VACATION.CHECK, ILGW_VACATION.EMPLOYER_ID, ILGW_VACATION.EMPLOYER_NAME, ILGW_VACATION.MEMBER_SSN, ILGW_VACATION.MEMBER_NAME, ILGW_VACATION.CHECK_STATUS, ILGW_VACATION.ISSUED_DATE, ILGW_VACATION.AMT, ILGW_VACATION.WHT_TYPE, ILGW_VACATION.WHT_AMT, WH_TYPE_DESC.WH_TYPE_DESC FROM ILGW_VACATION,WH_TYPE_DESC'
set stmt = stmt || 'WHERE'
set stmt = stmt || 'ILGW_VACATION.WHT_TYPE = WH_TYPE_DESC.WH_TYPE AND'
set stmt = stmt || 'ISSUED_DATE >= ' [red]
set stmt = stmt || ''' || DATE_FROM || ''' AND '
set stmt = stmt || 'ISSUED_DATE <='
set stmt = stmt || DATE_TO
set stmt = stmt || ' AND ILGW_VACATION.CHECK_STATUS IN (''' || LTRIM(RTRIM(CHECK_TYPE)) || ''' ) ORDER BY WHT_TYPE ASC ' ; [/red]
-- Cursor left open for client application
prepare v_stmt from stmt;
OPEN cursor1;
END P1
thanks a lot, cristi