Try looking @
http://www.il.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN428
6
Specifically the special variable TG_RELNAME.
sb
"+I" <incognit@unifiedmind.com> wrote in message
news:ebcd475a.0112240514.3f43431e@posting.google.com...
> How do you, from within a function, reference the table name
> corresponding to the calling trigger?
>
> Specifically, I am creating an object map for all tables listed in
> km_object_types...
>
> create table km_object_types (
> table_name varchar(32) primary key,
> pretty_name varchar(100) not null,
> pretty_plural varchar(100)
> );
>
> create table object_map (
> table_name varchar(32) not null references km_object_types
> -- a single sequence is used for object_ids accross all tables
> object_id int not null unique
> primary key (table_name, object_id)
> );
>
> A trigger needs to insert object_id and table_name into object_map
> when inserts are made into any object table listed in km_object_types.
>
> The function to do this may look something like this, but I don't know
> how to reference the table name for the calling trigger...
>
> create function object_map_fn()
> returns opaque
> as '
> declare
> begin
>
> INSERT INTO km_object_map
> (object_id,table_name)
> VALUES
> (new.object_id,TABLE_NAME);
>
> return new;
> end;'
> language 'plpgsql';