468,785 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

how to dynamically execute a select query based on some condition

i created

CREATE PROCEDURE SP_STMT_STMTRETRIEVE10(IN p_client_id varchar(32) ,IN p_TIN varchar(32))

P1: BEGIN
DECLARE p_customer_id varchar(32);
DECLARE stmt VARCHAR(100);
DECLARE cursor1 CURSOR WITH RETURN FOR S1;
select customer_id into p_customer_id from .CUSTOMER where client_id = p_client_id;
IF (p_TIN is not null ) then
SET stmt='SELECT statement_id,dt_read
FROM DOC_TRACKER_TAX_STMT WHERE
TIN=||p_TIN||' and customer_id='||p_customer_id;
ELSE
SET stmt='SELECT statement_id,dt_read
FROM DOC_TRACKER_ACCT_STMT WHERE
customer_id=p_customer_id';
END IF;
prepare s1 from stmt;
Open cursor1;
END P1@

the code got compiled but when i tried

call SP_STMT_STMTRETRIEVE10('123','123')

it throws a error
The PREPARE or EXECUTE IMMEDIATE could not be completed.

help me ou
Jan 12 '07 #1
0 1811

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by CARIGAR | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.