[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Executing SQL Querys in Code

Posted on 2014-02-11
2
Medium Priority
?
273 Views
Last Modified: 2014-02-13
;
Is there  a simpler approach to updating a SQL Table than all this?  All this cross linkage of Transactions, Querys and Databases?  Do all Querys need transactions?

  IBDatabase1.DatabaseName := 'c:\backupdbs\JPBD.IB';
  IBDatabase1.Params.Clear
  IBDatabase1.Params.Add('user_name=sysdba');
  IBDatabase1.Params.Add('password=masterkey');

  IBDatabase1.DefaultTransaction := IBTransaction1;
  IBTransaction1.DefaultDatabase := IBDatabase1;

  IBQuery1.Transaction := IBTransaction1;

  IBDatabase1.Open;
  IBQuery1.Database := IBDatabase1;
  IBQuery1.SQL.Clear;
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, ''Price'')');
  IBQuery1.Transaction.StartTransaction;
  IBQuery1.ExecSQL;
  IBQuery1.Transaction.Commit;
  IBDatabase1.Close;
0
Comment
Question by:CiaoBaby
[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 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 39851890
That again depends on the database system you are using. But most times you do not need transactions, which results in autocommiting all changes without chance to rollback changes.

Transactions are used to bundle several commands into a single "atomic" operation. They don't make much sense with a single command.
0
 
LVL 35

Accepted Solution

by:
ste5an earned 2000 total points
ID: 39852631
The IB prefix sounds like FireBird. And yes, here you need explicit transactions. Well, abstraction is your friend. Encapsulate theses actions in an appropriate class model.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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 …

656 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