Stumped on PlPgSql

From: AGRE Enterprises <agree(at)godzone(dot)net(dot)nz>
To: pgsql-general(at)hub(dot)org
Subject: Stumped on PlPgSql
Date: 2000-10-17 08:12:36
Message-ID: 200010170812.VAA17795@agree-6.godzone.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ok, I give up :-(

I have recently upgraded my development system to 7.0.2, my production server is still
6.5.1

I have a Plpsgsql function that I have been using in 6.5.1 and it works fine.

The same function on 7.0.2 gives me an error. I have looked in the doc and haven't
seen any change in syntax but maybe Im blind.

The function is

-- ------------------------------------------------------------------------
-- PostCharge
-- ------------------------------------------------------------------------
CREATE FUNCTION "postcharge" ( int4, int4, int4, int4, int4, text )
RETURNS bool AS '
DECLARE
clnt ALIAS FOR $1;
invnum ALIAS FOR $2;
rescode ALIAS FOR $3;
zone ALIAS FOR $4;
q ALIAS FOR $5;
cmmnt ALIAS FOR $6;
res RECORD;
ctrl RECORD;
amt float8;
qf float8;
BEGIN
SELECT * INTO res FROM resource WHERE code = rescode;
IF res.status <> ''A'' THEN
RETURN ''f'';
END IF;
SELECT * INTO ctrl FROM control;
qf := float8( q );
IF zone = 0 THEN
amt := res.rate_internal * qf;
END IF;
IF zone = 1 THEN
amt := res.rate_local * qf;
END IF;
IF zone = 2 THEN
amt := res.rate_national * qf;
END IF;
IF zone = 3 THEN
amt := res.rate_international * qf;
END IF;
INSERT INTO client_trans (
client, resource, invnum, period, tstamp, comment, qty, amount
) VALUES (
clnt, rescode, invnum, ctrl.open_period, ''now'', cmmnt, q, amt );
RETURN ''t'';
END;
' LANGUAGE 'plpgsql';

The error is

ERROR: parser: parse error at or near "$1"

Any help would be appreciated.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Colin Taylor 2000-10-17 08:14:03 Getting DateStyle Using C++ Library
Previous Message Rikul Patel 2000-10-17 08:00:31 Limit on number of queries from CGI or PHP (security)