常见问题1000例Oracle(五)
gary_name varchar2(20);
cur_gary cursor%rowtype;
begin
open cursor;
loop
begin
fetch cursor into cur_gary;
-- DBMS_OUTPUT.put_line(test.id);
-- DBMS_OUTPUT.put_line('teeesttt------stesrt');
-- DBMS_OUTPUT.put_line(test.password);
--DBMS_OUTPUT.put_line(test.emailaddress);
-- DBMS_OUTPUT.put_line(test.introduce);
exit when cursor%notfound;
DBMS_OUTPUT.put_line(cur_gary.id);
DBMS_OUTPUT.put_line(cur_gary.name);
DBMS_OUTPUT.put_line(cur_gary.password);
DBMS_OUTPUT.put_line(cur_gary.account);
DBMS_OUTPUT.put_line(cur_gary.emailaddress);
DBMS_OUTPUT.put_line(cur_gary.introduce);
student_name:=cur_gary.name;
--DBMS_OUTPUT.put_line(student_name);
end;
end loop;
if cursor%isopen then
close cursor;
end if;
end gary_test2;
-- use for loop to resaerch data
create or replace procedure gary_test3 (student_id in number,
student_name out varchar2
)
IS
--student_name:='kevin_xiong';
x number:=1;
Cursor cursor is select * from test_gary1 where id=student_id;
--name varchar2(20);
i number:=0;
begin
if x>0 then
begin
DBMS_OUTPUT.put_line('holl world!');
DBMS_OUTPUT.put_line('holl baby!');
DBMS_OUTPUT.put_line('hello infosys!');
end;
end if;
for test in cursor LOOP
begin
DBMS_OUTPUT.put_line(test.id);
DBMS_OUTPUT.put_line(test.name);
DBMS_OUTPUT.put_line(test.password);
DBMS_OUTPUT.put_line(test.emailaddress);
DBMS_OUTPUT.put_line(test.introduce);
end;
end LOOP;
end gary_test3;
-- use while loop to resaerch data
create or replace procedure gary_test4 (student1_id in number,