oracle stored procedure using the experience

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_34401027/article/details/73650609

First, the general structure stored procedure

--- 1) defines the storage name, the incoming parameters, outgoing parameters

create or replace procedure proc_function(in_opt in varchar2 ,out_opt in varchar2,outValue out sys_refcursor)

as

--2) define a variable parameter

  v_opt1 varchar2(50);
  v_count       number;

begin

--3) stored procedures specific to do

--4) cursor output (optional)

open outValue for  select   funname,funid from tbl_base_function;

end;

Second, focus on knowledge

--1) in length parameters supplied by an external parameter determined length, out parameter stored by the length of the internal length determination procedure assignment.

--2) begin end within a plurality of blocks can be nested block. Note that at this time the parameters of the scope of the problem.

--3 internal) stored procedures often require progressive processing is data, it is necessary to process the cursor circulated. Use the cursor is critical.

--4) select into the assignment, you may find the value of the number of rows of data or too many exceptions. At this time, you can use the cursor or provide code exception handling avoid.

--5) If the return value is the result set, the cursor can select a method embodiment, the transaction processing stage temporary table or the like.

How --6) program call a stored procedure: development code? regular tasks in the job?

--7) stored procedure not only to compile, but also to the test.







Guess you like

Origin blog.csdn.net/qq_34401027/article/details/73650609