Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Invalid precision value Expand / Collapse
Author
Message
Posted Wednesday, March 6, 2013 3:42 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, April 5, 2013 2:52 AM
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
Post #1427273
Posted Wednesday, March 6, 2013 7:16 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, September 8, 2014 7:58 AM
Points: 13, Visits: 52
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!
Post #1427375
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse