Re: SELECT INTO - Mailing list pgsql-general

From Richard Huxton
Subject Re: SELECT INTO
Date
Msg-id 200211131152.45462.dev@archonet.com
Whole thread Raw
In response to SELECT INTO  ("Roberto de Amorim" <roberto@smartbit.inf.br>)
List pgsql-general
On Wednesday 13 Nov 2002 10:24 am, Roberto de Amorim wrote:
> Hi all
>
> I'm tring to do some trigger and I must use a SELECT INTO,
> look this:
>
> CREATE OR REPLACE FUNCTION f_lancamentos_pagos() RETURNS opaque AS
> '  DECLARE V_VALUE NUMERIC(12,2);
>   DECLARE V_PAYMENT TIMESTAMP;
> begin
>        if tg_op = ''INSERT'' then
>             SELECT INTO V_PAYMENT "DATE_PAYMENT",
>                                       V_VALUE "VALUE"
>             FROM  "PAYMENTS"

I think perhaps it should be:
    SELECT INTO V_PAYMENT,V_VALUE "DATE_PAYMENT","VALUE"...

> so, if I want get 10 columns, must I do 10 SELETCs???

If you want 10 columns, you might prefer to select into a record variable and
reference the columns as required.

http://www.postgresql.org/idocs/index.php?plpgsql-statements.html

--
  Richard Huxton

pgsql-general by date:

Previous
From: Adam Witney
Date:
Subject: Re: Can not connect to the database
Next
From: "Henrik Steffen"
Date:
Subject: Re: Upgrade to dual processor machine?