Solved

How can I change IMPLICIT TRANSACTIONS ON

Posted on 1998-06-25
7
1,010 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 300 total points
ID: 1091625
Thanks .)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL query and VBA 5 46
sql, case when & top 1 14 30
First Max value 3 32
RAISERROR WITH NOWAIT 2 18
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

821 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