Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I change IMPLICIT TRANSACTIONS ON

Posted on 1998-06-25
7
Medium Priority
?
1,049 Views
Last Modified: 2008-02-01
The new question is: Can I get from my Visual C++ code the same behaviour than turning off the
"Generate Stored Procedure for Prepared Statement" in the Control Panel's ODBC
configuration?

I'd also like to know what exactly IMPLICIT TRANSACTIONS OFF means (I think that it was
IMPLICIT TRANSACTIONS ON before the ODBC driver that comes with SQL Server 6.5). How
can I change IMPLICIT TRANSACTIONS to ON from my C++ code? Will that mean that SQL
Server will release that temporary stored procedures from tempdb after every insert/update
(supposing I turn on the "Generate Stored Procedure for Prepared Statement" in the ODBC
configuration)?
0
Comment
Question by:davidjava
[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
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:connex
ID: 1091619
a)
  Just change the Registry Key:
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\<DSN-Name>\UseProcForPrepare to "No"

b)
  Issue the SQL-Command
   "SET IMPLICIT_TRANSACTIONS ON" via SQLExecDirect Call.
 
  This means that the SQL-Server will automatically use transactions for the Commands
    fetch,delete,insert,create,alter table,open,grant,revoke
    drop,truncate table,select,update
  (see Transact SQL-Help about the SET-Statement)

0
 

Author Comment

by:davidjava
ID: 1091620
Thank you again CONNEX. Your answer is quite good but I still do not know which is the relation between the IMPLICIT TRANSACTIONS ON or OFF and the "Generate Stored Procedure for Prepared Statement".

I tried to run the program with the "Generate Stored Procedure" checkbox enabled in the Control Panel and the IMPLICIT TRANSACTIONS ON (activated using CDatabase::ExecuteSQL("SET IMPLICIT_TRANSACTIONS ON") after the CDatabase::Open() call), and the program hung in the next CRecordset::Open() call. I do not know why... On the other hand, it runs ok when I disable the checkbox in the Control Panel.

0
 
LVL 2

Expert Comment

by:connex
ID: 1091621
Hmm works fine with ,my application ...
What exactly are you doing inbetween the calls?
Do you commit your transactions? or are you using autocommit?

0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
LVL 2

Expert Comment

by:connex
ID: 1091622
Oops forgot that part .)
There is quite a large article about that in the Technical articles about ODBC. Maybe you have a look at the MS Support pages just search for "implicit and transaction and odbc and stored and procedure"
It's too huge to post it here


0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1091623
Generate stored procedures for prepared statement has nothing to do with implicit transactions setting.
Generate... option is used by JET to optimize repeated parameter queries. It is quicker to call prepared stored procedure with a parameter, then do "Select .. where parameter_criteria"

Implicit transactions on means, that each statement issued agains  t SQL server database is automatically commited.
Implicit transaction off means, that you have to begin and commit transaction explicitly.


0
 

Author Comment

by:davidjava
ID: 1091624
Thank you CONNEX. The article you suggested was all what I needed. In fact, the two articles,
http://support.microsoft.com/support/kb/articles/Q135/5/32.asp and
http://support.microsoft.com/support/kb/articles/q151/5/36.asp
were very interesting. They explain the new configuration options for SQL Server 6.5 which are not included in the SQL Server documentation nor in the Visual C++ 5.0 help.

The only you need is to copy the odbcss.h file from the SQL Server 6.5 Service Pack 3 and then you are able to use the following instructions,
SQLSetConnectOption(hdbc, SQL_USE_PROCEDURE_FOR_PREPARE,
SQL_UP_ON_DROP)
SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_ON)

It seems to work fine. The first instruction makes SQL Server to delete the temporary stored procedures it creates on each Prepare... wow! I am currently trying SQL_AUTOCOMMIT_OFF in order to compare the efficiency.

I also want to thank you SPIRIDONOV for your help, though I think that the points of this question must go to CONNEX as he gave me the clue. Hope you understand.

0
 
LVL 2

Accepted Solution

by:
connex earned 1200 total points
ID: 1091625
Thanks .)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

722 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