Invalid precision value

  • 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_.cur_pos,

    SQL_PARAM_OUTPUT,

    SQL_WCHAR,

    SQL_WLONGVARCHAR,

    0,

    0,

    (SQLPOINTER)output_blobs_.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

  • Check out http://msdn.microsoft.com/en-us/library/windows/desktop/ms710963(v=vs.85).aspx

    In your code:

    retcode = SQLBindParameter(hStmtHandle,

    output_blobs_.cur_pos,

    SQL_PARAM_OUTPUT,

    SQL_WCHAR,

    SQL_WLONGVARCHAR,

    0,

    0,

    (SQLPOINTER)output_blobs_.cur_blob,

    0,

    (SQLINTEGER*)&size

    );

    I think the 2nd parameter should be 2 and not output_blobs_.cur_pos, because you are defining the 2nd parameter to the stored procedure. I'm gussing (hoping) that output_blobs_.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!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply