PLPGSQL Function calls function, want result. - Mailing list pgsql-general

From Hadley Willan
Subject PLPGSQL Function calls function, want result.
Date
Msg-id 1037852208.2300.71.camel@orac.area51.deeper.co.nz
Whole thread Raw
Responses Re: PLPGSQL Function calls function, want result.  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@deeper.co.nz > www.deeperdesign.com > +64 (21) 28 41 463
Level 1, 4 Tamamutu St, PO Box 90, TAUPO 2730, New Zealand.



pgsql-general by date:

Previous
From: Reid Thompson
Date:
Subject: is the sqlca.sqlabc value unique for each response type
Next
From: Markus Wagner
Date:
Subject: stability of pg library usage