Rules & cycles

From: "Moray McConnachie" <moray(dot)mcconnachie(at)computing-services(dot)oxford(dot)ac(dot)uk>
To: "PostgreSQL-general" <pgsql-general(at)postgresql(dot)org>
Subject: Rules & cycles
Date: 1999-11-19 14:54:53
Message-ID: 017101bf329e$099c4100$760e01a3@oucs.ox.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general

Is it possible to avoid a rule calling itself, as it were?

i.e.

CREATE TABLE test (testnumber float8,testid serial primary key);

CREATE FUNCTION adjust(float8) RETURNS '
SELECT dpow(1.14,$1) AS result;'
LANGUAGE 'SQL';

CREATE RULE testtest AS ON INSERT TO test
DO INSTEAD INSERT INTO test (testnumber) VALUES
(adjust(new.testnumber));

INSERT INTO test VALUES (2);

now gets into an endless loop, which postgres intelligently breaks out
of with an ERROR:

What I want is just to make that substitution once!

If possible I want to do this without rewriting my application to use
a view of the table rather than the table itself...

Yours,
Moray

----------------------------------------------------------------------
----------------
Moray(dot)McConnachie(at)computing-services(dot)oxford(dot)ac(dot)uk
----- Original Message -----
From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-announce <announce(at)postgreSQL(dot)org>; PostgreSQL-general
<pgsql-general(at)postgreSQL(dot)org>
Sent: Thursday, November 18, 1999 12:41 PM
Subject: [GENERAL] Book completed through chapter 6

> I have completed through chapter 6 of my book, "PostgreSQL:
> Introduction and Concepts." Of course, this is only the first
draft.
> It can be viewed at:
>
> http://www.postgresql.org/docs/awbook.html
>
> There are major improvements in this version. I have added sections
to
> chapter 4 dealing with DEFAULT and functions/operators. The figure
> placement and font usage is improved.
>
> Chapter 6 covers using multiple tables and joins. This was a very
> difficult chapter for me to write.
>
> --
> Bruce Momjian | http://www.op.net/~candle
> maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania
19026
>
> ************
>
>

In response to

Browse pgsql-announce by date

  From Date Subject
Next Message Alexander Barkov 1999-11-24 16:59:02 ANNOUNCE UdmSearch
Previous Message Bruce Momjian 1999-11-18 14:42:24 Publisher looking for Reviewers

Browse pgsql-general by date

  From Date Subject
Next Message Jason 1999-11-19 15:02:04 PG for Win.
Previous Message Pablo Sentis Castaño 1999-11-19 13:49:00