Process control methods in pl \ SQL

Source: Internet
Author: User

In pl \ SQL, the process control method block www.2cto.com Java code declare username varchar2 (20); begin select t. ename into username from emp t where rownum = 1; dbms_output.put_line (username); end; 2 use case when in oracle for Java code www.2cto.com declare age number (6, 2 ); ---- Here the six represents the total length, and 2 represents the length after the decimal point begin age: = & myage; case age when 10 then dbms_output.put_line ('you have 10 year '); when 20 then dbms_output.put_line ('you have 20 year'); when 30 then dbms_output.put_line ('you have 3o year'); else hour ('I donot know you age '); end case; end; 3 usage of loop in oracle declare q number: = 0; begin loop q: = q + 1; dbms_output.put_line ('q = '| q); exit when q = 10; end loop; end; 4. another exit method in loop: www.2cto.com Java code declare q number: = 0; begin loop q: = q + 1; dbms_output.put_line ('q = '| q ); if q = 10 then exit; end if; end loop; dbms_output.put_line ('Hello I barek '); --- after exit, end is executed. another Java code in the loop: declare q number: = 8; begin while q <100 loop q: = q + 1; dbms_output.put_line ('Hello world good '); end loop; end; 6. java code declare q number: = 8; begin for c in 1 .. 10 loop --- add reverse dbms_output.put_line ('C is '| c); dbms_output.put_line ('Hello world good'); end loop; end; 7. usage of the goto statement www.2cto.com Java code declare sal number; begin select t. sal into sal from emp t where rownum = 1; if sal <20000 then goto a; else goto B; end if; <a> dbms_output.put_line ('this is '); <B> dbms_output.put_line ('this is B '); end;

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.