-----BEGIN PGP SIGNED MESSAGE-----
> - If I delete a record, I want to delete all its references. -- Is it right
> that I have to use a function and a trigger; but how?
Just say ON DELETE CASCADE when creating the reference. If you want a
row's references to be updated when you change the original row, you
should do ON UPDATE CASCADE, as well.
> - I want to make sure an entry does not exist in the table, before adding a
> new entry.
Select for it first, then do IF NOT FOUND. Or use a UNIQUE index on the
table, to keep the entries indexed. But watch out -- if any statement of
the script fails, it stops there.
> - When adding an entry generate another table's entry using some default
Store the default in some table, then do an INSERT ... SELECT.
> - Automatically delete entries that are old.
use DELETE WHERE x, where x is some definition of 'old'.
If you wanted this cleanup to happen without any continued queries, the
easiest way would be to 1) create a view which excludes 'old' entries, and
2) cleanup the 'old' entries before you vacuum each night.
> - Update entries based on other tables' information.
Not sure what you mean here. If you mean subselects, joins, or unions in
an update statement, that should work. Alternatively, do the selects you
need to get your answer in a Result, and then update from the Result.
> I think all of these problems are not possible to solve with regular
> SELECT, UPDATE and DELETE statements.
I beg to differ.
> So I guess what I am asking is, where do I find some documentation on
> triggers and functions for PostgreSQL 7.0.2?
Erm, did you try the main postgresql documentation? Perhaps you should
search it for 'triggers'? :o
Pl/PgSQL does not support utility statements such as create trigger,
however it will in postgresql 7.1.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----
In response to
- PL/pgSQL at 2000-08-30 07:40:47 from Stephan Richter
pgsql-general by date
|Next:||From: Andrew Snow||Date: 2000-08-30 14:22:36|
|Subject: RE: Large selects handled inefficiently?|
|Previous:||From: Martin Neimeier||Date: 2000-08-30 13:53:35|
|Subject: Jobs with PostgreSQL|