July 2005
Intermediate to advanced
1032 pages
27h 10m
English
So far, all the functions that defined in this chapter have been called explicitly, either by using a SELECT function() command or by using the function within an expression. You can also call certain PL/pgSQL functions automatically. A trigger is a function that is called whenever a specific event occurs in a given table. An INSERT command, an UPDATE command, or a DELETE command can cause a trigger to execute.
Let's look at a simple example. You currently have a customers table defined like this:
CREATE TABLE customers
(
customer_id integer primary key,
customer_name character varying(50) not null,
phone character(8),
birth_date date,
balance decimal(7,2)
);
You want to create a new table that you can use to archive any rows that ...
Read now
Unlock full access