Thread: SELECT INTO

SELECT INTO

From
"Roberto de Amorim"
Date:
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"
            WHERE
              "ID" = NEW.ID;

            ....
        end if
end'
LANGUAGE plpgsql;

but, when this function is called I'm getting the following error message:
ERROR: parser: parse error at or near ''''''

but if do it in 2 SELECTs it runs normally..


            SELECT INTO V_PAYMENT "DATE_PAYMENT"
                        FROM  "PAYMENTS"
            WHERE
              "ID" = NEW.ID;

            SELECT INTO V_VALUE "VALUE"
                      FROM  "PAYMENTS"
            WHERE
              "ID" = NEW.ID;


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

thats wrong there??


Roberto de Amorim - +55 48 346-2243
Software engineer at SmartBit Software
Delphi and Interbase consultant
roberto@smartbit.inf.br