Results 1 to 2 of 2

Thread: Transaction Query

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Transaction Query

    Hi All,

    In my code I need to copy a file from one location to another and then perform a database operation.
    The problem is that I need to wrap this up in a tranaction and am not sure how best to cope with it.

    Should I wrap up the file copy operation in a try catch block ?
    Should I wrap it all up.

    I am just noth sure of the tidiest solution and was wondering how you guys managed this type of operation.

    Thanks In Advance

    Parksie

  2. #2
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325

    Re: Transaction Query

    You should always use Try/Catch blocks whenever something can go wrong (search for Murhpy's law ).

    I my opinion you have two solutions:

    1) begin the transaction (thus locking affected rows)
    2) copy your file (into a try/catch block)
    3) do your queries in the database (into another try/catch block)
    4) commit

    OR

    0) Try
    1) begin the transaction (thus locking affected rows)
    2) copy your file
    3) do your queries in the database
    4) commit
    5) Catch ...

    Rollback if something goes wrong...

    I think the first solution is more flexible...


    Best regards,
    Xmas.
    Learn, this is the Keyword...

Posting Permissions

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



Click Here to Expand Forum to Full Width