Received: from sahip.webevi.com (root@sahip.webevi.com [195.174.0.19]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA47988 for ; Wed, 29 Sep 1999 16:01:27 -0400 (EDT) (envelope-from ikizir@simteks.com.tr) Received: from kaplan (pm3-2-13.teklan.com.tr [195.174.0.163]) by sahip.webevi.com (8.8.8/8.8.5) with SMTP id WAA30174 for ; Wed, 29 Sep 1999 22:00:24 +0300 Message-ID: <006101bf0ab7$3b3e6120$a300aec3@kaplan> From: "Ismail Kizir" To: Subject: PL/PgSql documentation and examples Date: Wed, 29 Sep 1999 23:11:41 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-9" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 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';