From: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu> |
---|---|
To: | Unnikrishnan Menon <unnikrishnan(dot)menon(at)chennai(dot)transys(dot)net> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Problems with PL/PGSQL - functions |
Date: | 2002-01-13 16:19:31 |
Message-ID: | 20020113161931.GB7025@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Sun, Jan 13, 2002 at 08:07:27PM +0530, Unnikrishnan Menon wrote:
> Hi,
>
> I have a couple of problems :
>
> 1. I create a temporary table using the following method within a function:
>
> query := ''Create table S_'' || nextval(sequence) || '' ( abc integer, xyz varchar)'';
> Execute query;
> This query does create a table. But when I'am unable to access the records in the table. I use the following methods:
>
> a. Select xyz into variable from S_''|| nextval(sequence)||'' where abc = (some counter value) ;
> b. query1 := '' Select xyz as variable from S_''|| nextval(sequence)||'' where abc = (some counter value) '' ;
> Execute query1;
Right, because each one increments the sequence. Try substituting currentval().
Oh, and you might want to create the table as a temp table, in a transaction,
so it'll go aeway automatically for you at the end of the transaction.
Ross
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-01-13 16:59:33 | Re: Problems with PL/PGSQL - functions |
Previous Message | Unnikrishnan Menon | 2002-01-13 14:37:27 | Problems with PL/PGSQL - functions |