Is there any DB2 SQL Builtin Conversion from EBCDIC - ASCII

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pongal
Participant
Posts: 77
Joined: Thu Mar 04, 2004 4:46 am

Is there any DB2 SQL Builtin Conversion from EBCDIC - ASCII

Post by pongal »

Hi,
I am extracting the data from DB2 Database table with the following query
like...

SELECT CMMPU,CMMKU,CMLDA FROM FIN017
WHERE
ASCII(CMMPU) = 'HT';
here the field CMMPU data type is in Binary.

it is giving an error ASCII Function is undefined name.

could anyone give me exact conversion function for converting EBCDIC to ASCII in DB2

Thanks in advance...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Surely you can find this in DB2 manuals/help? Or ask your DBA?

I suspect there is no such function in DB2's SQL but I don't know for sure.

One thing you can do is to extract in EBCDIC and convert to ASCII within DataStage.

However, you also baffle me with a claim that the column is "in binary"; how can you legitimately compare it with the string value 'HT' in this case? What is the actual data type of the CMMPU column when you inspect the table definition (or import it into DataStage)?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

I used to do a 'tricky' conversion with Informix, reading an EBCDIC flat file into the DB as an external table, then writing it back out to a different ASCII flat file.
The key to success of course was the metadata, to correctly describe the two external files.
Given DB2's roots and parents, I'd be surprised if there wasn't some way to do this.

So take Ray's advice, and ask a DBA!

Carter
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Re: Is there any DB2 SQL Builtin Conversion from EBCDIC - AS

Post by bcarlson »

I agree with Ray, do it in DataStage - if it isn't a standard database function, let something else do the work. In this case, converting EBCDIC to ASCII is not a normal database function, but it is normal for DataStage. Use the tool (or tools) most appropriate for the work to be done.

Also, the ASCII function in DB2 simply returns the ASCII code of the FIRST character of the string you pass it.
Post Reply