tags:

views:

205

answers:

1

Hello,

I am trying to update a COBOL packed field via a SQL query in a C# application. Currently, the COBOL packed field is being stored in a character column (char(50)) in a MS SQL database.

COBOL Data Type = 4 Byte binary number (“PIC S9(9) COMP”):

I can use the following statement to extract the data. I am not sure on how to reverse this processes for data updates.

CAST(CAST(SUBSTRING({Column Name},{Start},4) AS VARBINARY(4)) AS BIGINT) AS {Alias_Name}

Any suggestions?

Thanks,

Brennan Mann

+1  A: 

Answer coming late. But anyway ... here goes: If it's indeed PIC S9(9) COMP and not COMP-3 then it's not a 'sinister' COBOL packed field but a simple 4 byte integer!

HaWe
Do you know how a COMP-3 is defined?
Brennan Mann
@Brennan Mann: COMP-3 = PACKED DECIMAL. Good overview can be found here: http://www.simotime.com/datapk01.htm
NealB