Thread: Re: Question about functions

Re: Question about functions

From
Dave Page
Date:
> -----Original Message-----
> From: Manley, Jim [mailto:JMANLEY@Trnsworld.com]
> Sent: 03 April 2002 17:01
> To: 'dpage@pgadmin.org'
> Subject: Question about functions
>
>
> Hi Dave,

Hi Jim,

Please use the pgadmin-support@postgresql.org list for future support
issues.

> I am having a problem developing advanced functions in
> pgAdmin. I want to do something like this:
>
> CREATE FUNCTION get_city (varchar) RETURNS varchar
> AS '
>
> DECLARE
>
>  vLastName  ALIAS FOR $1;
>  vCity VARCHAR;
>
> BEGIN
>  SELECT city INTO vCity
> FROM customer
> WHERE last_name = vLastName;
>
> END; '
>
> language 'sql';
            ^^^

Your code is plpgsql so the parser doesn't understand it when you specify it
as sql (kinda like writing C++ in Microsoft Visual Basic).

Specify plpgsql as the language and you should be OK (note, this isn't
installed by default with PostgreSQL, you may need to run the createlang
script on your server).

Regards, Dave.