Re: Re : overriding default value in inherited column (+ set_value function)
От | Stephan Szabo |
---|---|
Тема | Re: Re : overriding default value in inherited column (+ set_value function) |
Дата | |
Msg-id | Pine.BSF.4.21.0103201248480.30334-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Re: Re : overriding default value in inherited column (+ set_value function) ("Matt Magoffin" <mmagoffin@proxicom.com>) |
Список | pgsql-general |
I'd guess you could use TG_RELID or TG_RELNAME inside your trigger. On Tue, 20 Mar 2001, Matt Magoffin wrote: > Is there any way to make use of the tableoid either as an argument to the > function or as a reference within the function (in plpgsql)? For example, > I'd like to either > > CREATE TRIGGER set_default_value BEFORE INSERT > ON foo FOR EACH ROW EXECUTE PROCEDURE set_value('tableoid'); > > and within the function set_value(): > > SELECT p.relname::text FROM pg_class p WHERE p.oid = TG_ARGV[0]::oid ); > > - or - > > CREATE TRIGGER set_default_value BEFORE INSERT > ON foo FOR EACH ROW EXECUTE PROCEDURE set_value(); > > and within the function set_value(): > > SELECT p.relname::text FROM pg_class p WHERE p.oid = NEW.tableoid; > > The former produces the error > > ERROR: text_oid: error in "tableoid": can't parse "tableoid" > > and the later produces the error: > > ERROR: record new has no field tableoid > > I gather the former method is passing the string "tableoid" into the > set_value() function. I just want to be able to write one function that uses > the tableoid value to produce different results instead of unique functions > for each table I create.
В списке pgsql-general по дате отправления: