Insert Null values into Oracle date column

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
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Insert Null values into Oracle date column

Post by vinaymanchinila »

Hi,

One of the jobs reads from SQL server and writes to Oracle table, the date column in the target oracle is Nullable and in the transformer I set it to SetNull() , it rejects all the rows ( there are no rows to view in the reject file though!) .

So how do we insert null vlaues into a oralce date column which is nullabe and also

What would be the solution if the oracle date column is not nullabe and the incomming source has null value?

Thanks,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What is the error/warning message you get in the log? Copy paste it here.

For your second question, you will go into the exentended properties and specify an null_value for the nullable column. Or you can do an explicit null check inside the transformer and set a default value.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

The error I get int he first case is SQL CODE 1403, I am investigating into it, I an loading a blank oralce table with Insert then Update.

In the second case when you mean default value what would it be, 9999-99-99 or can we insert null vlaue ' ' ?

thanks,
Thanks,
Vinay
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can insert a null value. Do an explicit check with IsNull() and then SetNull() if its a nullable column. If its not then your requirements will state what to specify if null is encountered, specify that as null_value in the extended properties. It can also be specified using NullToValue() in transformer.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

vinaymanchinila wrote:In the second case when you mean default value what would it be, 9999-99-99 or can we insert null vlaue ' ' ?
It would have to be a valid date with special meaning to your application. For example, I've seen things like:

01-01-1900
12-31-9999

As magic min/max values used. You can't use something like a space. Also note that a typical table designer will include a default value for the column like that when it is required. In order to leverage the default value in the column, you have to not send the column - sending null will generate an error.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Dont you get any ORA error code. As noted you cannot send Null to not nullable field.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

For testing purpose, Iam inserting CurrentDate() and all the rows are bieng rejected with 1403 SQL code, I am using Insert then Update, also did try Update then insert. Its wierd, that all the rows re being rejected without being inserted or updated.
Thanks,
Vinay
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is CurrentDate() and what does it's output look like? I'll wager it is not the proper format, gets 'converted' to null by Oracle and then fails the constraint.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Are you using CurrentDate() in an expression in the Transformer, or in the SQL itself? The latter does not work, because there's no such Oracle function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi,

The CurrentDate() is in column in the transformer and the format as seen in the peek (reject) is 2007-03-08, the date column table has been defined as date but when I import the metadata using Orchestrate or ODBC it comes in as timestamp, I did try to use CurrentTimestamp() in the transformer but its the same issue, it rejects all the records with 1403.

Thanks,
Thanks,
Vinay
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

FYI , if it helps, I have also set the APT_ORACLE_PRESERVE_BLANKS to true for this job.
Thanks,
Vinay
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

There was a trigger constraint that had to be dropped, so the sql code error was not help full!

Thanks for all your responses.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

It might be a user defined function used in your site.
You need to convert it back to oracle format while loading it. You need to use TO_DATE() function.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply