pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trigger set to backup to other table NOT FUNCTIONING...
3+ messages / 2 participants
[nested] [flat]

* Trigger set to backup to other table NOT FUNCTIONING...
@ 2004-09-13 10:05 Joepie Platteau <Joepie.Platteau@kulak.ac.be>
  2004-09-14 05:00 ` Re: Trigger set to backup to other table NOT FUNCTIONING... Oliver Elphick <olly@lfix.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: Joepie Platteau @ 2004-09-13 10:05 UTC (permalink / raw)
  To: pgsql-admin

Hi,
I have a problem with my trigger... :

my tables :

CREATE TABLE public."T-Alumni" (
"Id_Persoon" int8 DEFAULT nextval('"T-Alumni_Id_Persoon_seq"'::text) NOT 
NULL,
"SteunendLid" bool,
"Betaald" bool,
"Stamnr" int4,
"Alumninr" int4,
"Acjaar" varchar(50),
"Studiejaar" varchar(50),
CONSTRAINT "T-Alumni_pkey" PRIMARY KEY ("Id_Persoon")
) WITH OIDS;

CREATE TABLE public."T-Alumni-backup" (
"Id_Persoon" int8 NOT NULL,
"SteunendLid" bool,
"Betaald" bool,
"Stamnr" int4,
"Alumninr" int4,
"Acjaar" varchar(50),
"Studiejaar" varchar(50)
) WITH OIDS;

i have a table (T-Alumni) and BEFORE a record changes or is being 
deleted, I want to copy this record to a UNDO_table (T-Alumni-backup).

I tried like this :

CREATE FUNCTION public.f100() RETURNS trigger AS '
BEGIN
INSERT INTO "T-Alumni-backup" VALUES (NEW.Id_Persoon, NEW.SteunendLid, 
NEW.Betaald, NEW.Stamnr, NEW.Alumninr, NEW.Acjaar, NEW.Studiejaar);
RETURN NEW;
END;
' LANGUAGE 'plpgsql' VOLATILE;

CREATE TRIGGER t100t BEFORE DELETE OR UPDATE ON public."T-Alumni" FOR 
EACH ROW EXECUTE PROCEDURE f100();

I get this error :
Record "new" has no field "id_persoon" (#7)

Also I want to have the name of the person who deleted or changed the 
record in my BackUp (undo) table...

Can someone tell me how to solve this problem?
Thanx!
Joepie.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Trigger set to backup to other table NOT FUNCTIONING...
  2004-09-13 10:05 Trigger set to backup to other table NOT FUNCTIONING... Joepie Platteau <Joepie.Platteau@kulak.ac.be>
@ 2004-09-14 05:00 ` Oliver Elphick <olly@lfix.co.uk>
  2004-09-14 07:43   ` Re: Trigger set to backup to other table NOT FUNCTIONING... Joepie Platteau <Joepie.Platteau@kulak.ac.be>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Elphick @ 2004-09-14 05:00 UTC (permalink / raw)
  To: Joepie Platteau <Joepie.Platteau@kulak.ac.be>; +Cc: pgsql-admin

On Mon, 2004-09-13 at 11:05, Joepie Platteau wrote:
> Hi,
> I have a problem with my trigger... :
> 
> my tables :
> 
> CREATE TABLE public."T-Alumni" (
> "Id_Persoon" int8 DEFAULT nextval('"T-Alumni_Id_Persoon_seq"'::text) NOT 
  ^^^^^^^^^^^^
> NULL,
...
> CREATE FUNCTION public.f100() RETURNS trigger AS '
> BEGIN
> INSERT INTO "T-Alumni-backup" VALUES (NEW.Id_Persoon, NEW.SteunendLid,
                                            ^^^^^^^^^^
...
> 
> I get this error :
> Record "new" has no field "id_persoon" (#7)

You created it with the column names double quoted so they are really
mixed case.  However, you are accessing it without the double quotes, so
that the name is folded to lower case.  Therefore the names don't match.

> Also I want to have the name of the person who deleted or changed the 
> record in my BackUp (undo) table...

CURRENT_USER will give you the user id; if that's what you mean.

-- 
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "But without faith it is impossible to please him; for 
      he that cometh to God must believe that he is, and 
      that he is a rewarder of them that diligently seek 
      him."        Hebrews 11:6 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Trigger set to backup to other table NOT FUNCTIONING...
  2004-09-13 10:05 Trigger set to backup to other table NOT FUNCTIONING... Joepie Platteau <Joepie.Platteau@kulak.ac.be>
  2004-09-14 05:00 ` Re: Trigger set to backup to other table NOT FUNCTIONING... Oliver Elphick <olly@lfix.co.uk>
@ 2004-09-14 07:43   ` Joepie Platteau <Joepie.Platteau@kulak.ac.be>
  0 siblings, 0 replies; 3+ messages in thread

From: Joepie Platteau @ 2004-09-14 07:43 UTC (permalink / raw)
  To: olly@lfix.co.uk; +Cc: pgsql-admin

Thank you very much!!!
Indeed this was the problem...

If I 'd once see you in a pub, I'd buy you a drink!!
Joepie.

Oliver Elphick wrote:

>On Mon, 2004-09-13 at 11:05, Joepie Platteau wrote:
>  
>
>>Hi,
>>I have a problem with my trigger... :
>>
>>my tables :
>>
>>CREATE TABLE public."T-Alumni" (
>>"Id_Persoon" int8 DEFAULT nextval('"T-Alumni_Id_Persoon_seq"'::text) NOT 
>>    
>>
>  ^^^^^^^^^^^^
>  
>
>>NULL,
>>    
>>
>...
>  
>
>>CREATE FUNCTION public.f100() RETURNS trigger AS '
>>BEGIN
>>INSERT INTO "T-Alumni-backup" VALUES (NEW.Id_Persoon, NEW.SteunendLid,
>>    
>>
>                                            ^^^^^^^^^^
>...
>  
>
>>I get this error :
>>Record "new" has no field "id_persoon" (#7)
>>    
>>
>
>You created it with the column names double quoted so they are really
>mixed case.  However, you are accessing it without the double quotes, so
>that the name is folded to lower case.  Therefore the names don't match.
>
>  
>
>>Also I want to have the name of the person who deleted or changed the 
>>record in my BackUp (undo) table...
>>    
>>
>
>CURRENT_USER will give you the user id; if that's what you mean.
>
>  
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-09-14 07:43 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-13 10:05 Trigger set to backup to other table NOT FUNCTIONING... Joepie Platteau <Joepie.Platteau@kulak.ac.be>
2004-09-14 05:00 ` Oliver Elphick <olly@lfix.co.uk>
2004-09-14 07:43   ` Joepie Platteau <Joepie.Platteau@kulak.ac.be>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox