Re: rules over multiple tables - Mailing list pgsql-novice

From Henshall, Stuart - WCP
Subject Re: rules over multiple tables
Date
Msg-id E2870D8CE1CCD311BAF50008C71EDE8E01F7483C@MAIL_EXCHANGE
Whole thread Raw
In response to rules over multiple tables  (Daniel Grob <dgrob@gmx.net>)
List pgsql-novice
Hi,
<snip>
>
> ERROR:  there is no built-in function named "
> declare
> "ID_ADDR" alias for $1;
> ...
> return 1;
> END;"
>
>
> See below the Syntax I used:
>
> create function
> delete_irgendwas_function (int4,varchar,...)
> returns boolean as '
> declare
> "ID_ADDR" alias for $1;
> "COMPANY" alias for $2;
> "SIGN" alias for $65;
I personally would try and avoid variables with quotes round them (not sure
if its even legal). Instead I'd do something like
f_id_addr alias for $1;

> begin
> delete from "ADDRESSES"
> where "ID_ADDR" = f_"ID_ADDR" AND "COMPANY" = f_"COMPANY"...;
Having variables named the same as fields can get confusing (for the parser
as well as people).
See above for how I personally would name

> delete from "CONTACTS"
> where "ID" = f_"ID" AND "C_CATEGORY" = f_"C_CATEGORY" AND
> .... "SIGN" =
> f_"SIGN";
> return 1;
> END;'
> LANGUAGE 'internal';
Should be LANGUAGE 'plpgsql';
Hope this helps,
- Stuart

pgsql-novice by date:

Previous
From: Daniel Grob
Date:
Subject: Re: rules over multiple tables
Next
From: "Brian Johnson"
Date:
Subject: Searching for all records but integer field is causing problems