| From: | "Robert Fitzpatrick" <robert(at)webtent(dot)com> |
|---|---|
| To: | "PostgreSQL" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Using arguments with functions |
| Date: | 2004-07-10 19:50:30 |
| Message-ID: | 000501c466b7$28257bd0$0c01a8c0@webtent.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
While this function works when hard coded, the following will not when
trying the same thing with a argument. Can someone point to me what I'm
doing wrong?
CREATE OR REPLACE FUNCTION "public"."test" () RETURNS varchar AS'
DECLARE
var1 varchar;
BEGIN
var1 = chr( (ascii(''a'') + 1) );
return var1;
END;
'LANGUAGE 'plpgsql' VOLATILE RETURNS NULL ON NULL INPUT SECURITY INVOKER;
ohc=> select test();
test
------
b
(1 row)
This does not work:
CREATE OR REPLACE FUNCTION "public"."get_next" (varchar) RETURNS varchar AS'
DECLARE
var1 alias for $1;
BEGIN
var1 = chr( (ascii(var1) + 1) );
return var1;
END;
'LANGUAGE 'plpgsql' VOLATILE RETURNS NULL ON NULL INPUT SECURITY INVOKER;
ohc=> select get_next('a');
ERROR: "$1" is declared CONSTANT
CONTEXT: compile of PL/pgSQL function "get_next" near line 5
--
Robert
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oliver Elphick | 2004-07-10 20:08:46 | Re: Using arguments with functions |
| Previous Message | Bill Moran | 2004-07-10 19:44:38 | Re: win32 port |