delay of function - Mailing list pgsql-novice

From Jaromír Kamler
Subject delay of function
Date
Msg-id 200603011757.1269@centrum.cz
Whole thread Raw
Responses Re: delay of function  (Michael Fuhr <mike@fuhr.org>)
List pgsql-novice
hallo,
I use PostGIS ... .

I have table:
CREATE TABLE basic_metadata(name text,size text, ......);

Inside I want insert some records (name of new table, size of new table and etc.), so I created trigger on the table
geometry_columns:
CREATE TRIGGER ins_metdta AFTER INSERT ON geometry_columns FOR EACH ROW EXECUTE PROCEDURE insert_new();

CREATE OR REPLACE FUNCTION insert_new() RETURNS trigger AS $$
DECLARE
str text;
BEGIN
  str := 'insert into basic_metadata(name,size) values
(\''||new.f_table_name||'\',\''||pg_size_pretty(pg_relation_size(new.f_table_name))||'\');';
  raise notice '%', str;
  execute str;
  return null;
END;
$$ LANGUAGE PLPGSQL;

Every time, when is something inserted into table geometry_columns would trigger insert some data into the table
basic_metadata,but it fail, becouse in that time when is inserted name of new table into geometry_columns is not
createdthat new table physically and therefore I can't call function pg_relation_size(). It is created after that. So I
needwait with calling that trigger until that new table is done or ...... ????? Does anybody have some solution? 

Thanks for your advices,
Jaromír Kamler


pgsql-novice by date:

Previous
From: Steve Crawford
Date:
Subject: Re: install problems
Next
From: Bruno Wolff III
Date:
Subject: Re: install problems