?
Solved

pervasive sql transaction

Posted on 2011-03-15
3
Medium Priority
?
1,179 Views
Last Modified: 2013-12-25
Hello everyone,

I am somewhat new to pervasive sql and I was wondering if I can run a series of sql statements as a transaction.   IE I am trying to duplicate a few records in a database with new keys and then delete the old record but only if all the inserts worked properly

insert into xtable (columna, columnb) select '12345', columnb from xtable where columna = '23456'

insert into ytable (columnd, columne, columnf) select '444444', columne, columnf from ytable where columnd = '33333'

delete from xtable where columna = '23456'
delete from ytable where columnd = '33333'

if any of those fail I want to rollback the transaction.

Any thoughts on how I would do this?

thanks in advance..
0
Comment
Question by:mitai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:Bill Bach
ID: 35140014
Yes.  Issue BEGIN TRANSACTION at the beginning, and then END TRANSACTION at the end to commit it.  I believe ABORT TRANSACTION is used to abort and undo the changes.
0
 

Author Comment

by:mitai
ID: 35141143
OK, I will try that.  How do you test to see if an error occured on each of the sql statements?
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 2000 total points
ID: 35143362
A SELECT @@ROWCOUNT might work for you.  You can read this into a variable, and if ROWCOUNT > 0, then the operation was successful.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question