Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I change IMPLICIT TRANSACTIONS ON

Posted on 1998-06-25
7
Medium Priority
?
1,060 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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
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:Victor 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

773 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