PLPGSQL Function calls function, want result.

From: Hadley Willan <hadley(dot)willan(at)deeper(dot)co(dot)nz>
To: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: PLPGSQL Function calls function, want result.
Date: 2002-11-21 04:16:47
Message-ID: 1037852208.2300.71.camel@orac.area51.deeper.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I'm a bit of a newbie with Postgresql and PLPGSQL, and I can't seem to
find in the docs how to do the following.

Function fn_convert_currencies( VARCHAR, NUMERIC, VARCHAR ) Returns
NUMERIC.
Given a currency name and amount and name to convert to, this will
convert from amount A to B and return the resulting numeric.

Function fn_get_price( INT, VARCHAR ) Returns NUMERIC.
$1 stock number
$2 currency to show price in.
Comes along, and if the stock unit's recorded currency differs from the
display amount, then convert it and return the result amount.

However, my hold up is that I don't know the syntax of the call within
the function. To date, I've not needed the return results from a
function so I've pretty much ignored them.
Normally I would go.

PERFORM fn_convert_currencies( rec_stock.currency, rec_stock.amount,
_disp_curr)

But I kinda want to know the result.

I've tried the following:

--1
unit_price NUMERIC;
unit_price := PERFORM fn_conver.....

--2
unit_price NUMERIC;
PERFORM unit_price := fn_conver.....

--3
unit_price NUMERIC;
PERFORM unit_price := SELECT fn_conver

--4
rec_unit_price RECORD;
SELECT INTO rec_unit_price * FROM fn_conver.....

--5
rec_unit_price RECORD;
rec_unit_price := SELECT fn_conver.....

--6
rec_unit_price RECORD;
PERFORM rec_unit_price := fn_conver...

Hmmm, all to no avail.

1. Can I do this?

Thank You.

--
Hadley Willan > Systems Development > Deeper Design Limited.
hadley(at)deeper(dot)co(dot)nz > www.deeperdesign.com > +64 (21) 28 41 463
Level 1, 4 Tamamutu St, PO Box 90, TAUPO 2730, New Zealand.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message QUINN, JAY (SBCSI) 2002-11-21 04:31:40 Dumb Newbie Question - Mandrake 9.0 / PGSQL 7.2
Previous Message Tom Lane 2002-11-21 04:11:55 Re: [GENERAL] Bug with sequence