Pgsql 8.1.4.

I want return custom type from function as row, not as values in brackets (1,2).

I have following type and function:

CREATE TYPE new_item_return_type AS
  (item_id bigint,
   last_update timestamp without time zone);

CREATE OR REPLACE FUNCTION new_item( new_title int8, new_user_id int8)
RETURNS new_item_return_type AS
$BODY$
DECLARE
ret new_item_return_type%ROWTYPE;
BEGIN
   INSERT INTO item (user_id,title) VALUES (new_user_id,new_title) ;
   ret.item_id:= currval('item_id_seq');
   SELECT time_last_update INTO ret.last_update  FROM item WHERE id
=ret.item_id;
   RETURN ret;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;


Seems like in DECLARE ret new_item_return_type%ROWTYPE;
%ROWTYPE is ignored.


When I run SELECT public.new_item(3,2);
I get :
new_item_return_type
---------------------------------
"(32,"2006-10-11 10:14:39")"


I want to get:
item_id   |   last_update
-------------------------------------
32         |  1234-12-12 12:12:12


Is it possible ? I am using the wrong approach?

Thanks.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to