select语句,返回必须有且只有一条记录,因为不返回记录没有用处,返回很多时变量
装不了。
select 语句必须带into
insert into语句
装不了。
select 语句必须带into
--SQL语句的运用
declare
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
select ename,sal into v_ename,v_sal from emp where empno=7369;
dbms_output.put_line(v_ename||' '||v_sal);
end;
declare
v_emp emp%rowtype;
begin
select * into v_emp from emp where empno=7369;
dbms_output.put_line(v_emp.ename);
end;
insert into语句
declare
v_deptno dept.deptno%type:=50;
v_dname dept.dname%type:='aaaa';
v_loc dept.loc%type:='bj';
begin
insert into dept2 values(v_deptno,v_dname,v_loc);
commit;
end;
pl/sql 执行ddl语句execute immediate
begin
execute immediate 'create table bbb(b varchar2(20) default ''222'')';
end;
执行授权语句
begin
execute immediate 'grant dba to scott';
end;