日期:2014-05-17  浏览次数:20736 次

关于oracle动态数据绑定的问题?
新手求指导,关于oracle数据绑定的问题,刚入手数据库,请高手门说得简单清晰一些,谢谢了!原代码如下:
SQL代码:
declare
dep_name department.department_name%type;
begin
  select department_name into dep_name from department where department_id=2;
end;
表:
 
SQL> select * from department;
 
DEPARTMENT_ID DEPARTMENT_NAME MANGER_ID LOCATION_ID
------------- -------------------- --------- -----------
  2 设计部  
 
SQL> 
刚入手看到这条select into 的命令,请指教!

------解决方案--------------------
declare
dep_NAME student.NAME %type;
begin
select NAME into dep_NAME from student where ID =1;
end;

如果id不是唯一的话……
declare
dep_NAME student.NAME %type;
begin
select max(NAME) into dep_NAME from student where ID =1;
end;