Re: Doubt on opaque returntype!! - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Doubt on opaque returntype!!
Date
Msg-id 20020918081149.W15838-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Doubt on opaque returntype!!  (Thirumoorthy Bhuvneswari <tbhuvneswari@yahoo.com>)
List pgsql-general
On Wed, 18 Sep 2002, Thirumoorthy Bhuvneswari wrote:

> hi,
> I am using postgresql-7.0 with RedHat Linux-7.1. I am
> having two tables:tableA and tableB. On every insert
> in tableA there should be an update in tableB.
> I created a function like the following:
> CREATE FUNCTION test_trigger() RETURNS opaque As '
> DECLARE
> v_sno INT:=0;
> BEGIN
> FOR C1 IN select sno from tableB LOOP
> v_sno:=v_sno+c1.sno;
> update tableB set sno=v_sno;
> END LOOP;
> RETURN opaque;

You should be returning a variable, probably NEW if
you want the insert to go through or NULL if you don't.

In addition, unless I'm missing something your function
appears to update every row of tableB once for each
row of tableB (ie, you're doing n^2 row modifications
given n rows in tableB).


pgsql-general by date:

Previous
From: Stephane Bortzmeyer
Date:
Subject: IPv6 type: a proposed implementation
Next
From: Stefan Stern
Date:
Subject: Special characters and units