Amarnath Raghu


I have already posted in the ODBC community..
I am not sure if its a problem with the ODBC binding or a problem in Stored Procedure.
Hence here goes the same.
--------------------
I got the following error when I tried to run a stored procedure and retrieve an output value.
"Stack around the variable 'scriptFile' corrupt."
I tried printing the value onto the console and that is where i get this error..

The stored procedure accesses a few tables and creates and array in a CSV String and this has been marked as an OUTPUT parameter in the Stored Proc..

Some specifics about the stored proc and my ODBC setting:

CREATE PROCEDURE getBucketDetails
(
@installedVersion varchar(20),
@scriptFileCollection varchar(100) OUTPUT
)

...
...
SET @scriptFileCollection = ''

WHILE PATINDEX('%'+@seperator+'%',@scriptListIterator) <> 0
BEGIN
...
...
SET @scriptFileCollection = @scriptFileCollection + '|' + @scriptFileName
...
...
END

SET @scriptFileCollection = SUBSTRING(@scriptFileCollection,2,LEN(@scriptFileCollection))
PRINT ' Final String :' + @scriptFileCollection

This runs fine when I use Query Analyser.
And the SQLBindParameter line goes like this.

SQLCHAR scriptList[1000];
SQLINTEGER _scriptList = SQL_NTS;

rc = SQLBindParameter(hQuery, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR, 1000, 0,scriptList, 2000, &_scriptList);

And I know that for this particular input I am trying to run, the scriptFileCollection is never more than 20 characters.




Re: Stack around the variable 'scriptFiles' corrupt

Arnie Rowland


Could it be that you are attemping to receive a string [ varchar() ] output parameter into an array variable





Re: Stack around the variable 'scriptFiles' corrupt

Louis Davidson

This is way beyond me to help out on the finer bits, but I would suggest a couple of things to try.

First, I don't find it clear why you used PRINT instead of SELECT. I know this is a different message, and it might be something strange.

Second, just whittle your proc down to:


CREATE PROCEDURE getBucketDetails
(
@installedVersion varchar(20),
@scriptFileCollection varchar(100) OUTPUT
) AS
SET @scriptFileCollection = 'your expected return'

--SELECT or

PRINT ' Final String :' + @scriptFileCollection

Then you can pretty much eliminate SQL server from the equation.

After that, good luck with the error message: "Stack around the variable 'scriptFile' corrupt."

There is a lot of stuff about this error message out on google (http://www.google.com/search hl=en&q=%22Stack+around+the+variable%22+corrupt) but could you be using the wrong type I pretty much thing Arnie has it right on the head. Should you return it to a SQLString and then cast it to your array