第6章OreaclePL/SQL动态SQL

动态SQL分为:

早期绑定和晚期绑定
编译 早期绑定(编译时就确定的对象)
执行 晚期绑定(不确定性要通过执行之后才确定下来)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
execute immediae关键字执行动态SQL语句using是预编译返回
create or replace procedure proc_sqlstring(empid in int)is
begin
execute immediate 'delete from emp where empno=:id' using empid;
end;
call proc_sqlstring(7782);
/*1、使用动态SQL完成创建一张表*/
declare
str_sqltring varchar2(4000);
begin
str_sqltring := 'create table t_table(
id int primary key not null,
name varchar2(100)
)';
execute immediate str_sqltring;
end;