LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Running long query using DBImmediateSQL function and Command Timeout

Hi,

 

I am have a SQL procedure that could potentially take > 5 minutes to run.  And, as I am trying to call that procedure from CVI 2009, I am using 'DBImmediateSQL' and that gaves me timeout error.  

 

I did some search online and found that it might be the Command Timeout attribute that I need to adjust.  How do I set that timeout value?

 

And also, if there is a recommended way to code the execute long SQL procedure?

 

I am using LabWindows/CVI 2009 Version 9.1.0 with SQL Server 2008 SP2

 

Thanks.

 

Peggy

0 Kudos
Message 1 of 3
(3,165 Views)

An update to what I have posted.  I found out that I can use 'DBSetStatementAttribute' function to set the command timeout, which along with the cache size and other stuff.  However, one thing that I am wondering, after 'DBOpenSQLStatement', do I need to wait for the statement to finish executing or the statement is finished already?

 

The following is my revised code

------------------------------------

hstmt = DBNewSQLStatement (hdbc, "exec myProcedure");
resCode = DBSetStatementAttribute (hstmt, ATTR_DB_STMT_COMMAND_TIMEOUT,3600);
resCode = DBSetStatementAttribute (hstmt, ATTR_DB_STMT_CACHE_SIZE,1000);
resCode = DBSetStatementAttribute (hstmt, ATTR_DB_STMT_COMMAND_TYPE,DB_COMMAND_STORED_PROC);

resCode = DBOpenSQLStatement (hstmt);

....

------------------------------------

 

Thanks.

 

Peggy

 

0 Kudos
Message 2 of 3
(3,151 Views)

Another update to my original question.  I gave up on the 'DBOpenSQLStatement' function and use 'DBPrepareSQL' and 'DBExecutePreparedSQL' with 'DBSetStatementAttribute' function instead.  It seems working good now with no error returned.

 

 

0 Kudos
Message 3 of 3
(3,144 Views)