Re: SELECT INTO

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Roberto de Amorim" <roberto(at)smartbit(dot)inf(dot)br>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT INTO
Date: 2002-11-13 11:52:45
Message-ID: 200211131152.45462.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • SELECT INTO at 2002-11-13 10:24:32 from Roberto de Amorim

Browse pgsql-general by date

  From Date Subject
Next Message Adam Witney 2002-11-13 11:55:05 Re: Can not connect to the database
Previous Message アムス 2002-11-13 11:37:45 Can not connect to the database