PL/pgSQL definition

Started by Jose' Soaresabout 27 years ago2 messages
#1Jose' Soares
jose@sferacarta.com

--postgresql-v6.4/src/pl/plpgsql/src/INSTALL says:
...
If you declare the language in the template1 database,
any subsequently created database will have PL/pgSQL
support installed automatically.

--I declared PL/pgSQL in the template1 database but I have an ERROR
message when I try to
--use PL/pgSQL language in another database.

create function nvl(integer) returns integer as
'declare
nonullo alias for $1;
begin
if nonullo then
return nonullo;
else
return 0;
end if;
end;
' language 'plpgsql';
ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recogn
ized languages are sql, C, internal and the created procedural
languages.

--Seems that I must to declare PL/pgSQL in every database.
--Any ideas?

--Please relply to sferac@bo.nettuno.it

--Jose-

#2Noname
jwieck@debis.com
In reply to: Jose' Soares (#1)
Re: [HACKERS] PL/pgSQL definition

--postgresql-v6.4/src/pl/plpgsql/src/INSTALL says:
...
If you declare the language in the template1 database,
any subsequently created database will have PL/pgSQL
support installed automatically.

--I declared PL/pgSQL in the template1 database but I have an ERROR
message when I try to
--use PL/pgSQL language in another database.

ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recogn
ized languages are sql, C, internal and the created procedural
languages.

--Seems that I must to declare PL/pgSQL in every database.
--Any ideas?

You must declare PL/pgSQL in template1 BEFORE you create the
other databases. At createdb time, the template1 database is
copied into the new created database. All definitions, you
made until then are automatically in the new db. So you could
also create tables, functions and anything else you want to
have by default in any new db.

--Please relply to sferac@bo.nettuno.it

--Jose-

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #