From: | Leif Jensen <leif(at)crysberg(dot)dk> |
---|---|
To: | Charles Clavadetscher <clavadetscher(at)swisspug(dot)org> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Delete trigger |
Date: | 2015-09-18 08:49:32 |
Message-ID: | 1588593519.5266893.1442566172786.JavaMail.zimbra@crysberg.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Charles,
If I do "DELETE FROM devicegroup WHERE group=1" I do not want to delete anything. I only want to delete if I do "DELETE FROM devicegroup WHERE groupid=x AND ctrlid=y AND userid=z". I don't wanna let anyone delete more than 1 row at a time.
Leif
----- Original Message -----
> Hello
>
> Not sure I get it right, but all three fields are not nullable. So they will
> always have a value, which is what I understand of "are specified".
> What do you need the trigger for in that case?
>
> Bye
> Charles
>
> > -----Original Message-----
> > From: pgsql-general-owner(at)postgresql(dot)org
> > [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Leif Jensen
> > Sent: Freitag, 18. September 2015 10:23
> > To: pgsql-general <pgsql-general(at)postgresql(dot)org>
> > Subject: [GENERAL] Delete trigger
> >
> > Hi,
> >
> > I am running PostgreSQL 9.3.4. I have a simple table with 3 fields:
> >
> > CREATE TABLE devicegroup (
> > groupid integer NOT NULL,
> > ctrlid integer NOT NULL,
> > userid integer NOT NULL
> > );
> > ALTER TABLE ONLY devicegroup
> > ADD CONSTRAINT pk_devicegroup PRIMARY KEY (groupid, ctrlid, userid);
> >
> > I want to make sure that records are only deleted when all 3 fields are
> > specified, so I tried make a trigger:
> >
> > CREATE TRIGGER userDev_trig INSTEAD OF DELETE ON admdevgrid FOR EACH
> > STATEMENT
> > EXECUTE PROCEDURE deleteUserDev();
> >
> > which could check for NOT NULL on the 3 fields before actual doing the
> > delete. Unfortunately this is not possible to
> > do FOR EACH STATEMENT, and FOR EACH ROW would not give me the chance to
> > check for NOT NULL.
> >
> > Any ideas ?
> >
> > Leif
> >
> >
> > --
> > Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2015-09-18 09:21:23 | Re: Delete trigger |
Previous Message | Charles Clavadetscher | 2015-09-18 08:44:59 | Re: Delete trigger |