Re: plpgsql rowtype
От | Rory Campbell-Lange |
---|---|
Тема | Re: plpgsql rowtype |
Дата | |
Msg-id | 20030630133953.GA3628@campbell-lange.net обсуждение исходный текст |
Ответ на | Re: plpgsql rowtype (Hubert Lubaczewski <hubert.lubaczewski@eo.pl>) |
Список | pgsql-novice |
On 30/06/03, Hubert Lubaczewski (hubert.lubaczewski@eo.pl) wrote: > On Thu, 26 Jun 2003 11:47:47 +0200 (CEST) > Heiko.Kehlenbrink@vermes.fh-oldenburg.de wrote: > > > i want to proof if if a rowtype has an attribute or get all > > attribute of a rowtype. > > as far as i know - you can't. what would you need it for? do you need a proof for variable being of "text" type when declaredas text? > you declared it as rowtype - so it's rowtype. Why don't you make a type with the fields you want. Set these to a default value. Then check for whether or not a variable has been set the way you want it. (See below). Otherwise maybe all you need is to declare a record type and select into that, and then check the variables. Hope this helps. Rory CREATE TYPE view_object as ( itemid VARCHAR, itemtype INT2, itemtitle VARCHAR ); CREATE OR REPLACE FUNCTION fn_v3_object_view (integer, varchar, integer) RETURNS view_object AS ' DECLARE boardid ALIAS for $1; recone RECORD; BEGIN resulter.itemid := ''''; resulter.itemtype := 0; resulter.itemtitle := ''''; SELECT INTO recone itemid, itemtype, itemtitle FROM objects WHERE n_boardid = boardid; IF NOT FOUND OR recone.itemid < 1 THEN RAISE NOTICE ''my error message''; RETURN resulter; END IF; resulter.itemid := recone.itemid; resulter.itemtype := recone.itemtype; resulter.itemtitle := recone.itemtitle; RETURN resulter; END;' LANGUAGE plpgsql; -- Rory Campbell-Lange <rory@campbell-lange.net> <www.campbell-lange.net>
В списке pgsql-novice по дате отправления: