<!doctype html>
Oracle
是存储在数据库里的
xxxxxxxxxx
declare
cursor name is select......
begin
open name;
loop
fetch name into ....
exit when name%notfound;
end loop;
close name;
end;
xxxxxxxxxx
declare
cursor name is ...
begin
open name;
fetch name into ....
while name%found loop
...
fetch name into ......;
end loop;
close loop;
end;
%found:判断最近一次使用fetch语句是否从缓存中检索导数据,如果检索到数据,返回true,否则返回false;(经常与while连用)
%notfound:判断最近一次使用fetch语句是否从缓存中检索导数据,如果没有检索到数据,返回true,否则返回false;(经常与when连用)
xxxxxxxxxx
create or replace procedure lisi(
id student.studentId%type,
na student.name%type)
as
begin
update student set studentId=id, name=na where studentId=id;
exception
when others then
DBMS_OUTPUT.PUT(‘无法修改‘);
end;
xxxxxxxxxx
create or replace function jindao
return number
as
c number;
begin
select COUNT(*) into c from student where name=‘金导‘;
return c;
end jindao;
xxxxxxxxxx
create or replace package pkg
as
procedure hello;
FUNCTION getid(id number) return number;
end pkg;
xxxxxxxxxx
create or replace package body pkg
as
procedure hello
as
begin
dbms_output.put_line(‘hello‘);
end hello;
FUNCTION getid(id number) return number
as
begin
return id;
end getid;
end pkg;
xxxxxxxxxx
declare
c number;
begin
pkg.hello;
c:=pkg.getid(1);
DBMS_OUTPUT.put_line(c);
end;
xxxxxxxxxx
create or replace trigger jindaogrant
after update or delete on student
begin
DBMS_OUTPUT.put_line(‘触发器发现你了‘);
end;
原文:https://www.cnblogs.com/huluxia-fun/p/14990029.html