I have the following initial situation in SnowFlake: I want to retrieve the NextVal of a sequence in a procedure and get the following error message when calling the procedure:
Uncaught exception of type 'STATEMENT_ERROR' on line 3 at position 29 : SQL compilation error: error line 1 at position 7 invalid identifier 'COMMON.SEQ_LAUF_ID'.
A select with the same user/role works fine:
Example SQL:
SELECT COMMON.SEQ_LAUF_ID as nv FROM DUAL ;
Example Proc:
create or replace procedure MDP_Codes ( )
returns varchar
language sql
EXECUTE AS CALLER
as
$$
DECLARE
rs resultset default ( SELECT COMMON.SEQ_LAUF_ID as nv FROM DUAL ) ;
hCur cursor for rs ;
SQL_lauf_id varchar ;
BEGIN
for hRow in hCur do
SQL_lauf_id := hRow.nv ;
end for;
return SQL_lauf_id ;
END;
$$
;
call APPSMITH.MDP_Codes();