creating functions

Started by Dale Walkerover 25 years ago3 messagesgeneral
Jump to latest
#1Dale Walker
dale@icr.com.au

Hi All,

I'm trying to create a function that takes an interval (in seconds)
and
returns HH:MM:SS similar to reltime() but not dividing down to num#
days,months etc...

anyway, I've been looking into the CREATE FUNCTION routines and
here I
struck a stumbling block.

I tried(from the doco):
----------------------------------------------------------
CREATE FUNCTION concat_text (text, text) RETURNS text AS '
BEGIN
RETURN $1 || $2;
END;
' LANGUAGE 'plpgsql';
----------------------------------------------------------

but I received this as the error:
----------------------------------------------------------
ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recognized languages are sql, C, internal and the
created
procedural languages.
----------------------------------------------------------

I'm running PostgreSQL 7.0.2 on FreeBSD-4.1. I'm new to postgres
(just
migrating from mysql).

What I'm wondering:
1. Am I missing something basic and fundamental here??
2. Am I looking at the right doco.. I recall on the list a
few
weeks
back there was a coment about the wrong doco being used...

Any help is appreciated..

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Dale Walker (#1)
Re: creating functions

but I received this as the error:
----------------------------------------------------------
ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recognized languages are sql, C, internal and the
created
procedural languages.
----------------------------------------------------------

By default the procedural languages are not loaded. There's a
script createlang which you can use to load the plpgsql language
into your database. (If you want it in all future databases,
I believe if you add it to template1, all later dbs have it
enabled)

#3Dale Walker
dale@icr.com.au
In reply to: Stephan Szabo (#2)
Re: creating functions

Stephan Szabo wrote:

but I received this as the error:
----------------------------------------------------------
ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recognized languages are sql, C, internal and the
created
procedural languages.
----------------------------------------------------------

By default the procedural languages are not loaded. There's a
script createlang which you can use to load the plpgsql language
into your database. (If you want it in all future databases,
I believe if you add it to template1, all later dbs have it
enabled)

got it.....

and guess what the sample function worked!

Thanks for that..

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au