1.CREATE OR REPLACE PROCEDURE cur_exp_1 IS
CURSOR c1 IS
SELECT emp_id, dept_name
FROM emp, dept
WHERE dept.location = 'London'
AND dept.dept_id = emp.dept_id;
TYPE rec_type IS RECORD (id emp.emp_id%TYPE,
name dept.dept_name%TYPE);
rec rec_type;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO rec;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(rec.id);
END LLOP;
CLOSE c1;
END;2. A
CURSOR c1 IS
SELECT emp_id, dept_name
FROM emp, dept
WHERE dept.location = 'London'
AND dept.dept_id = emp.dept_id;
TYPE rec_type IS RECORD (id emp.emp_id%TYPE,
name dept.dept_name%TYPE);
rec rec_type;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO rec;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(rec.id);
END LLOP;
CLOSE c1;
END;2. A
解决方案 »
- oracle高级问题,请教高手
- 大侠们来给新手点帮助
- 请教:oracle存储过程如何获取结果集所返回列的列名
- plsql 8.0 large data editor 点击无法读取配置注册表项
- linux下oracle疑问
- 游标,游标,请来帮忙
- 不知Oracle sql语法中有没有提供类似于sum(数值型字段)对字符型字段操作的函数呢?...
- 见到这么一个where条件,请问(+)是做什么用的
- select 数据库记录(简单问题)(二)
- oracle 普通用户无法登陆
- oracle的DBA STUDIO里用错误的用户名和密码选SYSDBA也可以进入!是为啥子呢?
- 初学oracle 问一简单的存储过程问题
declare
cursor mycursor
begin
loop
fetch mycursor into
exit when mycursor%not found
if...
then...
else...
end if..
end loop
close mycursor;
end.
这个是老师给的框架.能帮我补全么?顺便讲一下,谢谢:)
cursor mycursor
select * from tabname;
begin
open mycusor;
loop
fetch mycursor into 变量;
exit when mycursor%notfound;
if...then
...
else
...
end if;
end loop;
close mycursor;
end;
/
比如 变量s_tabname类型为tabname%rowtype,其中有一个字段为owner,并定义一个变量count,
s_tabname tabname%rowtype;
count integer(4) :=0;
则:
IF s_tabname.owner='SYSTEM' THEN
COUNT:=COUNT+1;
END IF;
create table #tmp
(id indentiy(1,1) not null,
a ...
..
.)
insert #tmp(a..,..)
from targetTablewhere (1=1)begin
select @i=(select max(id ) from #tmp)
if isnull(@i)
break
--your action--delete #tmp
where #tmp.id=@i
end
set serverout on
declare
cursor stu_cursor is
select stuno,stuname from student order by stuno;
stu_record stu_cursor%rowtype;
-------定义一个变量,和游标的字段相对应
open stu_cursor;
loop
fetch stu_cursor into stu_record;
exit when stu_cursor%notfound;
dbms_output.put_line(stu_record.stuno);
dbms_output.put_line(stu_record.stuname);
end loop;
close stu_cursor;
end;对于数值类型,可以使用number(*,n),n是小数点后面的位数。