Re: Converting mysql "on update" to postgres "rule"

From: Rodrigo Gonzalez <rjgonzale(at)gmail(dot)com>
To: Edward Blake <comedian(dot)watchman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Converting mysql "on update" to postgres "rule"
Date: 2008-03-25 19:14:41
Message-ID: 47E94F21.9080501@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edward Blake escribió:
> Thanks to everyone who's helped me before.
>
> I'm trying to create the following mysql table in postgres:
>
> CREATE TABLE visit (
> data1 varchar(30) NOT NULL,
> data2 varchar(30) DEFAULT NULL,
> data3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> CURRENT_TIMESTAMP);
>
> Thus far, I've been able to get this far:
> CREATE TABLE visit (
> data1 varchar(30) NOT NULL,
> data2 varchar(30) DEFAULT NULL,
> data3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP);
> CREATE RULE timestamp_update AS ON UPDATE TO visit
> DO ALSO
> UPDATE vist
> SET data3 = CURRENT_TIMESTAMP;

You are in a loop...

Use a trigger that put NEW.data3 - CURRENT_TIMESTAMP
>
> I've tried multiple iterations of how to accomplish this and keep
> getting stuck. With the one above, postgres yells and says:
> ERROR: infinite recursion detected in rules for relation "visit"
>
> Any ideas?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2008-03-25 19:20:06 Re: Converting mysql "on update" to postgres "rule"
Previous Message Andrew Sullivan 2008-03-25 19:13:33 Re: Converting mysql "on update" to postgres "rule"