Nullable to Non-Nullable

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
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Nullable to Non-Nullable

Post by Teej »

Hello folks --

I would like to pick all of your brains for a bit on this topic. It is generally known that if you have a Nullable column, and you need to convert it to Non-Nullable, you need to address what to do for those records with NULL values.

The one method I am aware of is using the Transform stage, and the following routine:

Code: Select all

If IsNull([link].[field]) Then [default value] Else [link].[field]
Is there any other methods you use to handle this? I know there is a Modify stage for 7.x, but what are the other options?

-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Write an NVL type function or transform. It's reusable and most people know how it works:

Code: Select all

NVL(value, replacement value)
Fewer letters to type, reusable, nest-able, etc.
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
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Post by Teej »

That would work for Server, but using the PX Transform stage? I am probably missing something big here if I am able to create a function that can be used by that stage.

-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
Eric
Participant
Posts: 254
Joined: Mon Sep 29, 2003 4:35 am

Post by Eric »

The Sequental File Stage (Import/Export Operator) allows NULL values to be replaced with a VALUE. (using the Column Property -> Nullable -> Null Field Value).
vzoubov
Participant
Posts: 28
Joined: Tue Feb 05, 2002 12:30 pm
Location: Boston, MA

Re: Nullable to Non-Nullable

Post by vzoubov »

Teej wrote:Hello folks --

The one method I am aware of is using the Transform stage, and the following routine:

Code: Select all

If IsNull([link].[field]) Then [default value] Else [link].[field]
Is there any other methods you use to handle this? I know there is a Modify stage for 7.x, but what are the other options?
You can also check for a null value in a buildop:

Code: Select all

if(in.field_null())
{
      out.field = <default value>;
}
else
{
      out.field = in.field;
}

Vitali.
ariear
Participant
Posts: 237
Joined: Thu Dec 26, 2002 2:19 pm

Post by ariear »

The Sequental File Stage (Import/Export Operator) allows NULL values to be replaced with a VALUE. (using the Column Property -> Nullable -> Null Field Value).
Somehow it doesn't work for me. I'm trying to process a delimited sequential file but I keep getting errors from the import phase that says something like -the null-value field must be the same size as the field (a specific one)- ! :?: :?: :?:

Then I went to the column definitions and went column by column and changed the default nullable property ! My god I have 390 columns :(
Isn't there any other way :evil:

ArieAR
mmanes
Participant
Posts: 91
Joined: Tue Mar 16, 2004 10:20 am
Location: Rome

Re: Nullable to Non-Nullable

Post by mmanes »

Teej wrote:Hello folks --

I would like to pick all of your brains for a bit on this topic. It is generally known that if you have a Nullable column, and you need to convert it to Non-Nullable, you need to address what to do for those records with NULL values.

The one method I am aware of is using the Transform stage, and the following routine:

Code: Select all

If IsNull([link].[field]) Then [default value] Else [link].[field]
Is there any other methods you use to handle this? I know there is a Modify stage for 7.x, but what are the other options?

-T.J.
OK TJ it's my solution too... Ascential told that is the solution
PX 6.0

I apologize for my english

Bye
Post Reply