Professional Web Applications Themes

I defined PK, how to restore original value for quality field - Microsoft SQL / MS SQL Server

In my TableA I have a KeyPK, Tagkey, datetime, quality and Rev fields. KeyPK is the primary key. What I want to do is whenever a user issues an update statement on quality field and if the existing value of quality field is 97 I want to restore the vale no matter what user tries to change it to otherwise change it to user's desired value. I am doing this in a trigger on this table by using If Update(Quality) statment and want to restore the quality field if 97 from deleted table back into table A, for all other ...

  1. #1

    Default I defined PK, how to restore original value for quality field

    In my TableA I have a KeyPK, Tagkey, datetime, quality and
    Rev fields. KeyPK is the primary key. What I want to do is
    whenever a user issues an update statement on quality
    field and if the existing value of quality field is 97 I
    want to restore the vale no matter what user tries to
    change it to otherwise change it to user's desired value.

    I am doing this in a trigger on this table by using If
    Update(Quality) statment and want to restore the quality
    field if 97 from deleted table back into table A, for all
    other records changed value remains in Table A.

    update table A
    set quality = Select deleted.Quality from deleted,
    inserted where deleted.[datetime] = inserted.[datetime]
    and deleted.Tagkey = inserted.Tagkey and ????????.....)

    Any help please ??
    Thanks
    Ricky
    ..


    Ricky Guest

  2. #2

    Default Re: I defined PK, how to restore original value for quality field

    You've already asked that same question today and got some answers.

    "Ricky" <ricky.arorametc.state.mn.us> a écrit dans le message de news: 899601c34563$ee8924f0$a401280aphx.gbl...
    > In my TableA I have a KeyPK, Tagkey, datetime, quality and
    > Rev fields. KeyPK is the primary key. What I want to do is
    > whenever a user issues an update statement on quality
    > field and if the existing value of quality field is 97 I
    > want to restore the vale no matter what user tries to
    > change it to otherwise change it to user's desired value.
    >
    > I am doing this in a trigger on this table by using If
    > Update(Quality) statment and want to restore the quality
    > field if 97 from deleted table back into table A, for all
    > other records changed value remains in Table A.
    >
    > update table A
    > set quality = Select deleted.Quality from deleted,
    > inserted where deleted.[datetime] = inserted.[datetime]
    > and deleted.Tagkey = inserted.Tagkey and ????????.....)
    >
    > Any help please ??
    > Thanks
    > Ricky
    > .
    >
    >
    Guest

  3. #3

    Default Re: I defined PK, how to restore original value for quality field

    You can do:

    CREATE TRIGGER trg ON tbl FOR UPDATE
    AS
    IF ROWCOUNT = 0 RETURN;
    IF UPDATE(quality)
    UPDATE tbl
    SET quality = 97
    WHERE EXISTS( SELECT *
    FROM inserted
    WHERE keycol = tbl.keycol
    AND quality <> 97 );

    --
    - Anith
    ( Please reply to newsgroups only )


    Anith Sen Guest

  4. #4

    Default Re: I defined PK, how to restore original value for quality field

    Sorry,

    "Ricky" <ricky.arorametc.state.mn.us> a écrit dans le message de news: 0f5d01c34567$a7077e20$a501280aphx.gbl...
    Not really, I didn't have primary key in the table. So I
    have one now acc. to Aaron. But nobody advised a solution
    to it.
    >-----Original Message-----
    >You've already asked that same question today and got
    some answers.
    >
    >"Ricky" <ricky.arorametc.state.mn.us> a écrit dans le
    message de news: 899601c34563$ee8924f0$a401280aphx.gbl...
    >> In my TableA I have a KeyPK, Tagkey, datetime, quality
    and
    >> Rev fields. KeyPK is the primary key. What I want to do
    is
    >> whenever a user issues an update statement on quality
    >> field and if the existing value of quality field is 97
    I
    >> want to restore the vale no matter what user tries to
    >> change it to otherwise change it to user's desired
    value.
    >>
    >> I am doing this in a trigger on this table by using If
    >> Update(Quality) statment and want to restore the
    quality
    >> field if 97 from deleted table back into table A, for
    all
    >> other records changed value remains in Table A.
    >>
    >> update table A
    >> set quality = Select deleted.Quality from deleted,
    >> inserted where deleted.[datetime] = inserted.[datetime]
    >> and deleted.Tagkey = inserted.Tagkey and ????????.....)
    >>
    >> Any help please ??
    >> Thanks
    >> Ricky
    >> .
    >>
    >>
    >
    >.
    >
    Guest

Similar Threads

  1. field attributes revert back to original
    By SKTodd in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: August 29th, 03:35 PM
  2. Defined text field in form -> subject field in e-mail
    By olaka in forum Dreamweaver AppDev
    Replies: 0
    Last Post: March 14th, 02:20 PM
  3. Physical restore that doesn't require a logical restore
    By Christian Eriksson in forum Informix
    Replies: 6
    Last Post: September 24th, 11:30 AM
  4. Replies: 2
    Last Post: July 14th, 08:40 AM
  5. How to restore the original value for a field
    By Ricky in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 8th, 02:15 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