2

I need to read a Microfocus CoBOL data file (on PC) containing COMP fields. FYI, a COMP stores an integer in binary format.

If I transfer the raw binary in SQL Server, I can convert it to a BigInt using CONVERT(bigint,compField,1).

That way, CONVERT(bigint,0x0000002B17,1) will become 11031.

I also need to deal with negative values. In T-SQL it looks like this:

CONVERT(bigint,0xFFFFFFD4E9,1) - CONVERT(bigint,0xFFFFFFFFFF,1)-0x0000000001

will give -11031.

Is there a way to do this directly in the data flow? I'm sure the info is out there somewhere, but I'm too dumb to find it.

I'm working with SSIS 2019 btw.

Thank you!

Simon.

Yahfoufi
  • 2,220
  • 1
  • 22
  • 41
  • 1
    Ahhh, [comp-3 aka packed decimal data](http://www.3480-3590-data-conversion.com/article-packed-fields.html) I wish you well. It's been a decade plus since I attempted to deal with this but the mainframe data I had to deal with had managed to overload the field so the various C# tutorials on converting it didn't work. Let me take another search, see what I can find – billinkc Apr 09 '21 at 15:07
  • And if you're the same gentleman I met at the PASS Summit 2011, Hi! *waves* – billinkc Apr 09 '21 at 15:08
  • 2
    https://stackoverflow.com/a/143001 <-- While VB.NET that might be something you can use in a Script Component acting in a Transformation (default) mode – billinkc Apr 09 '21 at 15:11
  • Hi @billinkc! I hope all is well on your side! And it's great to see you're still involved in the community! – Simon Blais Apr 12 '21 at 13:14
  • A colleague wrote a function in VB which converts the COMP and from there, I wrote another one for COMP-3. Fortunately, I don't have to deal with EBCDIC which makes the job easier. Thanks for your help! – Simon Blais Apr 12 '21 at 13:35

0 Answers0