How can I rollback a prepared statement ?
Using just “create” , “update” etc. SQL-queries I just execute them all within a transaction.
I mostly run multiple queries with just one transaction. If one fails, I can just rollback them all at once.
But it’s not quite clear to me how I would do that using prepared statements.
Exactly the same way. A prepared statement is just another way of issuing an “Update” etc.
Thanks for the quick response Tim. I also thought so, but since I cannot look into a PS using the debugger, and get an error doing PS.commit or PS.rollback I am misunderstanding something ?
I should do a commit or rollback on the database connection object itself, I guess ?
Tested that with Postgres but it seems to be commited automaticly at execution.
The error, if any, will show up in the DB object.
So I should code : DB.Rollback
?
Yes
And solved of course. Thanks guys.
Problem was I wanted to do it in a method on the level of the preparedsteatement, since I have multiple database connections to different kind of databases, and did not carry a reference to the database involved, which I should do of course.