Thread: Rule

Rule

From
sara_software@hotmail.com (sara_software)
Date:
How can a rule call a function?

I have found that I can do this:

CREATE RULE a_rule
AS ON INSERT TO a_table
DO INSTEAD  INSERT into other_table(myfunction());

actually I don't have any need for this test scenerio what I want to
do is say:

DO INSTEAD function();
where all insert changes and testing will be carried out.

but it doesn't seem to let me do this, of course all the documentation
leads me to believe it is not possible, but if I am able to call the
function from within an insert statement, can't I just skip that all
together and call the function alone?

Be gentle.

~Sara

Re: Rule

From
Stephan Szabo
Date:
On 25 Nov 2001, sara_software wrote:

> How can a rule call a function?
>
> I have found that I can do this:
>
> CREATE RULE a_rule
> AS ON INSERT TO a_table
> DO INSTEAD  INSERT into other_table(myfunction());
>
> actually I don't have any need for this test scenerio what I want to
> do is say:
>
> DO INSTEAD function();
> where all insert changes and testing will be carried out.
does DO INSTEAD select function();
work?



Re: Rule

From
Martín Marqués
Date:
On 25 Nov 2001, sara_software wrote:

> How can a rule call a function?
>
> I have found that I can do this:
>
> CREATE RULE a_rule
> AS ON INSERT TO a_table
> DO INSTEAD  INSERT into other_table(myfunction());
>
> actually I don't have any need for this test scenerio what I want to
> do is say:
>
> DO INSTEAD function();
> where all insert changes and testing will be carried out.

Use a trigger. :-)


Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués                  |        mmarques@unl.edu.ar
Programador, Administrador, DBA |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------