Rules & cycles - Mailing list pgsql-general

From Moray McConnachie
Subject Rules & cycles
Date
Msg-id 017101bf329e$099c4100$760e01a3@oucs.ox.ac.uk
Whole thread Raw
In response to Book completed through chapter 6  (Bruce Momjian <pgman@candle.pha.pa.us>)
List 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.McConnachie@computing-services.oxford.ac.uk
----- Original Message -----
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: PostgreSQL-announce <announce@postgreSQL.org>; PostgreSQL-general
<pgsql-general@postgreSQL.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@candle.pha.pa.us            |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania
19026
>
> ************
>
>


pgsql-general by date:

Previous
From: Pablo Sentis Castaño
Date:
Subject:
Next
From: "Shawn Pursley"
Date:
Subject: Trying to SELECT via web server using PHP