From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Anshuman Kanwar <ansh(at)expertcity(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Create tables based on another table |
Date: | 2003-09-22 06:17:39 |
Message-ID: | 1064211459.26041.45.camel@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Sun, 2003-09-21 at 19:23, Anshuman Kanwar wrote:
> Hi all,
>
> I want to have a table that lists all other tables in a database. For
> example:
,,,
>
> Now I want to automatically create a new table in the database whenever an
> entry is made in this "Project_List". Based on "project_type", this new
> table could have 2 different structures.
...
> What mechanism can I use to accomplish this ? Could anyone point me to any
> documentation ?
You need a trigger that runs after every INSERT. If the data can change
and affect the subsidiary tables as a result, you may also need triggers
to run after UPDATE and/or DELETE.
See:
CREATE TRIGGER
CREATE FUNCTION
Procedural languages: PL/pgSQL (especially the chapter on using this
language in a trigger)
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Therefore when thou doest thine alms, do not sound a
trumpet before thee, as the hypocrites do in the
synagogues and in the streets, that they may have
glory of men. Verily I say unto you, They have their
reward. But when thou doest alms, let not thy left
hand know what thy right hand doeth; That thine alms
may be in secret; and thy Father which seeth in secret
himself shall reward thee openly." Matthew 6:2-4
From | Date | Subject | |
---|---|---|---|
Next Message | Aled Morris | 2003-09-22 07:55:21 | Re: DTS |
Previous Message | Anshuman Kanwar | 2003-09-21 18:23:56 | Create tables based on another table |