on 02-06-2017 9:36 AM
I have checked similar questions and couldn't find the answer.
I have used cursors many times before but not with an intersection query, so I think the error is thrown from the first Declare cursor statement. When i call the below procedure, i get error: SAP DBTech JDBC: [1287]: identifier must be declared: PRI
PROCEDURE "SP_RetiredEmp_AddDayCal" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
--DEFAULT SCHEMA <default_schema_name>
--READS SQL DATA
AS
BEGIN
/*****************************
Write your procedure logic
*****************************/
DECLARE PRI_T VARCHAR(9);
DECLARE RECDATE_T DATE;
DECLARE CHANGEDT_T DATE;
DECLARE DAYS_T INTEGER :=0;
DECLARE CURSOR DISTINCT_PRI for select distinct(PRI) as PRI from (
select distinct(PRI) from "App_RecordDate"
INTERSECT
select distinct(PRI) from "Mobility_ChangeDate");
For D_PRI as DISTINCT_PRI do
DECLARE CURSOR RECDATE for select RECDATE from "App_RecordDate" where PRI = D_PRI.PRI order by RECDATE;
For R_D as RECDATE do
RECDATE_T := R_D.RECDATE;
select MAX("CHANGEDT") into CHANGEDT_T from "Mobility_ChangeDate" where PRI = D_PRI.PRI and CHANGEDT<iterator_row.R_D.RECDATE;
IF :RECDATE_T < :CHANGEDT_T
THEN
DAYS_T := days_between(:RECDATE_T,:CHANGEDT_T);
ELSE
DAYS_T := 0;
END IF;
Insert into "RetiredEmp_AddDayCal" values (D_PRI.PRI,:RECDATE_T,:CHANGEDT_T,:DAYS_T);
END FOR;
END FOR;
END;
You have to transfer the "PRI" value as parameter to the second cursor instead of using it directly.
E.g.
...
FOR d_pri AS distinct_pri DO
DECLARE CURSOR recdate(p_pri nvarchar(100))
FOR SELECT recdate FROM "App_RecordDate" WHERE pri= :p_pri ORDER BY recdate;
FOR r_d AS recdate(:d_pri.pri) DO
...
Please adjust the type of the PRI value for the PRI cursor parameter.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.