pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Unnikrishnan Menon <unnikrishnan.menon@chennai.transys.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problems with PL/PGSQL - functions
Date: Sun, 13 Jan 2002 10:19:31 -0600
Message-ID: <20020113161931.GB7025@rice.edu> (raw)
In-Reply-To: <008801c19c3f$d588ce70$e90aa8c0@UNNIKRISHNAN>
References: <008801c19c3f$d588ce70$e90aa8c0@UNNIKRISHNAN>

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



view thread (4+ messages)  latest in thread

Message-ID: <20020113161931.GB7025@rice.edu>
Permalink:  ../20020113161931.GB7025@rice.edu/
Also on:    postgresql.org/message-id/20020113161931.GB7025@rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: reedstrm@rice.edu, unnikrishnan.menon@chennai.transys.net
  Subject: Re: Problems with PL/PGSQL - functions
  In-Reply-To: <20020113161931.GB7025@rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox