The following articles mainly describe the writing of Oracle stored procedures (add, delete, and modify), which are analyzed in the current form, I find that I have too many things to learn from, or even cannot find a clue, such as databases, development technologies, management ...... These technologies.
Update every day. If you want to keep up with your step, you may need to get tired of yourself, or do your best in terms of expertise.
I haven't written any Oracle stored procedures for a long time. Generally, I write a lot of query statements and try to write the stored procedures of inserting, deleting, and modifying records.
Insert:
Code
- Create or replace Procedure p_insert_t_stu -- stored Procedure name
- (
- P_stuid in Number,
- P_stuname in Nvarchar2,
- P_stusex in Nvarchar2,
- P_stuadd in Nvarchar2
- )
- As
- BEGIN
- Insert into t_stu
- Values
- (P_stuid, p_stuname, p_stusex, p_stuadd );
- Commit;
- End;
Delete:
Code
- Create or replace Procedure p_delete_t_stu -- stored Procedure name
- (
- P_stuid in Number,
- P_msg Out Nvarchar2
- )
- Is
- Flag Integer: = 1;
- V_stuid Number;
- Begin
- Select flag Into v_stuid From t_stu Where stuid = p_stuid;
- Delete t_stu
- Where
- Stuid = p_stuid;
- Commit;
- If flag = 1 Then
- Begin
- P_msg: = 'deleted successfully ';
- End;
- End If;
- Exception
- When Others Then
- P_msg: = Sqlerrm | ',' | 'deletion failed ';
- END;
Modify:
Code
- Create or replace Procedure p_update_t_stu -- stored Procedure name
- (
- P_stuid in Number,
- P_stuname in Nvarchar2,
- P_stusex in Nvarchar2,
- P_stuadd in Nvarchar2
- )
- As
- BEGIN
- Update t_stu Set stuname = p_stuname, stusex = p_stusex, stuadd = p_stuadd
- Where
- Stuid = p_stuid;
- Commit;
- End;
The above content is an introduction to the Oracle stored procedure. I hope you will find some gains.