Professional Web Applications Themes

UPDATE instead of DELETE - MySQL

Hi all, is it possible to avoid deleting of a row when a DELETE query is executed? I want to UPDATE row (setting for example a boolean field) insted of deleting it. I can do this in Oracle and Postgres (with INSTEAD OF rule). Is it possible to do this in MySQL? Thank you in advance....

  1. #1

    Default UPDATE instead of DELETE

    Hi all,
    is it possible to avoid deleting of a row when a DELETE query is
    executed? I want to UPDATE row (setting for example a boolean field)
    insted of deleting it.

    I can do this in Oracle and Postgres (with INSTEAD OF rule). Is it
    possible to do this in MySQL?

    Thank you in advance.

    mario.cartia@gmail.com Guest

  2. #2

    Default Re: UPDATE instead of DELETE

    [email]mario.cartia[/email] wrote:
    > Hi all,
    > is it possible to avoid deleting of a row when a DELETE query is
    > executed? I want to UPDATE row (setting for example a boolean field)
    > insted of deleting it.
    >
    > I can do this in Oracle and Postgres (with INSTEAD OF rule). Is it
    > possible to do this in MySQL?
    I don't think so. MySQL triggers can do other operations in addition to
    the named operation (for example, inserting to a log table when an
    operation is performed on a given table), and BEFORE INSERT/UPDATE
    triggers can modify values entered into a row, but there's no way to
    tell it to skip the operation.

    A typical usage of INSTEAD OF, in addition to the usage you're
    describing, is to allow non-updateable views to be made updateable, by
    providing custom logic in the trigger to update the base tables of the
    view. However, MySQL docs explicitly say that one cannot associate a
    trigger with a view or a temporary table.

    It sounds like you're doing someting akin to overloading the DELETE
    statement, to make it do something other than its assigned semantics.
    SQL is not an object-oriented language, and does not support overloading
    in this way. I think you need to use UPDATE when you mean UPDATE, as in
    this case.

    Regards,
    Bill K.
    Bill Karwin Guest

Similar Threads

  1. ASP/VBS Using Command to Insert/Update/Delete
    By Sanjay in forum Dreamweaver AppDev
    Replies: 2
    Last Post: April 19th, 10:34 PM
  2. How to know if UPDATE, INSERT or DELETE succeed
    By Serge Myrand in forum ASP Database
    Replies: 7
    Last Post: July 19th, 01:56 AM
  3. SQL Update, Insert and Delete
    By Lou in forum ASP Database
    Replies: 1
    Last Post: June 22nd, 07:33 PM
  4. OOP page: Where to put update, insert, delete
    By jn in forum PHP Development
    Replies: 5
    Last Post: October 21st, 02:17 AM
  5. Before update or delete trigger to insert ?
    By Cindy Gold in forum IBM DB2
    Replies: 2
    Last Post: August 12th, 01:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139