Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Invalid precision value


Invalid precision value

Author
Message
rajeshk.kokkonda
rajeshk.kokkonda
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 5
Hi,

I am new to MS SQL and the project need arose to bind an OUTPUT blob. Towards that I created a stored procedure which returns a nvarchar(max) type. I do not know what will be the length of this blob as this is constructed by the stored procedure.

The SQL Server that I am running this on is 2005.

I am binding in my C++ application using SQLBindParameter. This is how I am doing it.

retcode = SQLBindParameter(hStmtHandle,
output_blobs_[i].cur_pos,
SQL_PARAM_OUTPUT,
SQL_WCHAR,
SQL_WLONGVARCHAR,
0,
0,
(SQLPOINTER)output_blobs_[i].cur_blob,
0,
(SQLINTEGER*)&size
);


This is how my stored procedure looks like

create proc ujo_delete_box
@del_dep_list nvarchar(max) OUT,
@job_name varchar(64),
@joid int,
@rstr_del_job int,
@rstr_del_depjob int,
@ref_integrity int,
@stamp int,
@del_box int,
@user varchar(80)

No matter what I do I don’t seem to get past the bind stage. With the way SQLBindParamter is depicted, I always end up with the below error when I try to bind the nvarchar(max) field.

Error from SQLBindParameter() Failed for stored procedure.
SQLSTATE: HY104, Native error: 0, Message: [Microsoft][ODBC SQL Server Driver]Invalid precision value

Please let me know what am I doing wrong.

Regards,
Rajesh
John_P
John_P
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 63
Check out http://msdn.microsoft.com/en-us/library/windows/desktop/ms710963(v=vs.85).aspx

In your code:
retcode = SQLBindParameter(hStmtHandle,
output_blobs_[i].cur_pos,
SQL_PARAM_OUTPUT,
SQL_WCHAR,
SQL_WLONGVARCHAR,
0,
0,
(SQLPOINTER)output_blobs_[i].cur_blob,
0,
(SQLINTEGER*)&size
);

I think the 2nd parameter should be 2 and not output_blobs_[i].cur_pos, because you are defining the 2nd parameter to the stored procedure. I'm gussing (hoping) that output_blobs_[i].cur_pos is pointing to some data area that you have allocated on the heap.
The 2nd to last parameter shouldn't be 0, it should contain the size of the data area that you have allocated.

I hope this helps!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search