Checking for nulls

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
phyllis
Participant
Posts: 34
Joined: Wed Jan 14, 2004 4:07 pm

Checking for nulls

Post by phyllis »

I'm using an Oracle database 'view' as my source and the zipcode column is defined as varchar(35) in the view. Some zipcodes are 10 characters (xxxx-xxxx) but I only want the first 5 characters. Null zipcodes are not allowed (the target stage specifies the column as Null=N, as does the table I'm writing to) so I've been asked to change any null zipcode to '00000'

In DS, my source stage has the column defined as varchar(35) and in the target stage it's defined as varchar(10), then I have a derivation in the transform of

If ISNull (BillingAddressesIn.BILLING_ZIP_CODE) then BillingAddressesIn.BILLING_ZIP_CODE = '00000' else Left(BillingAddressesIn.BILLING_ZIP_CODE,5)

I'm running this using an ODBC stage - I imported the ODBC table definition and the column is specified as varchar (10) (someone else set this up before I came on board). I'm getting the following error:

Cannot insert the value NULL into column 'billingzip', column does not allow nulls. INSERT fails. billingzip = NULL

Is the problem that I have an incorrect derivation - my assumption is that I don't need to change the target column to allow null - or the column length in the target?
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Code: Select all

If ISNull (BillingAddressesIn.BILLING_ZIP_CODE) then BillingAddressesIn.BILLING_ZIP_CODE = '00000' else Left(BillingAddressesIn.BILLING_ZIP_CODE,5) 
Should be

Code: Select all

If ISNull (BillingAddressesIn.BILLING_ZIP_CODE) then '00000' else Left(BillingAddressesIn.BILLING_ZIP_CODE,5) 
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
phyllis
Participant
Posts: 34
Joined: Wed Jan 14, 2004 4:07 pm

Post by phyllis »

Thanks - I changed the derivation and am running the job now - don't see any errors being logged - THANKS AGAIN!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Expressions in DataStage are exactly that: expressions. Expressions generate values.

They are not assignment statements, and therefore should not contain assignment operators.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply