0

How to represent SQL Server type numeric(38,0) as IDL type (COM type library)?

Thanks a lot for the help!

P.S. For example, SQL Server type int is long type in IDL.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dmitry
  • 14,306
  • 23
  • 105
  • 189

1 Answers1

5

Numbers in COM could be:

  • Integers up to 64 bits (Int64) - so up to 19 significant digits;
  • Floating-point values up to 64 bit (double) - from 15 - 17 significant decimal digits precision.

So for 38 digits, none of those types would match your request. You can achieve the best resolution with Int64, but if your value is higher than 9,223,372,036,854,775,807, you will reach an overflow.

I think the easier compliant type is a good old BSTR (widestring), in which you can store as many digit as wished - but encoded as plain text. On the code side, you will need to have a BCD library to process your high-resolution numbers: no Delphi native type (even extended) has such a resolution.

Edit: Another option (thanks Ondrej for the proposal) is an array of bytes. IMHO a COM binary array is less easy than a text content (and less efficient about speed, even if it uses less memory). Encoding option could be good old BCD. You may be able to find libraries on both sides of the COM object.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • Thanks for the answer. But the question was about IDL types (not Delphi types). – Dmitry Jul 26 '12 at 19:38
  • @Altaveron Why did you include the Delphi tag? I still don't see any reason why IDL can represent that type. What makes you think it can? – David Heffernan Jul 27 '12 at 06:08
  • IDL is a generic term. I spoke about COM types. "Integers up to 64 bits", "Floating-point values up to 64 bit", and BSTR are COM types. Since you put the "Delphi" tag in your question, I also named the Delphi types matching those COM types. There is a perfect match between those COM types and the Delphi types I named. – Arnaud Bouchez Jul 27 '12 at 11:27
  • Another option is variant array of bytes. – Ondrej Kelle Jul 27 '12 at 13:26