Operator, condition, and loop control in PL/SQL

Source: Internet
Author: User

1. PL/SQL is a block structure language. It stores a group of statements in a block and sends them to the server at one time. The statements are compiled and then executed. For PL/SQL blocks with names, they can be compiled separately and permanently stored in the database and ready for execution at any time. Advantages of PL/SQL:

A. supports SQL (Case Insensitive ). b. supports object-oriented processes. c. better performance (SQL is a non-procedural language and can only be executed one by one. PL/SQL can compile one block at a time ). d. portability. e. security. 2.pl/ SQL block Syntax:
[DECLARE--decalration statements] BEGIN--executable statements [Exception--exception statements]End;
3. assignment operator :(: =, default, select .. into), special symbol: (|, --, ** power operation, for example, 3 ** 2 = 9), relational OPERATOR: (>,<,>=, <=, =, <> ,! =), Logical operators (and, or, not ). 4. Conditional Control statement:
If condition 1 then Condition 1 struct elsif condition 2 then condition 2 struct end if; and Case: case [selector] When expression 1 then Statement 1; when expression 2 then Statement 2; elseend case; the options must match the values; otherwise, an error is returned. Example of using case as an expression: p_grade: = casewhen v_grade = 'A' then'a' else 'bb' end;
5. loop Structure: unconditional loop (loop-end loop statement): loop -- loop body end loop; while loop statement: whlie condition loop body end loop; For Loop statement: for Loop Variable in [reverse] loop upper limit .. the lower limit of loop the end loop of the loop body. For example:
declare       counter number(3):=0;       sumResult number:=0;begin       dbms_output.put_line(counter);       for counter in 1..100 loop        dbms_output.put_line(counter);           sumResult:=sumResult+counter;        end loop;        dbms_output.put_line('result is :'||sumResult);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.