Convert field with SQL type as BIT to Integer

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
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Convert field with SQL type as BIT to Integer

Post by Krazykoolrohit »

Hi,

Can anyone help me out in converting a column which has a SQL type as BIT to Integer in a transformer.

thanx,
Rohit
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

I tries Int(FieldName) but it didnt work
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try not doing anything at all to it.

What is the SQL data type in the imported table definition?

Remember that, within DataStage server jobs, there are no data types, so the cast may be performed implicitly and correctly for you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

doing nothing does not help. It is resulting in job abort with the message that unable to convert to integer sine the target is not nullable it drops the record
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Are you sure this is a server job? :?

In server jobs (by default) NULL is 10000000 (which is possibly how a "bit" is stored) so it may be possible to use

Code: Select all

IsNull(InLink.Field)
as your derivation.
Last edited by ray.wurlod on Wed Jun 14, 2006 4:14 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

yes. I have run the job again and then will give you the exact error message
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

it says,

SQL3120W The field value in row "F0-1" and column "36" cannot be converted to an INTEGER value, but the target column is not nullable. The row was not loaded.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What's the source database?

Try changing the derivation of that column to

Code: Select all

CAST(FieldName AS INTEGER)
and changing its data type within DataStage also to INTEGER. If it's truly a bit type this is a legal cast.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

will do that. The source is Progress.
thanx for the info. will try and let you know
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Using the cast function is throwing me an error:

SQLSTATE=37000, DBMS.CODE=-20003
[DataStage][SQL Client][ODBC][DataDirect][ODBC PROGRESS driver][PROGRESS]Syntax error (7587

I used CAST(fieldname as integer) and changed sql type to integer in the odbc stage
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What is your source and target database? thats what Ray had asked too.
And also provide the original source and target datatypes.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

My source is progress and target is DB2
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Its working now. thanx a lot. There was a schema mismatch between the DB2 bulk load stage and the actual production table.

Ray's advice helped. thanx again
Post Reply