创建一个存储过程的语法:
create [or replace] procedure 过程名
[(参数名 [IN | OUT | IN OUT] 数据类型 ...]
{IS | AS}
{说明部分}
begin
语句序列
[exception 例外处理]
end [过程名]
-
CREATE TABLE Student
-
(Sno CHAR(9) PRIMARY KEY,
-
Sname CHAR(20) NOT NULL,
-
Ssex CHAR(4),
-
Sage SMALLINT,
-
Sdept CHAR(20)) tablespace gaospace;
-
-
例子:
创建一个添加学生的存储过程。
-
create or replace procedure addnewstudent(
-
p_sno student.sno%type,
-
p_sname student.sname%type,
-
p_ssex student.ssex%type,
-
p_sage student.sage%type,
-
p_sdept student.sdept%type)
-
As
-
begin
-
insert into student values(p_sno, p_sname, p_ssex, p_sage, p_sdept);
-
commit;
-
end addnewstudent;
调用:
-
begin
-
addnewstudent('0209','赵利','男',21,'cs');
-
end;
参数类型:
这里肯定是传入参数 IN:
-
create or replace procedure addnewstudent2(
-
p_sno IN student.sno%type,
-
p_sname IN student.sname%type,
-
p_ssex IN student.ssex%type,
-
p_sage IN student.sage%type,
-
p_sdept IN student.sdept%type)
-
As
-
begin
-
insert into student values(p_sno, p_sname, p_ssex, p_sage, p_sdept);
-
commit;
-
end addnewstudent2;
-
-
-
begin
-
addnewstudent2('0210','赵五','男',21,'cs');
-
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26435490/viewspace-1077848/
,如需转载,请注明出处,否则将追究法律责任。