oracle- function

The syntax of the function

 

create or replace function function name (parameter type parameter Mode 1)
return return value type
as
 Variable 1 Variable Type;
 Variable 2 Variable Type;
begin
 Function thereof;
end function name;
 
Classification model
 
in: read-only mode, the function value of the parameter can be referenced and can not be changed;
out: write-only mode, can only be assigned, it can not be referenced;
in out: readable and writable.
 
Delete function
 
drop function testfunction // testfunction as a function name
 
Creating functions
 
Requirements: call the function with two arguments and their output
1. First, find the folder in the left plsql Functions software, right-click on the folder New, pop-up box on the right side of the body.
2. In the housing enter the name (name), parameters (parameters) and the return value (return type), can be modified at the back, so the type parameters and return values ​​may be temporarily omitted.
note:

1. function: sign function.

2. test1: name of the function.

3. num1, num2: function parameters.

4. return number: Return Value Type as a number.

5. num3 number: the definition of a variable number type, name num3.

6. return (num3) Returns

1 create or replace function test1(num1 number,num2 number) return number is
2   num3 number;
3 begin
4   num3:=num1+num2;
5   return(num3);
6 end test1;

 

函数的调用

 

在sql中直接就可以使用之前创建好的函数,比如:select test1(1,2) from dual

 

 

持续更新!!

 

Guess you like

Origin www.cnblogs.com/flyinghome/p/12156638.html