Re: Rule Error

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Rule Error
Дата
Msg-id 20071005045637.GA14452@a-kretschmer.de
обсуждение исходный текст
Ответ на Re: Rule Error  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Hengky Lie"
Дата:
Сообщение: Re: Rule Error
Следующее
От: "Dawid Kuroczko"
Дата:
Сообщение: Re: [ADMIN] Postgres Array Traversing Problem