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@jps.net>