I try to create a procedure that return a query table from Postgresql, but I'm stuck at creating the procedure
CREATE OR REPLACE PROCEDURE "sap_data"."get_emp_number"(dep VARCHAR)
RETURNS TEMP TABLE (
emp_id VARCHAR,
department VARCHAR)
AS $BODY$
BEGIN
RETURN QUERY SELECT
emp_id,
department
FROM
emp_data
WHERE
department = dep
END;$BODY$
LANGUAGE plpgsql
When I save this procedure, this error occurs:
ERROR: syntax error at or near "TABLE" LINE 2: RETURNS TABLE (
I want to return this as a query so I can query this table using parameter to filter it.
"get_emp_number"(dep VARCHAR)