We help IT Professionals succeed at work.

DTS syntax questioin

yechan
yechan asked
on
Hi,

I am looking at some VBScript that nees to be convered looks like the following

If DTSSource("Col1") > 0 then
    'do something here.
end if

What I am wondering is whether the above syntax checks whether Col1 is null, or whether Col1 contains a number value greater than 0, or checks whether the length of the string is greater than 0.  Looking at the datetpe of Col1, it has been decalred as Char(8).  I wonder if the logic changes if the data type were to change to datetime for example.

thanks


Comment
Watch Question

Commented:
Hi,

  Are you looking to do that in DATAFLOW or CONTROLFLOW?

In dataflow, you can use either derived column transform or script component
In control flow, you can use script task

Author

Commented:
hi rav,

well...i don't know yet.  Once I know what exactly the syntax evaluates itself to, I can go from there but most likely will do this in some sort of a dataflow.

Commented:
Well,

   In the data flow, derived column transform, write the condition as

(ISNULL(col1) ? 'col1isnull' : (ISNUMERIC(col1) ? (((DT_I4)col1 > 0)  ? intvalue : (LEN(col1) > 0 ? char value : charfalsevalue) : intfalsevalue))

hope you understand
Jason YousefSr. BI  Developer

Commented:
Alright, is that's a DTS or SSIS questions? it makes a big difference here.

What @rajvja provided is a SSIS expression .

regarding your question, it's checking the value of the  col1 if it's greater than 0

checking is null:

If IsNull(DTSSource("Region").value  then

Jason YousefSr. BI  Developer

Commented:
checking for NULL
If IsNull(DTSSource("Col1").value  then
'do something here.
end if

Open in new window

CERTIFIED EXPERT
Top Expert 2012
Commented:
>>
If DTSSource("Col1") > 0 then
    'do something here.
end if
...
Looking at the datetpe of Col1, it has been decalred as Char(8).  <<
Then it will treat the comparison as a string comparison and in fact be doing this:
If DTSSource("Col1") > "0" then
    'do something here.
end if

So "ABC" > "0" is true.

Author

Commented:
Thank you very much acperkins.  

Explore More ContentExplore courses, solutions, and other research materials related to this topic.