Select * fromgoods; AChar(Ten):='Samsung' --Fixed length stringBvarchar2(Ten):='Samsung';--variable StringC Binary_integer:='10001';--signed integer, which optimizes performance for integer calculationsD Number(5,2):='123.45';--valueELong --variable length stringF Date--DateG Boolean--BooleanH ROWID--Store Database line numberI Goods.gname%Type='Samsung';--defining attribute types that match tables with%type------------------------------------------------------If statementDeclareC Binary_integer:='10002';begin ifC>Ten Then UpdateGoodsSetGnote='\ (^o^)/~' whereGid=C; End if;End;------------------------------------------------------if: Else StatementDeclarea Number(4,2):='13.45'; D Number(5,2):='123.45';begin ifA>D ThenDbms_output.put_line ('AAA'); ElseDbms_output.put_line ('BBB'); End if;End;------------------------------------------------------if: Elsif. Else StatementDeclareavarchar2(Ten):='823'; bvarchar2(Ten):='12a3456'; C Number:='132456798';begin ifA<B andA>C ThenDbms_output.put_line ('AAA'); Elsif a>BorA>C ThenDbms_output.put_line ('BBB');--The string comparison is the first one to start with the subscriptElsif A<C ThenDbms_output.put_line ('CCC'); ElseDbms_output.put_line ('DDD'); End if;End;------------------------------------------------------Case StatementDeclareaChar(Ten):= Upper('&p_grade'); bvarchar2(Ten); beginB:= Casea when 'A' Then '123' when 'B' Then '456' when 'C' Then '789' Else 'NO' End; Dbms_output.put_line (b||'ABCD');End;------------------------------------------------------Loop LoopDeclarea Number(Ten):=0;beginLoop A:=A+1; Dbms_output.put_line ('the current value of a is'||a); Exit whenA=Ten; EndLoop;End;------------------------------------------------------for LoopDeclareaChar(Ten):=1; begin forXinch 1..TenLoop Dbms_output.put_line ('the current value of a is'||a); EndLoop;End;------------------------------------------------------for loop using the keyword reverse (reverse loop)Declareavarchar2(Ten):=Ten;begin forAinch Reverse 1..TenLoop Dbms_output.put_line ('the current value of a is'||a); EndLoop;End; ------------------------------------------------------While LoopDeclarea Number:=1;begin whileA<=TenLoop Dbms_output.put_line ('the current value of a is'||a); A:=A+1; EndLoop;End; ------------------------------------------------------Adding properties with a For loopCreate TableDemo (did Number(5), Dnamevarchar2(Ten));Select * fromDemo;Declarea Number:=1; bvarchar2(Ten):='Jack';begin forAinch 1..TenLoopInsert intoDemo (Did,dname)Values(A, b); EndLoop; forAinch 1..TenLoopInsert intoDemo (dname)Values(b); EndLoop;End;Delete fromDemo------------------------------------------------------Declarea Number:=1;beginLoop Dbms_output.put_line ('the current value of a is'||a); A:=A+1; ifA>Ten Then GotoLoyer; End if; EndLoop; <<Loyer>> NULL;--no need to process any dataDbms_output.put_line ('ABCD');End;------------------------------------------------------
Oracle Loop statements