Re: Help with Procedures in pgsql

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: Nelio Alves Pereira Filho <nelio(at)ifx(dot)com(dot)br>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Help with Procedures in pgsql
Date: 2000-12-01 06:32:12
Message-ID: 0012010132120Q.00289@comptechnews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Monday 27 November 2000 15:01, Nelio Alves Pereira Filho wrote:
> I have the folowing procedure in PL/pgsql:
>
> CREATE FUNCTION set_counter () RETURNS INT AS '
> DECLARE
> nivel_rec record;
> new_count integer;

I always used the syntax like:

nivel_rec nivel%ROWTYPE;

Not sure it matters though.

> BEGIN
> UPDATE nivel SET count=-2;
>
> FOR nivel_rec IN SELECT * FROM nivel LOOP
> new_count := set_counter_row (nivel_rec);
> END LOOP;

I don't know what set_counter_row() is doing so the problem could be in that
function.

>
> RETURN new_count;
> END;'
> LANGUAGE 'plpgsql';
>
> I create it, but when I do 'select set_counter()', it says
> IFX=# select set_counter();
> ERROR: Attribute 'nivel_rec' not found
>
> Isn't that the right sintax to declare variables in pgsql? What's wrong
> with it?
> Does my procedure contain any other errors that will appear later?
>
>
>
> Thanks

--
-------- Robert B. Easter reaster(at)comptechnews(dot)com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jens Hartwig 2000-12-01 10:40:52 How to identify connected Users?
Previous Message Tom Lane 2000-12-01 05:33:22 Re: [HACKERS] Re: Rules with Conditions: Bug, or Misunderstanding