Обсуждение: creating functions

Поиск
Список
Период
Сортировка

creating functions

От
Dale Walker
Дата:

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

Re: creating functions

От
Stephan Szabo
Дата:
> 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)


Re: creating functions

От
Dale Walker
Дата:
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