您的位置:首页 > 其它

Chapter -09 Creating Procedures 02

2013-04-19 16:51 316 查看

Using the IN、OUT、IN OUT Parameter Mode:Example

DEMO 03:IN OUT CALL WITH VARIABLE

VARIABLE b_phone_no VARCHAR2(16)
EXECUTE :b_phone_no := '01082375915'
PRINT b_phone_no
EXECUTE format_phone(:b_phone_no)
PRINT b_phone_no
--plsql block

--call
SQL> @s9_3_call_01

PL/SQL procedure successfully completed.

B_PHONE_NO
--------------------------------------------------------------------------------
01082375915

PL/SQL procedure successfully completed.

B_PHONE_NO
--------------------------------------------------------------------------------
(010)8237-5915


Viewing OUT Parameters:Using SQL*PLUS Host Variables

1、Use SQL*Plus host variables.

2、Execute QUERY_EMP using host variable.

3、Print the host variables.

Parameter Passing Methods

The PL/SQL compiler has two ways of passing an actural parameter to a subprogram:

by reference:The compiler passes the subprogram a pointer to the actual parameter.The actual and formal parameters refer to the same memory location.

by value:The compiler assigns the value of the actual parameter to the corresponding formal parameter.The actual and fromal parameter refer to different memory locations.



IN->by reference(按照正常思维,容易混淆)

OUT 、IN OUT ->by value(按照正常思维,容易混淆)

Available Notations for Passing Actual Parameters

When calling a subprogram,you can write the actual parameters using the following notations:

-Postional:Lists the actual parameters in the same order as the formal parameters

-Named:Lists the actual parameters in arbitrary order and uses the association operator(=>) to associate a named formal parameter with its acutal parameter

-Mixed:Lists some of the acutal parameters as positional and some as named

Prior to Oracle Database 11g,only the postional notation is supported in calls from SQL

Starting in Oracle Database 11g,named and mixed notation can be used for sepecifying arguments in calls to PL/SQL subroutines from SQL statements.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: