数据库语句中 select into 与select in的区别是什么

如题所述

select into 是把值取出来赋值到变量中,比如:
select cola into v_a from tab where xxx;

select in 是什么?这样吗?
select * from tab where cola in (1,2,3,4,5...)

这表示查找cola的 括号中的列表中 的内容追问

写个函数,实现以下功能:
1、添加一个参数,参数为雇员的名字
2、通过输入一个雇员名字,可以查询出雇员所在的部门
如:名字为fun_getdept的函数,编译成功后,可通过以下命令执行:
select fun_getdept('SMITH') from dual;
得到的结果为: RESEARCH
涉及的表有dept 、emp 两个表。

追答

-- 如下:未处理特殊情况(比如未找到姓名)

create or replace function fun_getdept(ename in varchar2) as
result varchar2(200);
begin
select deptname into result from dept,emp where emp.deptid = dept.id and emp.empname = ename;
return result;
end;

温馨提示:答案为网友推荐,仅供参考
相似回答