Re: Could someone tell me what is wrong withthis function

From: "PGMailList" <pgmail(at)pgexplorer(dot)com>
To: <tsmets(at)brutele(dot)be>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Could someone tell me what is wrong withthis function
Date: 2002-03-25 15:06:26
Message-ID: 000a01c1d40e$a3b7ffe0$05faa8c0@edios
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

1) as 'BEGIN
as '
BEGIN

Put BEGIN in next line

2) if new.countrycode !~''^[A-Za-z][A-Za-z]$''
wont check for only Uppercase Letters try
''^[A-Z]*''

3) You can also use a Rule on the field, but its nice to use a trigger if
you require a better error to be reported

http://www.pgexplorer.com
GUI postgresql Frontend

----- Original Message -----
From: <tsmets(at)brutele(dot)be>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Monday, March 25, 2002 4:36 PM
Subject: [GENERAL] Could someone tell me what is wrong withthis function

>
> This is almost a copy / paste from Bruce Momjian's book :
> <snip>
> create function trigger_iso_code_2_uppercase()
> returns opaque
> as 'BEGIN
> if new.countrycode !~''^[A-Za-z][A-Za-z]$''
> then raise exception ''ISO-code are excepted to be uppercase
> letters.'';
> ENd if;
> new.countrycode=upper(new.countrycode);
> new.countryname=initcap(new.countryname);
> end;'
> language 'internal';
> </snip>
>
> but I get the following :
>
> <snip>
> ERROR: ProcedureCreate: there is no builtin function named "BEGIN
> if new.countrycode !~'^[A-Za-z][A-Za-z]$'
> then raise exception 'ISO-code are excepted to be uppercase
> letters.';
> ENd if;
> new.countrycode=upper(new.countrycode);
> new.countryname=initcap(new.countryname);
> end;"
> </snip>
>
> Please note that I logging as postgres
>
> tx for your help,
>
> thomas,
>
>
>
>
>
>
> --
> Thomas SMETS
> rue J. Wytsmanstraat 62
> 1050 Bruxelles
> yahoo-id : smetsthomas
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2002-03-25 15:15:06 Re: Could someone tell me what is wrong withthis function
Previous Message tsmets 2002-03-25 14:36:27 Could someone tell me what is wrong withthis function