From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Rule Error
Date: Fri, 5 Oct 2007 06:56:37 +0200
Message-ID: <20071005045637.GA14452@a-kretschmer.de> (raw)
In-Reply-To: <004601c806dc$8cd85a20$6f00a8c0@hengky>
References: <20071004130011.GH15428@a-kretschmer.de>
<004601c806dc$8cd85a20$6f00a8c0@hengky>
am Fri, dem 05.10.2007, um 7:16:06 +0800 mailte Hengky Lie folgendes:
> Yes, it works now ! Wow, the problem is in the field name. Changed it to
> lowercase solved the problem. Thank you to all ho give me this advice.
>
> But now I have another question regarding to this field, what command I can
> use in UPDATE RULE to make these 2 fields (KODEGL and NAMAREK) keep syncron
> between these 2 tables (tblmasdbt and tblmasgl) ?
As Richard suggested, use TRIGGER instead RULE, but okay.
A little example, i hope, it helps:
(2 little tables t1 and t2 and a UPDATE-RULE on t1 with a 'do also')
test=# create table t1 (id int, val int);
CREATE TABLE
test=*# create table t2 (id int, val int);
CREATE TABLE
test=*# create rule r1 as on update to t1 do also update t2 set val =
new.val where id=new.id;
CREATE RULE
test=*# commit;
COMMIT
test=# insert into t1 values (1,1);
INSERT 0 1
test=*# insert into t1 values (2,2);
INSERT 0 1
test=*# insert into t2 values (1,1);
INSERT 0 1
test=*# insert into t2 values (2,2);
INSERT 0 1
test=*# update t1 set val =10 where id=1;
UPDATE 1
test=*# select * from t2;
id | val
----+-----
2 | 2
1 | 10
(2 rows)
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: andreas.kretschmer@schollglas.com
Subject: Re: Rule Error
In-Reply-To: <20071005045637.GA14452@a-kretschmer.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox