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,
GiovanniHello,
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
"Giovanni Azua" <bravegag@.hotmail.com> wrote in message
news:2u9qr5F27hn83U1@.uni-berlin.de...
> 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|||Giovanni Azua (bravegag@.hotmail.com) writes:
> 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));
> // ...
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
http://www.microsoft.com/sql/techin.../2000/books.asp
No comments:
Post a Comment