Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
40
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Remote Dependencies

does not change the signature. Any other change of parameter mode does change the signature.

Default Parameter Values Changing the specification of a default parameter value does not change the signature. For example, procedure P1 has the same signature in the following two examples:

PROCEDURE P1 (Param1 IN NUMBER := 100);

PROCEDURE P1 (Param1 IN NUMBER := 200);

An application developer who requires that callers get the new default value must recompile the called procedure, but no signature-based invalidation occurs when a default parameter value assignment is changed.

Examples of Changing Procedure Signatures

Using the Get_emp_names procedure defined in "Parameters for Procedures and Functions" on page 7-5, if the procedure body is changed to the following:

DECLARE

Emp_number NUMBER;

Hire_date DATE;

BEGIN

--date format model changes

SELECT Ename, To_char(Hiredate, 'DD/MON/YYYY') INTO Emp_name, Hire_date

FROM Emp_tab

WHERE Empno = Emp_number;

END;

The specification of the procedure has not changed, so its signature has not changed.

But if the procedure specification is changed to the following:

CREATE OR REPLACE PROCEDURE Get_emp_name (

Emp_number

IN

NUMBER,

Hire_date

OUT

DATE,

Emp_name

OUT

VARCHAR2) AS

And if the body is changed accordingly, then the signature changes, because the parameter Hire_date has a different datatype.

7-26 Oracle Database Application Developer's Guide - Fundamentals

Remote Dependencies

However, if the name of that parameter changes to When_hired, and the datatype remains VARCHAR2, and the mode remains OUT, the signature does not change. Changing the name of a formal parameter does not change the signature of the unit.

Consider the following example:

CREATE OR REPLACE PACKAGE Emp_package AS

TYPE Emp_data_type IS RECORD (

Emp_number NUMBER,

Hire_date VARCHAR2(12),

Emp_name VARCHAR2(10));

PROCEDURE Get_emp_data

(Emp_data IN OUT Emp_data_type);

END;

CREATE OR REPLACE PACKAGE BODY Emp_package AS PROCEDURE Get_emp_data

(Emp_data IN OUT Emp_data_type) IS

BEGIN

SELECT Empno, Ename, TO_CHAR(Hiredate, 'DD/MON/YY') INTO Emp_data

FROM Emp_tab

WHERE Empno = Emp_data.Emp_number;

END;

END;

If the package specification is changed so that the record's field names are changed, but the types remain the same, then this does not affect the signature. For example, the following package specification has the same signature as the previous package specification example:

CREATE OR REPLACE PACKAGE Emp_package AS

TYPE Emp_data_type IS RECORD (

 

Emp_num

NUMBER,

-- was Emp_number

Hire_dat

VARCHAR2(12),

-- was Hire_date

Empname

VARCHAR2(10));

-- was Emp_name

PROCEDURE Get_emp_data

(Emp_data IN OUT Emp_data_type);

END;

Changing the name of the type of a parameter does not cause a change in the signature if the type remains the same as before. For example, the following package specification for Emp_package is the same as the first one:

CREATE OR REPLACE PACKAGE Emp_package AS

TYPE Emp_data_record_type IS RECORD (

Emp_number NUMBER,

Using Procedures and Packages 7-27

Соседние файлы в папке Oracle 10g