Hello all -
I've changed my sp to run dynamically with prepare statement & it does not return any results.
It runs fine in the regular procedure.
Any ideas, please???!!!
I think it has something to do with quotes…
It does not return any results....
Here is the working statement w/o prepare:
HELP PLEASE!!!!
I've changed my sp to run dynamically with prepare statement & it does not return any results.
It runs fine in the regular procedure.
Any ideas, please???!!!
I think it has something to do with quotes…
Code:
CREATE PROCEDURE BASYS.UMASS_ADD_NK_test (
in in_period date,
-- in tran_app char (6),
in in_empl char (9)
)
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
DECLARE p_in_empl varchar (200);
DECLARE stmt VARCHAR(4000);
DECLARE in_Employer_fmt VARCHAR(250);
DECLARE p_period varchar (50);
DECLARE cursor1 CURSOR WITH RETURN FOR s1;
if in_empl is null then
set stmt ='SELECT e.ssn, count( period) cnt FROM umass_contr_gr e WHERE e.period >= (date( ''' || CHAR(in_period) || ''' ) - 5 months) '||
'and e.period<date( ''' || CHAR(in_period) || ''' ) ' ||
'GROUP BY e.ssn ' ||
' having count( distinct period)=5';
end if;
PREPARE s1 FROM stmt;
-- Cursor left open for client application
END P1
It does not return any results....
Here is the working statement w/o prepare:
Code:
SELECT
e.ssn,
count( period) cnt
FROM
umass_contr_gr e
WHERE
e.period >= (date( in_period ) - 5 months) and e.period<date( in_period )
GROUP BY e.ssn
having count( distinct period)=5
HELP PLEASE!!!!