Several simple examples of conditional statement and Loop statement in DM7
Recently, I have initial contact with Dameng database (DM7).
The syntax of SQL is very similar to that of oracle.
-- if statement: if elsif else and if
Declare
P_int int
Begin
P_int: = 1
If pendant int1 then
Print ('AA')
Elsif pendant int2 then
Print ('BB')
Else
Print ('CC')
End if
Exception when others then
Null
End
/
-- Loop writing 1: for loop
Declare
Begin
For i in 1.. 10 loop
Print (I)
End loop
End
/
-- Loop 2: while loop Loop
Declare
Pn number
Begin
Pn: = 10
While pn > 0 loop
Pn: = pn-1
If pn = 5 then
Return
Else
Dbms_output.put_line ('pn:' | | pn)
End if
End loop
End
/
-- 3:loop and loop Loop
Declare
Pn number
Begin
Pn: = 0
Loop
Pn: = pn + 1
Exit when pn > 10
End loop
Dbms_output.put_line ('pn:' | | pn)
End
/