Subject | Re: [ib-support] Re: Flagging a deletion rather than delete |
---|---|
Author | Martijn Tonies |
Post date | 2003-01-06T08:14:06Z |
Didier,
DELETE FROM table, create a procedure DELETE_table with parameters
with the primary key value. This way, you're keeping the delete logic
in the database... Next, create a BEFORE DELETE trigger that raises
an exception along the lines of "cannot delete, use stored procedure
proc_name"
So instead of doing a DELETE FROM, you need to call the procedure.
The trigger with the exception ensures no-one is actually deleting anything.
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase & Firebird
Firebird Workbench - the developer tool for Firebird
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."
> > I use an ACTIVE boolean field in the table, which indicates whether theHow about a procedure that does the "delete" for you - instead of
> > record should be considered deleted or not. We don't delete our deletes
> > (if you see what I mean), we just make them inactive.
> >
>
> Yes, I agree this is the way to go but I was hoping to be able to mark
> the record as deleted in a before delete trigger event and somehow
> prevent the actual deletion from happening. That would save me to have
> to explain to others (there are quite a few different apps written by
> different teams using different tools dealing with the same DB) that
> to delete a record, you in fact have to update that field, they'll see
> that as a sort of twisted logic, even though it's not.
>
> So any pointer in that direction would help me a lot.
DELETE FROM table, create a procedure DELETE_table with parameters
with the primary key value. This way, you're keeping the delete logic
in the database... Next, create a BEFORE DELETE trigger that raises
an exception along the lines of "cannot delete, use stored procedure
proc_name"
So instead of doing a DELETE FROM, you need to call the procedure.
The trigger with the exception ensures no-one is actually deleting anything.
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase & Firebird
Firebird Workbench - the developer tool for Firebird
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."