#IF operator

[ Home / SQLBatch Home / Documentation / Basics ]


SYNTAX

{#if bool expression }
  SQL block 	
[{#elsif another bool expression }]
  SQL block 	
...
[{#else}]
  SQL block 	
{#endif}

DESCRIPTION

#If operator allows conditional execution of SQL commands. Multi line or single line syntax is allowed.

PARAMETERS

bool expression Any SB expression. If the expression evaluates to an empty string or zero or non-existent variable then it's considered to be a FALSE value otherwise it's a TRUE value.
SQL block Any SQL command or sequence of commands or part of a command. It may contain nested #If or other operators.

EXAMPLE 1

{
debug = 1;
output = 0;
}
....
begin
	update test set col = 1;
	{#if debug||output} 
		dbms_output.put_line('Processed: '||SQL%rowcount); 
	{#endif}
end;
/

EXAMPLE 2

{var = 3;}
select 
	{#if var==1} 1 
	{#elsif var==2} 2
	{#elsif var==3} 3
	{#else} 0
	{#end}
from dual;

The script above will be evaluated to:
select 
   3
from dual;
	
See Also
Language Basics
#WHILE operator
#FOR operator
Variables
Special Variables


Copyright (C) 1999 - 2024 Anatoly Moskovsky Report a site problem