2023-04-17

Snowflake scripting error in anonymous block execution

Getting below error:

Error:'STATEMENT_ERROR' on line 8 at position 6 : SQL compilation error: error line 1 at position 40 (line 130) invalid identifier 'ROW_VARIABLE.ID' (line 130)

code:

DECLARE
    id_variable INTEGER;
    price_variable float;
    c1 cursor for select id from invoices;
BEGIN
    Open c1;
    FOR row_variable IN c1 DO
      SELECT id, price INTO :id_variable, :price_variable 
          FROM invoices where id=row_variable.id; 
    END FOR;
    Close c1;
            
    RETURN id_variable || ' ' || price_variable;
END;


No comments:

Post a Comment