Re: "CASE" is not a variable

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: "CASE" is not a variable
Date: 2006-07-05 18:08:19
Message-ID: 20060705180422.M54977@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 28 Jun 2006 10:48:31 -0700, Bricklen Anderson wrote
> Keith Worthington wrote:
> >>> "Keith Worthington" <keithw(at)narrowpathinc(dot)com> writes:
> >>> The following is a section of code inside an SQL function.
> >> On Wed, 28 Jun 2006 12:16:29 -0400, Tom Lane wrote
> >> SQL, or plpgsql? It looks to me like misuse of the plpgsql INTO clause
> >> (there can be only one).
> >>
> >> regards, tom lane
> >
> > plpgsql
> >
> > This is part of a function inside a v8.0.2 database.
> >
> > I didn't realize that the INTO clause was only limited to one instance. I was
> > trying to accomplish
> >
> > SELECT col_a INTO var1,
> > col_b INTO var2,
> > col_c INTO var3,
> > ...
> > FROM foo
> > WHERE fobar;
> >
> > Kind Regards,
> > Keith
>
> try it like
> select col_a,col_b,col_c INTO va1,var2,var3 ....
>
> not sure if 8.0.2 allows you to do that, however.

Apparently it does. Just to wrap up this thread and hopefully help the next
person. When SELECTing multiple values into variables only use one instance of
the INTO clause. i.e.

SELECT col_a,
col_b,
col_c
INTO var1,
var2,
var3
FROM foo
WHERE fobar;

Kind Regards,
Keith

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Jones 2006-07-05 18:10:53 Re: Problem with array subscripts in plpgsql trigger function
Previous Message Aaron Bono 2006-07-05 17:56:31 Re: Problem with array subscripts in plpgsql trigger function