插入:
1 CREATE OR REPLACE Procedure p_insert_t_stu --存储过程名称
2 (
3 p_stuid in Number,
4 p_stuname in Nvarchar2,
5 p_stusex in Nvarchar2,
6 p_stuadd in Nvarchar2
7 )
8 as
9 BEGIN
10 insert into t_stu
11 values
12 (p_stuid,p_stuname,p_stusex,p_stuadd);
13 commit;
14 end;
删除:
1 CREATE OR REPLACE Procedure p_delete_t_stu --存储过程名称
2 (
3 p_stuid in Number,
4 p_msg Out Nvarchar2
5 )
6 Is
7 flag Integer := 1;
8 v_stuid Number;
9 Begin
10 Select flag Into v_stuid From t_stu Where stuid=p_stuid;
11 Delete t_stu
12 Where
13 stuid=p_stuid;
14 commit;
15 If flag=1 Then
16 Begin
17 p_msg:='删除成功';
18 End;
19 End If;
20 Exception
21 When Others Then
22 p_msg:=Sqlerrm || ',' || '删除失败';
23 END;
修改:
1 CREATE OR REPLACE Procedure p_update_t_stu --存储过程名称
2 (
3 p_stuid in Number,
4 p_stuname in Nvarchar2,
5 p_stusex in Nvarchar2,
6 p_stuadd in Nvarchar2
7 )
8 as
9 BEGIN
10 Update t_stu Setstuname=p_stuname,stusex=p_stusex,stuadd=p_stuadd
11 Where
12 stuid=p_stuid;
13 commit;
14 end;
oracle存储过程实现增删改简单示例
最新推荐文章于 2021-12-16 09:18:31 发布