varchar to NUMBER conversion problem

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

varchar to NUMBER conversion problem

Post by muascdev »

We have a column PROD_KEY which is defined as NUMBER in the table, its allowed to have NULL in it. when we receive data in a file, its received as VarChar, when we try to insert into table, it gives the following error, PendingSeqFile,0: Field "PROD_KEY" has import error and no default value; data: <empty>, at offset: 48, what do i need to do here, whats the best way to handle this. thx we use oracle9i
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Use the Designer to actually define a default null value for that column. In the input stage, highlight the column and right-mouse-click to "edit row" and set the null attributes.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

EDITED: After realizing its a px job.
Try this

Code: Select all

IF LEN(TRIM(in.PROD_KEY)) < 1 then SetNull() else in.PROD_KEY
Last edited by DSguru2B on Tue Jan 23, 2007 1:28 pm, edited 2 times in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

Post by muascdev »

it worked with this if (isNull(col)) setnull() else StringToDecimal(col)
Post Reply