Re: Problem with PL/pgSQL

From: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with PL/pgSQL
Date: 2001-02-25 04:26:35
Message-ID: 20010224202635.A18434@calico.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Feb 24, 2001 at 04:01:59PM +0100, Hans-Jürgen Schönig wrote:
> What is wrong with the following function?
>
> CREATE FUNCTION logfunc2 (text) RETURNS int AS '
> DECLARE
> text ALIAS FOR $1;
> BEGIN
> SELECT length(text);
> RETURN ''3'';
> END;
> ' LANGUAGE 'plpgsql';

That won't work:

CREATE FUNCTION logfunc2 (text) RETURNS int4 AS '
DECLARE
phrase ALIAS FOR $1; -- "text" is a reserved word
BEGIN
RETURN length (phrase);
END;
' LANGUAGE 'plpgsql';

testbed# SELECT logfunc2('foobar');
logfunc2
----------
6
(1 row)

> I get the following error:
>
> ERROR: Unrecognized language specified in a CREATE FUNCTION: 'plpgsql'.
>
> Recognized languages are sql, C, internal, and created
> procedural languages.

Maybe plpgsql is not "installed" into template1?

template1# SELECT * FROM pg_language;
lanname | lanispl | lanpltrusted | lanplcallfoid | lancompiler
----------+---------+--------------+---------------+-------------
internal | f | f | 0 | n/a
C | f | f | 0 | /bin/cc
sql | f | f | 0 | postgres
plpgsql | t | t | 21024 | PL/pgSQL
plperl | t | t | 305959 | PL/Perl
(5 rows)

--
Eric G. Miller <egm2(at)jps(dot)net>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-02-25 04:35:02 Re: Problem with PL/pgSQL
Previous Message Mitch Vincent 2001-02-25 03:47:36 Re: Problem with PL/pgSQL