Re: CREATE FUNCTION - Mailing list pgsql-general

From gnari
Subject Re: CREATE FUNCTION
Date
Msg-id 001801c47d9a$d02aadb0$0100000a@wp2000
Whole thread Raw
In response to CREATE FUNCTION  (Jiri Nemec <konference@menea.cz>)
List pgsql-general
[ CC'd to "Jiri Nemec" <konference@menea.cz>]

"Jiri Nemec" <konference@menea.cz> said:


> Hello all, sorry about beginner question, but I'm sure function has
> correct structure, buw PostgreSQL reports error. (This function is
> only on approbation.)
>
> CREATE FUNCTION foo(int2)
> RETURNS TEXT
> AS 'DECLARE ret TEXT;
>    begin
>       SELECT INTO ret CAST(name AS text)
>       FROM shop_goods
>       WHERE id = $1;
>       return ret;
>    end;'
> language 'sql';

should this not be language 'plpgsql' ?

or

CREATE FUNCTION foo(int2)
RETURNS TEXT AS '
  SELECT CAST(name AS text)
       FROM shop_goods
       WHERE id = $1;
' language 'sql';


mind you, i could be wrong.

gnari




pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: CREATE FUNCTION
Next
From: Randy Yates
Date:
Subject: Re: Postgres and Tools Intro?