Hello all,

I have the following procedure. I wish it will return a single row result to 
caller, after I insert the value (as the row contains several auto generated 
fields), without perform additional SELECT query.

According to 
http://wischner.blogspot.com/2009/03/creating-stored-procedure-function.html, 
my guess is that, I need to use SETOF. However, pgAdmin doesn't allow me to 
enter "SETOF" in "Return Type".

However, it let me enter "lot" (lot is the name of the table)

May I know how can I modified the following function, to let it returns my 
newly inserted row?

CREATE OR REPLACE FUNCTION create_lot(text, text, text, 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); 
END;$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100;
ALTER FUNCTION create_lot(text, text, text) OWNER TO postgres;

Thanks and Regards
Yan Cheng CHEOK

p/s May I know what is the purpose of "COST 100"?


      


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to