Oracle's Plsql

Source: Internet
Author: User

PL/SQL Developer is an integrated development environment that specializes in developing applications for Oracle databases. PL/SQL is also a programming language called the procedural SQL language (procedural language/sql), which is an extension of the Oracle database to SQL statements. In the use of ordinary SQL statements to increase the characteristics of the programming language, so PL-SQL to the data Operations and query statements organized in the PL/SQL code of the process unit, through logical judgment, loop and other operations to achieve complex functions or calculations, so that the SQL language has process capabilities. PL/SQL is available only for Oracle databases.

A PL/SQL program Structure :

Declare

Description section (variable description, cursor declaration, exception description)

Begin

Statement sequence (DML statement) ...

exception

Exception Handling Statements

End

Here's a question about variables:

Var1 char (15);--describes the variable name, data type, and length followed by a semicolon ending description statement.

Married boolean:=true;--uses ": =" to denote an equal sign "=", and "=" for "= =".

My_name emp.ename%type;--reference variable, that is, the type of my_name is the same as the type of the ename column in the EMP table

Emp_rec emp%rowtype;--Record type variable

Reference to the variable component of the record type: emp_rec.ename:= ' Adams ';

An example of the following plsql: According to the employee's job increase wages, the President 1000 yuan, the manager 800 yuan, the other people rose 400 yuan.

Declare  cursor Cemp is select Empno,empjob from emp;  Pempno Emp.empno%type;  Pjob   emp.empjob%type;begin  rollback;  Open cemp;  Loop    -Take a record    fetch cemp into pempno,pjob;    Exit when Cemp%notfound;        --Judge Position    if Pjob = ' president ' then update EMP set sal=sal+1000 where empno=pempno;      elsif pjob = ' MANAGER ' then update emp set sal=sal+800 where empno=pempno;      Else update emp set sal=sal+400 where empno=pempno;    End If;  End Loop;  Close Cemp;      commit;    Dbms_output.put_line (' done '); end;/
before the rise:

after the rise:


The data manipulation ability of SQL language is combined with the data processing ability of process language, which makes plsql more simple, efficient and practical than the process language.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Oracle's Plsql

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.