Oracle Loop statements

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.