mhinze.com archive

this is an archive of the old blog, ended 6/16/08





    26
    Mar

    pl/sql: updating a table but not replacing it, with sequence/triggers

    ever forgotten the predicate of your update query?  you would have to update everything from backup.  back to the future!

    i affected (er, corrupted) all 1600+ rows of semi-important data recently.  and had to restore the rows (while keeping the rows added since last night).. thought about something cool like insert into where not exists or using minus, but we settled on the fastest way:

    alter trigger schema.id_pk_increment disable
    delete from schema.table where id in (select id from other_schema.table_restore)
    insert into schema.table select * from other_schema.table_restore
    alter trigger schema.id_pk_increment enable
    

    Leave a Reply

    You must be logged in to post a comment.

    © 2007 mhinze.com