Trigger to update table info

From: Arvind Singh <arvindps(at)hotmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Trigger to update table info
Date: 2013-08-12 07:16:33
Message-ID: BLU164-W1BBF09221B2C555E92428CA5B0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello friends,

I have a table with the following structure

Create table postablestatus

(

tablename
varchar(30) NOT NULL,

updatetime timestamp,

reccount
int,

size
int,

CONSTRAINT postablestatus_pkey PRIMARY KEY(tablename)

)
WITH (oids = false);

where
a) tablename - is the name of table where a record is inserted,updated or deleted
b) updatetime - the time when table was updated (w/o timezone)
c) reccount - records in table
d) size - bytesize of the table

--
for example, if a table called item_master had 1 record and a
new record is inserted and it's size is 2000 bytes

> postablestatus must have a entry like

item_master 08/12/2013 12:40:00 2 2000
--

I request to know how to write a trigger in PLSQL so that the postablestatus
is updated whenever a record is inserted,updated or deleted in item_master

PLEASE NOTE : a new record must be created if the item_master is not present in postablestatus

thanks in advance
arvind

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Seref Arikan 2013-08-12 08:35:10 Re: Pl/Python runtime overhead
Previous Message Victor Hooi 2013-08-12 04:59:11 Re: Performance of ORDER BY RANDOM to select random rows?