Oracle PLSQL, oracleplsql
PL/SQL Developer is an integrated development environment dedicated to developing Oracle database-oriented applications. PL/SQL is also a programming Language called Procedural Language/SQL. It is an extension of SQL statements in Oracle databases. The features of the programming language are added to the use of common SQL statements. Therefore, PL/SQL organizes data operations and query statements into procedural units of PL/SQL code, complex functions or computing are implemented through logical judgment, loops, and other operations, so that the SQL language has the process processing capability. PL/SQL is available only in Oracle databases.
OnePL/SQL program structure:
Declare
Description (variable description, cursor declaration, exception description)
Begin
Statement sequence (DML statement )......
Exception
Exception Handling statement
End;
Here we will talk about the variable problem:
Var1 char (15); -- indicates the variable name, data type, and length. Use a semicolon to end the description statement.
Married boolean: = true; -- use ": =" to represent equal sign "=", and use "=" to represent "= ".
My_name emp. ename % type; -- reference type variable, that is, the type of my_name is the same as that of the ename column in the emp table.
Emp_rec emp % rowtype; -- Record type variable
Reference of record variable component: emp_rec.ename: = 'adams ';
An example demonstrates PLSQL:The salary is increased by the employee's job type. The president's salary is RMB 1000, the manager's salary is RMB 800, and others are up by RMB 400.
Declare cursor cemp is select empno, empjob from emp; pempno emp. empno % type; pjob emp. empjob % type; begin rollback; open cemp; loop -- fetch a record fetch cemp into pempno, pjob; exit when cemp % notfound; -- determine the 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 ('complete'); end ;/
Before the increase:
After the increase:
Combining the data manipulation capability of SQL with the data processing capability of process language makes PLSQL process-oriented, but simpler, more efficient, and more flexible than process language.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.