溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

達(dá)夢數(shù)據(jù)庫(DM7)條件語句和循環(huán)語句的幾個簡單的例子

發(fā)布時間:2020-08-08 21:48:58 來源:ITPUB博客 閱讀:4006 作者:jlandzpa 欄目:數(shù)據(jù)庫

最近初步接觸了達(dá)夢數(shù)據(jù)庫(DM7), 

SQL的語法和oracle極為類似。

--if語句:if elsif else and if

Declare 

p_int int;

Begin

    p_int := 1;

    If p_int= 1 then

       Print ('AA');

    Elsif p_int= 2 then

       Print ('BB');

    Else 

        Print ('CC');

    End if;

Exception when others then

   Null;

End;

/

--循環(huán)寫法1: for循環(huán)

declare

Begin

   For i in 1 .. 10 loop

       Print(i);

   End loop;

End;

/

--循環(huán)寫法2: while loop循環(huán)

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;

/

--循環(huán)寫法3:loop and loop循環(huán)

declare

pn number;

begin

  pn :=0;

  loop

    pn := pn +1;

  exit when pn >10 ;

  end loop;

    dbms_output.put_line('pn:'||pn);

end;

/

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI