Здравствуйте.
Как написать функцию на postgresql чтоб она вернула несколько значений
Пример:
таблица
id | date| text
-----------------
id- PK= nextval('acm_comments_file_id_seq'::regclass)
функция для добавления строки в таблицу:
SQL |
begin insert into acm_comments_file (text) values($1); return ('now'::text)::timestamp(6) with time zone; end |
SQL |
return currval('acm_comments_file_id_seq'); |
SQL |
CREATE OR REPLACE FUNCTION "public"."acm_f_add_comment" (_id_np integer, _id_file integer, _comment varchar, out _date timestamp, out _id integer) RETURNS record AS $body$ begin insert into acm_comments_file (id_np,id_file,COMMENT) values($1,$2,$3); -- return currval('acm_comments_file_id_seq'); -- return ('now'::text)::timestamp(6) with time zone; _date = ('now'::text)::timestamp(6) with time zone; _id = currval('acm_comments_file_id_seq'::regclass); end $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; |