pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Benoît Bournon <benoit.bournon@adelis.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: tablename as attribute in pgplsql
Date: Thu, 22 May 2003 18:42:28 -0700 (PDT)
Message-ID: <20030522184108.C51260-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <3ECCF0D1.8030705@adelis.com>


On Thu, 22 May 2003, [ISO-8859-1] Benoît Bournon wrote:

> DECLARE
>    usertablename ALIAS FOR $1 ;
>    userid ALIAS FOR $2 ;
>
>    id_lang BIGINT ;
>
>    var VARCHAR(200) ;
>
> BEGIN
>       var := 'client' ;
>
>       SELECT id_language INTO id_lang FROM client WHERE id_user = userid ;
>       IF NOT (id_lang = 1 OR id_lang = 3) THEN
>           id_lang = 1 ;
>       END IF ;
>
>       RETURN id_lang ;
>
> END ;
>
> I want to use client table as a variable
>
> How could I do

Look at the documentation for EXECUTE.  Unfortunately using EXECUTE into a
variable is a little complicated right now AFAIR because you can't using
select ... INTO variable inside the execute, but instead need to use
something like for in execute loop.





view thread (6+ messages)  latest in thread

Message-ID: <20030522184108.C51260-100000@megazone23.bigpanda.com>
Permalink:  ../20030522184108.C51260-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20030522184108.C51260-100000@megazone23.bigpanda.com

 · 

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: sszabo@megazone23.bigpanda.com, benoit.bournon@adelis.com
  Subject: Re: tablename as attribute in pgplsql
  In-Reply-To: <20030522184108.C51260-100000@megazone23.bigpanda.com>

* 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