Create a stored procedure that adds food
Create or Replace procedure Add_food_pro (name in Varchar,price in number,description on varchar) as Begininsert into food (f_name,f_price,description) values (name,price,description); commit;end;--The following code is called the stored procedure Beginadd_food_pro (' sweet and sour fish ', 12 , ' delicious '); end;
Create a stored procedure with an output parameter, take a+b=c as an example
Create or Replace procedure Add_num_pro (a in int,b with int,c out int) as beginc:=a+b;end;--next call to Stored procedure Declarec int;begin add_ Num_pro (10,20,c);d bms_output.put_line (c); end;--Note the final dbms_output.put_line ();--if you want to see the results, you need to open the console, set Serveroutput On
The use of Oracle database midstream standard
DECLARE CURSOR c is select *from employees; Hang employees%rowtype;begin--opens the cursor open C;loop fetch C into the hang; Dbms_output.put_line (' The employee's name is ' | | hang.first_name| | ', wages are ' | | Hang.salary); Exit when C%notfound;end loop;--close the cursor if C%isopen then close C;end if;end;
Create a function
--Create a function that can remove the space of the string create or Replace function Noblank1 (str varchar) return Varcharisbeginreturn replace (str, ', '); end ;--Call function Select Noblank1 (' DFA D s a ') from dual;
Create a Trigger
--Creating a trigger create or replace trigger Stu_update_tribefore update on Studentfor each rowbegindbms_output.put_line (' A record has been updated, the original data is ' | |:o ld.age| | ' The new data is ' | |:new.age '; end;--trigger trigger update student set age=21;
This article is from the "Java White Battlefield" blog, be sure to keep this source http://8023java.blog.51cto.com/10117207/1669102
Oracle database PL/SQL stored procedure cursor trigger