create rule

From: chunxia xu <chunxia_xu(at)yahoo(dot)com>
To: pgsql-general(at)postgreSQL(dot)org
Subject: create rule
Date: 2002-06-03 22:37:29
Message-ID: 20020603223729.4738.qmail@web11601.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This won't work:

CREATE TABLE pub_gene (
pub_gene_id serial PRIMARY KEY,
name varchar(200) default NULL
);

CREATE TABLE term (
term_id serial PRIMARY KEY,
name varchar(200) default NULL,
pub_gene_id INTEGER references pub_gene
ON UPDATE CASCADE
ON DELETE SET NULL
);

CREATE RULE pub_gene_insert_term AS -- INSERT rule
ON INSERT TO pub_gene
DO
insert into term(term_id, name, date_entered,
entered_by )
values (nextval('term_term_id_seq'),
(select name from pub_gene where
pub_gene_id=currval('pub_gene_pub_gene_id_seq'))
)
);

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-06-03 23:41:09 Re: Vacuum behaviour in plpgsql function
Previous Message Joshua b. Jore 2002-06-03 21:21:53 Re: ctid & updates