一、SQL statements in PL_SQL
1.并不是所有的sql 都可以在PL_SQL中使用
2.Make changes to rows in the database by using DML commands;
3.Control a transaction with the commit , rollback ,or savepoint command; (注意commands)
二、SELECT Statements in PL_SQL
Syntax;
SELECT select_list
INTO { variable_name [ , varable_name] .... | record_name}
FROM table
[ WHERE condition ]
2.例子如下
DECLARE
V_FNAME EMPLOYEES.FIRST_NAME %TYPE;
-- V_FNAME VARCHAR(25);
BEGIN
SELECT FIRST_NAME INTO V_FNAME
FROM EMPLOYEES WHERE EMPLOYEE_ID = 200;
DBMS_OUTPUT.PUT_LINE(' FIRST NAME IS : ' || V_FNAME);
END;
3.如果多列则在PL_SQL中 应 SELECT a, b INTO a_var, b_var FROM table
4.The names of local variables and formal parameters take precedence over the names of database tables;
5.the names of local database table columns take precedence over the names of local variables;
三、其他的sql语句
1、update 2.insert 3.delete 4.merge (将两个表合并为一个表,如 A merge b 则会将A表中不存在比表的数据保存到比表,A表与B表相同的数据则会更新那A表的数据更新B表得数据)
2、update example
DECLARE
sal_increase employees.salary %type := 800;
BEGIN
update employees
set salary = salary + sal_increase
where job_id = 'ST_CLERK'
END;/