Oracle database PL/SQL stored procedure cursor trigger

Source: Internet
Author: User

    1. Create a stored procedure that adds food


    2. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.