Skip to Content.
Sympa Menu

freetds - [freetds] dbrpcparam with SQLDECIMAL output parameter

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Marc Abramowitz <marca AT surveymonkey.com>
  • To: "freetds AT lists.ibiblio.org" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] dbrpcparam with SQLDECIMAL output parameter
  • Date: Fri, 26 Jul 2013 15:03:03 +0000

I have some code that calls dbrpcparam [1] with type = SQLDECIMAL and
DBRPCRETURN. It is attempting to get back a DECIMAL(6, 5) from a stored proc.

What I am seeing is that the data returned has a scale of 0 — i.e.: the value
I get back looks like this:

data[0] = 38
data[1] = 0

So it appears that I'm getting a DECIMAL(38, 0) and thus losing everything
after the decimal point.

I found an old message on the list about this [2], which suggested that one
should send a DBDECIMAL structure with the desired precision and scale (code
was added by Freddy for this at that time). I tried that and thus far have
still not gotten it to send back the expected value. I am wondering if I have
something wrong still — I am unclear on what I should be sending for maxlen
and datalen for instance. I've tried a number of combinations of 0, -1, and
sizeof(DBDECIMAL) and so far they all have returned the same DECIMAL(38, 0)
or I have gotten back an error about using an invalid length.

Currently, I have something like this:

DBDECIMAL db_decimal
db_decimal.precision = 18
db_decimal.scale = 5

dbrpcparam(dbproc, "@odecimal", DBRPCRETURN, SQLDECIMAL, sizeof(DBDECIMAL),
0, (BYTE *) &db_decimal) // SQLDECIMAL = 106; sizeof(DBDECIMAL) = 35

Am I doing this wrong? Anyone have a working example of returning a
SQLDECIMAL?

Thanks,
Marc

[1] http://freetds.schemamania.org/reference/a00285.html#ga8
[2] https://lists.ibiblio.org/sympa/arc/freetds/2009q3/025076.html




Archive powered by MHonArc 2.6.24.

Top of Page