Thread

  1. Re: UPDATE keyword

    Ian Harding <ianh@co.pierce.wa.us> — 2001-05-29T14:03:36Z

    True, true... but the next time I need the code to fire I would need ot remember that I had set it to 1 and set it to something else...
    
    Ian A. Harding
    Programmer/Analyst II
    Tacoma-Pierce County Health Department
    (253) 798-3549
    mailto: ianh@tpchd.org
    
    >>> Rene Pijlman <rpijlman@spamcop.net> 05/26/01 01:56AM >>>
    ianh@healthdept.co.pierce.wa.us ("Ian Harding") schreef:
    >UPDATE mytable SET myfield = myfield WHERE...
    >to fire an update trigger, and executing only the code in that 
    >trigger surrounded by UPDATE(myfield).
    
    So you update a field by not changing its value, to execute a piece of
    code that has nothing to do with the field and the value :-)
    
    >Is there an easy way to duplicate this, or should I work around it?
    
    Isn't it easier (and more poratble) to add a dummy field to the table?
    Then you can do:
    
       UPDATE mytable
       SET dummy = 1 - dummy
       WHERE ...
    
    to execute the piece of code that responds to an update of 'dummy'.
    
    Regards,
    René Pijlman
    
    http://www.applinet.nl 
    
    ---------------------------(end of broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
        (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
    
    
    
  2. Re: UPDATE keyword

    Rene Pijlman <rpijlman@spamcop.net> — 2001-05-29T16:38:29Z

    ianh@co.pierce.wa.us ("Ian Harding") schreef:
    >True, true... but the next time I need the code to fire I would 
    >need ot remember that I had set it to 1 and set it to something else...
    
    False, false, I've thought of that :-)
    
    The statement says:
    
    	dummy = 1 - dummy
    
    a) Initially, dummy == 0. Then dummy becomes 1 - 0 which equals 1.
    
    b) So dummy == 1. Then dummy becomes 1 - 1 which equals 0.
    
    c) Goto a.
    
    Dummy changes value from 0->1 or 1->0 on every execution of the
    statement.
    
    If you don't believe it, you can also try dummy = -dummy, but then you
    have to remember to initialize it to a non-zero value :-)
    
    -- 
    Vriendelijke groet,
    René Pijlman <rpijlman@spamcop.net>
    
    Wat wil jij leren?
    http://www.leren.nl/