您的位置:首页 > 数据库 > Oracle

[bbk4979]第06集 - Chapter 04- Interacting with Oracle Database Server:SQL Statements in PL/SQL Programs(01)

2013-04-22 23:25 621 查看

Objectives

After completing this lesson,you should be table to do the following:

Determine the SQL statements that can be directly included in a PL/SQL executeable block.

Manipulate data with DML statements in PL/SQL

Use transaction control statements in PL/SQL

Make use of the INTO clause to hold the values returned by a SQL statement

Differentiate between implicit cursors and explicit cursors

Use SQL cursor attributes

Agenda

Retrieving data with PL/SQL

Manipulating data with PL/SQL

Introducing SQL cursors

SQL Statements in PL/SQL

Retrieve a row from the database by using the SELECT command.

Make chanages to rows in the database by using DML commands.

Control a transaction with COMMIT,ROLLBACK,or SAVEPOINT command;

一个PL/SQL的blokc中,如果执行完毕了,里面的事务不会自动处理(COMMIT,ROLLBACK),必须显示处理.

SELECT Statements in PL/SQL

Retrieve data from the database with a SELECT statement.

Syntax:(带有明显PL/SQL烙印的SELECT)

SELECT select_list
INTO  { variable_name[,variable_name]... | record_name }
FROM table
[WHERE condition]


The INTO clause is required.

Queries must return only one row.

Demo 02

SELECT employee_id,last_name,salary,job_id FROM emp WHERE job_id = 'ST_CLERK';

DECLARE
sal_increase    employees.salary%TYPE := 800;
BEGIN
UPDATE emp
SET     salary = salary + sal_increase
WHERE job_id = 'ST_CLERK';

COMMIT;
END;

/

SELECT employee_id,last_name,salary,job_id FROM emp WHERE job_id = 'ST_CLERK';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: