pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed(no subject)
2+ messages / 2 participants
[nested] [flat]
* (no subject)
@ 1999-09-29 20:49 Ismail Kizir <ikizir@teklan.com.tr>
0 siblings, 1 reply; 2+ messages in thread
From: Ismail Kizir @ 1999-09-29 20:49 UTC (permalink / raw)
To: pgsql-sql
Hi all,
I need more information and examples for pl/pgsql.
The examples found on the source tree of postgres are not sufficient,
because they are all alphanumerical examples. I need function examples for
numerical computations.
I tried to code the example below but it responded with error message
something like '$= operator not defined for types int4 and float8 ...'
Thanks in advance.
Ismail Kizir
CREATE FUNCTION fCurr (date, int2, float8, int2) RETURNS float8 AS '
DECLARE
fcDate ALIAS FOR $1; -- Conversion date
fromCurrID ALIAS FOR $2; -- Which currency to convert
Amount ALIAS FOR $3; -- Amount to convert
toCurrID ALIAS FOR $4; -- Convert to which currency?
BolenCarpan float8;
BolunenCarpan float8;
BEGIN
IF fromCurrID = toCurrID THEN
RETURN Amount; -- If source and destination are the same, the result
is the input amount
END IF;
IF fromCurrID = 1 THEN -- If we convert the national currency
BolunenCarpan = 1;
ELSE
SELECT Rate FROM CurrDaily INTO BolunenCarpan WHERE cDATE = fcDate
AND CurrID::int2=fromCurrID::int2;
IF NOT FOUND THEN
RAISE EXCEPTION ''Currency info for % #%d not
found'',fcDate,fromCurrID
END IF;
END IF;
IF toCurrID = 1 THEN -- If we convert to national currency
BolenCarpan = 1;
ELSE
SELECT Rate FROM CurrDaily INTO BolenCarpan WHERE cDATE = fcDate AND
CurrID::int2=toCurrID::int2;
IF NOT FOUND THEN
RAISE EXCEPTION ''Currency info for % #%d not
found'',fcDate,fromCurrID
END IF;
END IF;
RETURN Amount*BolunenCarpan/BolenCarpan;
END;
' LANGUAGE 'plpgsql';
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Date: Wed, 29 Sep 1999 23:49:15 +0300
@ 1999-09-29 23:24 Tom Lane <tgl@sss.pgh.pa.us>
parent: Ismail Kizir <ikizir@teklan.com.tr>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 1999-09-29 23:24 UTC (permalink / raw)
To: Ismail Kizir <ikizir@teklan.com.tr>; +Cc: pgsql-sql
"Ismail Kizir" <ikizir@teklan.com.tr> writes:
> I tried to code the example below but it responded with error message
> something like '$= operator not defined for types int4 and float8 ...'
That's a known bug in plpgsql. You can work around it by putting spaces
acround the '=' operator (you may need them around other operators too).
I assume it'll get fixed properly for 6.6...
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-09-29 23:24 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-29 20:49 Ismail Kizir <ikizir@teklan.com.tr>
1999-09-29 23:24 ` Re: [SQL] Date: Wed, 29 Sep 1999 23:49:15 +0300 Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox