# Step 1 : Create table.
SQL> CREATE TABLE Stu_Info
(
stuid number,
name varchar2(10),
city varchar2(10),
amount number
);
Sample Table Stu_Info.
STUID
|
NAME
|
CITY
|
AMOUNT
|
1000
|
RAM
|
NEW DELHI
|
1000
|
1001
|
SACHIN
|
MUMBAI
|
2000
|
1002
|
SMITH
|
NEW YORK
|
3000
|
1003
|
CHENG
|
BEIJING
|
4000
|
#Step2 : Create Procedure p_deleteStuInfo to delete table's row.
SQL> CREATE OR REPLACE PROCEDURE p_deleteStuInfo
(p_stuid IN stu_info.stuid%TYPE)
IS
BEGIN
DELETE Stu_info where stuid=p_stuid;
END;
SQL> /
Step 3 : Execute Procedure to delete table's row.
Once you created procedure successfully, you can use it multiple times simply passing parameter's value .
Execute Procedure# : Delete rows where stuid is 1000.
SQL> EXEC p_deleteStuInfo(1000);
Setp 4 : Check table Stu_info after DELETE.
STUID
|
NAME
|
CITY
|
AMOUNT
|
1001
|
SACHIN
|
MUMBAI
|
2000
|
1002
|
SMITH
|
NEW YORK
|
3000
|
1003
|
CHENG
|
BEIJING
|
4000
|
No comments:
Post a Comment