Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Different between If ... then and When

Hi All,

Can anyone tell me what is the difference between the following scripts:

Suppose we have a variable called "A" and is set to = 1;

If A = 1 then

     load * inline{

     Col A, Col B,

     1,2,

     3,4

     ];

end if;

---------------------

When A := 1

  load * inline{

     Col A, Col B,

     1,2,

     3,4

     ];

Would second query be fired automatically if the value of variable "A" changed to something other than 1 and than change back to 1?

Thanks!

2 Replies
Gysbert_Wassenaar

An if statement can have an else branch, a when statement doesn't. With a When there's only one block of code that will or will not be executed. In an If-then-else you can have two alternative blocks of code. See the online help: When


talk is cheap, supply exceeds demand
its_anandrjs

In first code the table is run and loaded while in the second code it will not run as Gysbert suggest you have to use When with nested if statement. 

Regards

Anand