Get the App
SLTechnology News&Howtos  ›  Database  › 

Several simple examples of conditional statement and Loop statement in DM7

Shulou Source: shulou.com Published: 2022-06-01 06:37:48 09月28日 Update

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

/

Tags: Loops writings data databases statements syntax contacts examples conditions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB Shulou Tech Info Xiaomi Apple