使用光标查询10部门的员工姓名和工资,并打印__使用光标查询员工姓名和工资,并打印
/*
使用光標(biāo)查詢10部門的員工姓名和工資,并打印
*/
set serveroutput on
declare
? --申明一個(gè)光標(biāo)代表員工的姓名和工資
? --cursor c1 is select ename,sal from emp;
? --定義一個(gè)帶參數(shù)的光標(biāo)
? cursor c2(dno number) is select ename,sal from emp where deptno= dno;
? --定義兩個(gè)變量保存員工姓名和薪水
? pename emp.ename% TYPE;
? psal?? emp.sal% TYPE;
begin
? --打開(kāi)光標(biāo)
? open c2(10);
? --循環(huán)從c1中取值
? loop
? --注意順序
? fetch c2 into pename, psal;
? --退出條件
? exit when c2%notfound;
?
? dbms_output.put_line(pename ||'的工資是:' || psal );
? end loop;?
? --關(guān)閉光標(biāo)
? close c2;
end;
/
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
/*
使用光標(biāo)查詢員工姓名和工資,并打印
*/
set serveroutput on
declare
? --申明一個(gè)光標(biāo)代表員工的姓名和工資
? cursor c1 is select ename,sal from emp;
? --定義兩個(gè)變量保存員工姓名和薪水
? pename emp.ename% TYPE;
? psal?? emp.sal% TYPE;
begin
? --打開(kāi)光標(biāo)
? open c1;
? --循環(huán)從c1中取值
? loop
? --注意順序
? fetch c1 into pename, psal;
? --退出條件
? exit when c1%notfound;
?
? dbms_output.put_line(pename ||'的工資是:' || psal );
? end loop;?
? --關(guān)閉光標(biāo)
? close c1;
end;
/
?
總結(jié)
以上是生活随笔為你收集整理的使用光标查询10部门的员工姓名和工资,并打印__使用光标查询员工姓名和工资,并打印的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 长期不用的信用卡怎么处理最好 及时注销
- 下一篇: 小米股票代码是多少 如何购买小米股票