Re: Return Single Row Result After Inserting (Stored Procedure) - Mailing list pgsql-general

From Yan Cheng Cheok
Subject Re: Return Single Row Result After Inserting (Stored Procedure)
Date
Msg-id 268500.83231.qm@web65710.mail.ac4.yahoo.com
Whole thread Raw
In response to Return Single Row Result After Inserting (Stored Procedure)  (Yan Cheng Cheok <yccheok@yahoo.com>)
Responses Re: Return Single Row Result After Inserting (Stored Procedure)  (Adrian Klaver <adrian.klaver@gmail.com>)
List pgsql-general
Thanks!

However, we prefer to stick with plpgsql, as rest of our functions are in that language. We need some consistency.

I try to modify my previous stored procedure to.

CREATE OR REPLACE FUNCTION create_lot(text, text, text)
   RETURNS lot AS
$BODY$DECLARE
     configurationFile ALIAS FOR $1;
     operatorName ALIAS FOR $2;
     machineName ALIAS FOR $3;
 BEGIN
     INSERT INTO lot(configuration_file, operator_name, machine_name)
     VALUES(configurationFile, operatorName, machineName) RETURNING *;
 END;$BODY$
   LANGUAGE 'plpgsql' VOLATILE
   COST 100;
 ALTER FUNCTION create_lot(text, text, text) OWNER TO postgres;

However, we get the following error.

SemiconductorInspection=# SELECT * FROM create_lot('a','b','3');
ERROR:  query has no destination for result data
CONTEXT:  PL/pgSQL function "create_lot" line 9 at SQL statement

Any suggestion? Thanks!

Thanks and Regards
Yan Cheng CHEOK







pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: 8.4.1 & 8.4.2 require map=... for ident in the pg_hba.conf file, will this be the new way?
Next
From: Adrian Klaver
Date:
Subject: Re: Return Single Row Result After Inserting (Stored Procedure)