*在PL/SQL中只可以直接嵌入SQL中的查询、DML、TCL,而DDL、DCL不能直接嵌入。
*DDL怎么嵌入,需要吗?
*DCL怎么嵌入,需要吗?
?
;——以SQL语句为单位来执行;
/——以PL/SQL块为单位来执行;
?
?
SQL> SELECT *FROM dept;
??? DEPTNO DNAME????????? LOC
---------- -------------- -------------
??????? 10 ACCOUNTING???? NEW YORK
??????? 20 RESEARCH?????? DALLAS
??????? 30 SALES????????? CHICAGO
??????? 40 OPERATIONS???? BOSTON
SQL> SELECT *FROM dept
? 2? /
??? DEPTNO DNAME????????? LOC
---------- -------------- -------------
??????? 10 ACCOUNTING???? NEW YORK
??????? 20 RESEARCH?????? DALLAS
??????? 30 SALES????????? CHICAGO
??????? 40 OPERATIONS???? BOSTON
SQL>
?
?
select语句
sql可以返回任意量的记录;PL/SQL能且只能返回单个记录。
SQL> begin
? 2? select *from dept;
? 3? end;
? 4? /
select *from dept;
*
第 2 行出现错误:
ORA-06550: 第 2 行, 第 1 列:
PLS-00428: 在此 SELECT 语句中缺少 INTO 子句
SQL> select *from dept;
??? DEPTNO DNAME????????? LOC
---------- -------------- -------------
??????? 10 ACCOUNTING???? NEW YORK
??????? 20 RESEARCH?????? DALLAS
??????? 30 SALES????????? CHICAGO
??????? 40 OPERATIONS???? BOSTON
SQL>
?
??????? *select * bulk collect into table_type from t1;?
??????? *PL/SQL中select into能且只能返回一条记录。
??????? *PL/SQL中的变量与表字段同名会有too_many_rows例外。
??????? *