Problems with stored procedure

Поиск
Список
Период
Сортировка
Искать
От
lmanorders
Тема
Problems with stored procedure
Дата
Msg-id
26CEDE87A7E14D56BCDA26A0CE6550A1@LynnPC
Ответ на
Список
Дерево обсуждения
Show stored function code mephysto <mephystoonhell@gmail.com>
Re: Show stored function code Merlin Moncure <mmoncure@gmail.com>
Re: Show stored function code Mephysto <mephystoonhell@gmail.com>
Re: Show stored function code Merlin Moncure <mmoncure@gmail.com>
Re: Show stored function code mephysto <mephystoonhell@gmail.com>
Re: Show stored function code Merlin Moncure <mmoncure@gmail.com>
Re: Show stored function code Mephysto <mephystoonhell@gmail.com>
Re: Show stored function code Merlin Moncure <mmoncure@gmail.com>
Problems with stored procedure "lmanorders" <lmanorders@gmail.com>
Re: Problems with stored procedure "lmanorders" <lmanorders@gmail.com>
Re: Problems with stored procedure Gavin Flower <GavinFlower@archidevsys.co.nz>
(More) Questions about stored procedures "lmanorders" <lmanorders@gmail.com>
Re: (More) Questions about stored procedures Merlin Moncure <mmoncure@gmail.com>
Re: Show stored function code Tom Lane <tgl@sss.pgh.pa.us>
Re: Show stored function code Mephysto <mephystoonhell@gmail.com>
I'm trying to learn how to use stored procedures. In particular, I need to 
return multiple values from the function, so I've been experimenting with 
the OUT argument type. I'm writing code in C++ and using the libpq dll as 
the interface to postgresql. I've created the following function, that 
works:

CREATE OR REPLACE FUNCTION getdetailamts ( acct_no char(22), beg_moyr 
char(6),
      end_moyr char(6), OUT beg_bal float8) AS $$
  DECLARE sum_totl float8;
  BEGIN
    SELECT SUM(dramt) FROM detrec WHERE detrec.acctno = $1 AND detrec.apmoyr 
 >= $2 AND
               detrec.apmoyr <= $3 INTO sum_totl;
    beg_bal := sum_totl;
  END; $$ language plpgsql;

This returns the proper value, but when I attempt to add a second argument 
of OUT type, I get an error when attempting to create the function:

CREATE OR REPLACE FUNCTION getdetailamts ( acct_no char(22), beg_moyr 
char(6),
      end_moyr char(6), OUT beg_bal float8, OUT half_bal float8) AS $$
  DECLARE sum_totl float8;
  BEGIN
    SELECT SUM(dramt) FROM detrec WHERE detrec.acctno = $1 AND detrec.apmoyr 
 >= $2 AND
               detrec.apmoyr <= $3 INTO sum_totl;
    beg_bal := sum_totl;
    half_bal := sum_totl / 2;
  END; $$ language plpgsql;

Can anyone tell me why adding the second OUT argument type causes the 
function to return an error and not be created?

Thanks, Lynn


В списке pgsql-novice по дате отправления
От: Tom Lane
Дата:
Сообщение: Re: Vacuum error message
От: lmanorders
Дата:
FAQ