Re: [GENERAL] Delete trigger

2015-09-18 Thread Leif Jensen
Hi Ioana and David. Thank you. Yes, I can see the problem. I will look into your suggestions. Leif - Original Message - > On Friday, September 18, 2015, Leif Jensen wrote: > > >Hello Laurenz, > > > >Thank you for you suggestion. I really want to aviod that someone > > '

Re: [GENERAL] Delete trigger

2015-09-18 Thread David G. Johnston
On Friday, September 18, 2015, Leif Jensen wrote: >Hello Laurenz, > >Thank you for you suggestion. I really want to aviod that someone > 'accidentally' deletes too much by typing (programming) a not full > qualified DELETE ... statement. In your case one would have to always use > the del

Re: [GENERAL] Delete trigger

2015-09-18 Thread Ioana Danes
It depends on the size of the table and the frequency of updates, deletes but cold consider an audit table with triggers for update, delete and truncate. At least you have a way to recover deleted records. Ioana On Fri, Sep 18, 2015 at 5:52 AM, Leif Jensen wrote: >Hello Laurenz, > >Tha

Re: [GENERAL] Delete trigger

2015-09-18 Thread Leif Jensen
Hello Laurenz, Thank you for you suggestion. I really want to aviod that someone 'accidentally' deletes too much by typing (programming) a not full qualified DELETE ... statement. In your case one would have to always use the delete function, but no restrictions on using the DELETE statem

Re: [GENERAL] Delete trigger

2015-09-18 Thread Albe Laurenz
Leif Jensen wrote: >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. I can't think of a way t

Re: [GENERAL] Delete trigger

2015-09-18 Thread Leif Jensen
gt; > > -Original Message- > > From: pgsql-general-ow...@postgresql.org > > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Leif Jensen > > Sent: Freitag, 18. September 2015 10:23 > > To: pgsql-general > > Subject: [GENERAL] Delete trigger > > &g

Re: [GENERAL] Delete trigger

2015-09-18 Thread Charles Clavadetscher
.@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Leif Jensen > Sent: Freitag, 18. September 2015 10:23 > To: pgsql-general > Subject: [GENERAL] Delete trigger > >Hi, > >I am running PostgreSQL 9.3.4. I have a simple table with 3 fields: > > CR

[GENERAL] Delete trigger

2015-09-18 Thread Leif Jensen
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);

Re: [GENERAL] Delete trigger and data integrity

2014-05-27 Thread Alban Hertroys
On 27 May 2014 12:25, Yvonne Zannoun wrote: > CREATE OR REPLACE FUNCTION delete_records() > RETURNS TRIGGER AS $$ > BEGIN > delete from "TABLE"; > RETURN NEW; > END; > $$ > LANGUAGE plpgsql; You can't return NEW in an ON DELETE trigger - there is no NEW record. Since you're going with a STATE

Re: [GENERAL] Delete trigger and data integrity

2014-05-27 Thread Yvonne Zannoun
Thank you very much, that answers my question. And yes, I think you are right with the FOR EACH ROW/STATEMENT, I didn't think that through for this example. Thank you for your help! Kind regards, *Yvonne Zannoun* Graduate Technical Consultant Snowflake Software *Tel: +44 (0) 23 80238 232* Emai

Re: [GENERAL] Delete trigger and data integrity

2014-05-27 Thread Albe Laurenz
Yvonne Zannoun wrote: > I have this question regarding delete triggers and how it affects data > integrity. > So here goes: I have this trigger which deletes everything before I insert > new rows. > > CREATE OR REPLACE FUNCTION delete_records() > RETURNS TRIGGER AS $$ > BEGIN > delete from "

[GENERAL] Delete trigger and data integrity

2014-05-27 Thread Yvonne Zannoun
Hello everyone, I have this question regarding delete triggers and how it affects data integrity. So here goes: I have this trigger which deletes everything before I insert new rows. CREATE OR REPLACE FUNCTION delete_records() RETURNS TRIGGER AS $$ BEGIN delete from "TABLE"; RETU

Re: [GENERAL] Delete Trigger

2010-08-14 Thread Tom Lane
Chris Berry writes: > When I update, insert or delete to one table, I need a trigger to delete and > possibly insert into another table. The trigger I have works for insert and > update, but returns an error when I do a delete. There's no "NEW" row in a delete trigger (... and the error message s

[GENERAL] Delete Trigger

2010-08-14 Thread Chris Berry
When I update, insert or delete to one table, I need a trigger to delete and possibly insert into another table. The trigger I have works for insert and update, but returns an error when I do a delete. The is no explicit link between the tables, so I can't do 'DELETE CASCADE' or anything like that

[GENERAL] delete trigger function in 'C'

2001-01-09 Thread Sandeep Joshi
How do I get the values of parameters in the query? e.g. where x = 'op'; i.e. How do I get ? field: x value : op any example, pointers will help. thanks, Sandeep Joshi