0 votes
in Software Defined Networking by

Under what circumstances would you code a SELECT construct instead of IF statements?

1 Answer

0 votes
by

When you have a long series of mutually exclusive conditions and the comparison is numeric, using a SELECT group is slightly more efficient than using IF-THEN or IF-THEN-ELSE statements because CPU time is reduced.

The syntax for SELECT WHEN is as follows :

SELECT (condition);

WHEN (1) x=x;

WHEN (2) x=x*2;

OTHERWISE x=x-1;

END;

Example :

SELECT (str);

WHEN ('Sun') wage=wage*1.5;

WHEN ('Sat') wage=wage*1.3;

OTHERWISE DO;

wage=wage+1;

bonus=0;

END;

END;

...