Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC and Stored Procedure returning unwanted resultsets

Status
Not open for further replies.

stevensteven

Programmer
Jan 5, 2004
108
CA
Hello,

I am having a problem with the performance with when calling stored procedures. I have to do a large number of inserts/updates to a table, so speed is a big factor. Here is one of my simplified stored procedures I am using for testing:

ALTER PROCEDURE dbo.I7PROCaddAnalog(@p_Analog_Id CHAR(20),
@p_Analog_Value REAL,
@p_Analog_Subs INTEGER) as

begin
SET NOCOUNT ON

UPDATE IRISAnalog SET
Analog_Value = @p_Analog_Value,
Analog_Subs = @p_Analog_Subs
WHERE Analog_Id = @p_Analog_Id

end


I am using the C code to call it:

rc = SQLAllocStmt(hdbc, hstmt);
rc = SQLPrepare(*hstmt, "{call AddAnalog(?,?,?)}", SQL_NTS);
rc = SQLNumParams (*hstmt, &numParams);
[BINDPARAMETERS CALL]

while(I am looping)
{
rc = SQLExecute(*hstmt);
rc = SQLFreeStmt(*hstmt, SQL_CLOSE); OR rc = SQLMoreResults(*hstmt);
}

It seems like I have to close the cursor before I execute another call. Is it fair to say that this is returning a resultset? This seems to be very slow.

I have also tried to use the following:
rc = SQLAllocStmt(hdbc, hstmt);
rc = SQLPrepare(*hstmt, "UPDATE IRISAnalog SET Analog_Value = ?, Analog_Subs = ? WHERE Analog_Id = ?", SQL_NTS);
rc = SQLNumParams (*hstmt, &numParams);
[BINDPARAMETERS CALL]

while(I am looping)
{
rc = SQLExecute(*hstmt);
}

This example I do not have to close the cursor. And can quickly execute another call. I even have to close the resultset cursor if my stored procedure simply has one line which is return.

Is there any way for the stored procedure to not return a resultset (if it is returning one) or speed up the efficiency of the stored procedure call?

Thanks for your help,

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top