1
votes

getting error while compiling below sp

CREATE OR REPLACE FUNCTION get_name ( IN E_ID NUMERIC, OUT N varchar(30), OUT S NUMERIC) 
LANGUAGE plpgsql
AS $P1$
DECLARE CURSOR1 CURSOR FOR
SELECT NAME, SALARY INTO N,S
FROM PUBLIC.EMPLOYEE
WHERE(EMP_ID=E_ID);
BEGIN
-- CURSOR LEFT OPEN FOR CLIENT APPLICATION
OPEN CURSOR1;
END $P1$ 

ERROR: syntax error at or near ","

LINE 6: SELECT NAME, SALARY INTO N,S

whats wrong in this line

select col1, col2 into v1,v2 from table1 Is this correct in PostgreSQL?

1

1 Answers

1
votes

Remove 'INTO N,S' in your cursor declaration: this is not the right way to use cursor in PL/PGSQL.

After the cursor is opened, you use FETCH INTO: this is where you are using table column from cursor result set.

See https://www.postgresql.org/docs/current/plpgsql-cursors.html