all groups > sql server (alternate) > october 2004 >
You're in the

sql server (alternate)

group:

Extended Stored Procedure problem (srv_describe function)...



Extended Stored Procedure problem (srv_describe function)... Giovanni Azua
10/27/2004 4:44:16 PM
sql server (alternate): Hello all,

I have spend quite some time now but don't manage to
find out how to have the srv_describe function working
properly for target NUMERIC(x,x) and NUMERIC types.

Already tried several alternatives like e.g.

// ...
PVOID pvdata1;
strcpy((char*)pvdata1, "12345.6789");
wsprintf(colname, "Score");
srv_describe(srvproc
, 1 /* column #1 */
, colname /* column name */
, SRV_NULLTERM /* column name ending */
, SRVNUMERIC
, (DBINT)sizeof(DBNUMERIC)
, SRVNUMERIC
, (DBINT)sizeof(DBNUMERIC)
, pvdata1);
srv_setcoldata(srvproc, 1, pvdata1);
srv_setcollen (srvproc, 1, strlen((char*)pvdata1));
// ...

but obviously does not work, I get an empty result
set.

I could only manage by converting the numeric value
to string from C and then sending only strings but the
SQL side expects actually a number(x,x) and is a customer
, in which case, I would never propose to be casting the
thing from TSQL.

Any ideas how to do it? The documentation and examples is
quite limited in this area.

Thanks in advance,
Best Regards,
Giovanni

Re: Extended Stored Procedure problem (srv_describe function)... Giovanni Azua
10/27/2004 4:46:50 PM
Hello,

Sorry I made a mistake with the example, it is
actually:

// ...
PVOID pvdata1;
pvdata1 = new float[1];
((double*)pvdata1)[0] = 12345.6789f;
wsprintf(colname, "Score");
srv_describe(srvproc
, 1 /* column #1 */
, colname /* column name */
, SRV_NULLTERM /* column name ending */
, SRVNUMERIC
, (DBINT)sizeof(DBNUMERIC)
, SRVNUMERIC
, (DBINT)sizeof(DBNUMERIC)
, pvdata1);
srv_setcoldata(srvproc, 1, pvdata1);
srv_setcollen (srvproc, 1, sizeof(float));
// ...

Thanks in advance,
Best Regards,
Giovanni

[quoted text, click to view]

Re: Extended Stored Procedure problem (srv_describe function)... Erland Sommarskog
10/28/2004 9:56:08 AM
Giovanni Azua (bravegag@hotmail.com) writes:
[quoted text, click to view]

I have not done very much XP programming, so I might be missing something
here. But I think you have the srctype and stclen parameters wrong.
pvdatal is not numeric, but a string. If memory serves, a DBNUMRIC is a
struct with three bytes for precision, scale and sign and then a
16-byte array for the value. So your float is not likely to be correctly
interpreted.

Then again, if you don't get an empty result set, there may be more
problems. It would be more likely that you would get completely bogus
output.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button