Purpose of setting Nullable property as 'No'??

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

joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Purpose of setting Nullable property as 'No'??

Post by joesat »

I am quite confused as to what is the real purpose of setting the Nullable property as 'No'.

In a job, I had to read a field with a BigInt datatype from a sequential file. It was a key field, so I set the Nullable to 'No'. While testing it (reading the sequential file input), I gave a Null value for the field, and as expected PX rejected that record as it had a null value in a non-nullable field.

Now I am developing another similar job, except that the field has Date datatype. I set Nullable to 'No' like earlier and gave a null value as input for testing it. Now PX reads the record properly and does not reject the record!!! I tried with Varchar and again the record is not rejected.

The sequential file input is read properly even when there are null values in the input, and when the fields are specified as Nullable 'No' with datatype like Varchar and Data.

If it is going to allow null values in the input, what exactly is the purpose of setting the Nullable property?

Thanks in advance!
Joel Satire
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

:)
Joel Satire
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What has happened is that you are reading the null value in the Date field from a sequential file; but you have also set the default value for the date field, so upon reading the default value is what you are getting.
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

actually, I havent set the default value...
Joel Satire
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

And if you write the date to a dataset what values are written (null or something else)?
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

i haven't tried writing it to a dataset, but when I wrote it out to a sequential file, the null values are written to the output..
Joel Satire
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Actually, you should get errors when writing nulls to a sequential file without handlers; so this means that you probably don't have a real SQL NULL but a UNIX null (0x00)
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

Yes, the sequential file is actually read from unix environment... so what should I do to handle this kind of null?

THanks..
Joel Satire
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I use both default values (for constrained columns like dates, times & numerics) and a transform stage with derivations for strings.
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Go to the extended properties of the field you want to set as Not nullable, and set the Null Value to the value which you want to treat as a NULL.

For a varchar you would set the

Code: Select all

NullValue = ''
This property tells datastage to treat the value which you set as a NULL and then your job should work fine.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Go to the extended properties of the field you want to set as Not nullable, and set the Null Value to the value which you want to treat as a NULL.

For a varchar you would set the

Code: Select all

NullValue = ''
This property tells datastage to treat the value which you set as a NULL and then your job should work fine.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Minhajuddin - what you recommend means that an empty string is equated to SQL Null, which I believe is not the poster's intent. Also, strings containing 0x00 (the NUL value) would not correctly be converted to SQL NULL (0x280).
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

Sorry if I have been confusing, let me clarify...

I want PX to tell me when a null value is coming in the input field 'Field1'. But Field1 is a key column and hence cannot be nullable. In the event of a null coming in, the record should be rejected...

I thought this was the purpose of setting Nullable 'No'...

Andrw, I couldn't understand what exactly you meant when u said that you used default in both places,

Minjuddin, do you mean the Null Field Value property?
Joel Satire
joesat
Participant
Posts: 93
Joined: Wed Jun 20, 2007 2:12 am

Post by joesat »

sorry for getting the names wrong :oops:
Joel Satire
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ok, let us take things step by step. Normally this type of problem starts with mistaking an ASCII NUL and SQL NULL values for the same thing. Normally, a sequential file doesn't contain SQL NULLs. So as the first step let us see what kind of values we are dealing with. Use your favorite editor to look at your file and determine if you are seeing CHAR(000) {likely} or CHAR(128) {which is SQL Null, and unlikely}. Also, tell us if just one of these characters occurs or if the whole string or number is filled with repetitions of the character.
Post Reply