date routine

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
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

date routine

Post by kollurianu »

Hi all,


iam using following code in my routine

if (Not(IsNull(Trim(Arg1)))) Then

Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans = Oconv(Date(),'D4/MDY')

End

if my input is and empty string then iam not getting today's date.

Any help greatly appreciated.

Thank you all
rsaliah
Participant
Posts: 65
Joined: Thu Feb 27, 2003 8:59 am

Re: date routine

Post by rsaliah »

Try "if (Not(IsNull(Trim(Arg1)))) and Arg1 # '' Then ....".

Regu
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Thank you Regu,
Though i did not get the reason why you asking me to do like that

still i did in my code , but now iam getting compilation error.

Code: Select all

if (Not(IsNull(Trim(Arg1)))) and Arg1 #  Then

Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans  =  Oconv(Date(),'D4/MDY')

End

compilation error is

Compiling: Source = 'DSU_BP/DSU.OraDatetimestamp', Object = 'DSU_BP.O/DSU.OraDatetimestamp'

0002 if (Not(IsNull(Trim(Arg1)))) and Arg1 # Then

^
"THENEOL" unexpected, Was expecting: '=', "LT", "LE", "GT", "GE", "NE",
"EQ", "MATCH"

1 Errors detected, No Object Code Produced.


Can any one help me,
rsaliah
Participant
Posts: 65
Joined: Thu Feb 27, 2003 8:59 am

Post by rsaliah »

You missed out the '' (empty string).

So your code should be

Code: Select all

if (Not(IsNull(Trim(Arg1)))) and Arg1 # ''  Then 

Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]") 
End Else 
Ans  =  Oconv(Date(),'D4/MDY') 

End 
You need to remember that nulls are not always the same as empty strings.

Regu.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Trim() won't help the test. If it's null, it's null. You can simpllfy your logic. Reversing the logic will remove the need for Not(). And you can be less specific about the format for Iconv().

Code: Select all

If IsNull(Arg1) Then
   Ans  =  Oconv(Date(),'D4/MDY')
End Else
   Ans = Oconv((Iconv(Trim(Arg1),"DMDY")), "D4/MDY[2,2,4]") 
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ps. The '#' symbol means 'not equal'. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsaliah
Participant
Posts: 65
Joined: Thu Feb 27, 2003 8:59 am

Post by rsaliah »

If you use Ray's simplified code don't forget to also add a check for empty string, otherwise your problem will still persist.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Thank you Regu,

I agree to you that nulls are not same empty string , i need to insert

date in a timestamp field in a oracle table ,

if my input is an empty strin or spaces when trim it it is a null value.

so in place of empty string , i need to insert system date that is what iam
doing in the else part.

does oracle all to insert null values in a timestamp field thru ora oci
stage

Can you any help me,

Thank you all.
srinagesh
Participant
Posts: 125
Joined: Mon Jul 25, 2005 7:03 am

Post by srinagesh »

does oracle all to insert null values in a timestamp field thru ora oci
stage
You can insert NULL value into Oracle column of datatype DATE by using @NULL in the derivation part
rsaliah
Participant
Posts: 65
Joined: Thu Feb 27, 2003 8:59 am

Post by rsaliah »

if my input is an empty strin or spaces when trim it it is a null value.
This is not true. What you get is an empty string which you would test for as explained. A test using ISNULL on it's own will not work.

Have you tried the modified code from earlier?

Regu.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Hi all ,

Thanks for all your answers

i acheived in the following way,

Code: Select all

if Len(Trim(Arg1)) = '0'  Then

Ans = Oconv(Date() , "D4/MDY")

End Else
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")

End
That worked,

Thank you
Post Reply