Re: user-defined not working

From: Stephen Ingram <ingram(at)samsix(dot)com>
To: "Patrick Hatcher" <PHatcher(at)macys(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: user-defined not working
Date: 2002-02-06 06:01:58
Message-ID: 20020206060211.RMWC10716.femail1.sdc1.sfba.home.com@there
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tuesday 05 February 2002 04:32 pm, Patrick Hatcher wrote:
> Hello. I'm trying to create my first function. However, when I try to
> compile, I get an error message: Unrecognized language specified in a
> CREATE FUNCTION: 'plpgsql'
>
> Any help would be greatly appreciated:
>

Hi Patrick,

I think we all get caught out on this one :)

Have you run 'createlang' ?

Try:

createlang -U ${PGUSER} plpgsql ${PGDATABASE}
or
createlang plpgsql

or whatever enviroment variant makes sense for your setup

steve

> '---Start function--
> CREATE Function OwnedGoods
> ( varchar(6)
> , varchar(2)
> , int
> , int
> , int
> , int
> , int
> , int
> ) RETURNS integer
> as '
>
> DECLARE
> GMM_ID ALIAS FOR $1;
> Div_ID ALIAS FOR $2;
> Loc1 ALIAS FOR $3;
> Loc2 ALIAS FOR $4;
> Loc3 ALIAS FOR $5;
> Loc120 ALIAS FOR $6;
> Loc15 ALIAS FOR $7;
> Cheshire ALIAS FOR $8;
> Total Int
>
> Begin
>
> IF GMM_ID = ''0001'' THEN
> IF Div_id = ''15'' or Div_id = ''16'' or Div_id = ''17'' or
> Div_id = ''23'' THEN
> Total = sum(Loc120 + Loc3 )
> Else
> Total = sum(Cheshire)
> END IF;
> END IF;
> IF GMM_ID = ''0002'' THEN
> Total = sum(loc15 + Loc3)
> END IF;
> IF GMM_ID = ''0006'' or GMM_ID = ''0007'' THEN
> Total = sum(Loc1 + loc2 +Cheshire)
> END IF;
> IF GMM_ID = ''0008'' THEN
> IF Div_id = ''99'' THEN
> Total = sum(Loc120 + Loc3 )
> END IF;
> END IF;
> IF GMM_ID = ''0003'' or GMM_ID = ''0005'' or GMM_ID = ''0009'' or
> GMM_ID = ''999'' THEN
> Total = sum(Cheshire)
> END IF;
> IF GMM_ID is null or Div_id=''00'' THEN
> Total = sum(Cheshire)
> END IF;
>
> Return Total;
> END;
> ' LANGUAGE 'plpgsql';
>
> '----END FUNCTION
>
> Patrick Hatcher
> Macys.Com
> Legacy Integration Developer
> 415-932-0610 office
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Ingram 2002-02-06 06:09:53 Re: user-defined not working
Previous Message Josh Berkus 2002-02-06 06:01:12 Re: user-defined not working