What Are Named Parameters?
Submitted by: AdministratorNamed parameters are actual parameters specified not by position but by providing formal parameter names when calling the procedure or function. The main advantage of named parameters is that the caller don't have to remember the position of each parameter. But the caller have to remember the formal parameter names. The script below illustrates how to use named parameters:
SQL> CREATE OR REPLACE PROCEDURE SWAP_TEST AS
2 A NUMBER := 3;
3 B NUMBER := 8;
4 PROCEDURE MY_SWAP(X IN OUT NUMBER,Y IN OUT NUMBER) AS
5 T NUMBER;
6 BEGIN
7 T := X;
8 X := Y;
9 Y := T;
10 END MY_SWAP;
11 BEGIN
12 MY_SWAP(Y=>B, X=>A); -- same as (X=>A, Y=B), OR (A,B)
13 DBMS_OUTPUT.PUT_LINE('A = ' || TO_CHAR(A));
14 DBMS_OUTPUT.PUT_LINE('B = ' || TO_CHAR(B));
15 END;
16 /
SQL> EXECUTE SWAP_TEST;
A = 8
B = 3
Submitted by: Administrator
SQL> CREATE OR REPLACE PROCEDURE SWAP_TEST AS
2 A NUMBER := 3;
3 B NUMBER := 8;
4 PROCEDURE MY_SWAP(X IN OUT NUMBER,Y IN OUT NUMBER) AS
5 T NUMBER;
6 BEGIN
7 T := X;
8 X := Y;
9 Y := T;
10 END MY_SWAP;
11 BEGIN
12 MY_SWAP(Y=>B, X=>A); -- same as (X=>A, Y=B), OR (A,B)
13 DBMS_OUTPUT.PUT_LINE('A = ' || TO_CHAR(A));
14 DBMS_OUTPUT.PUT_LINE('B = ' || TO_CHAR(B));
15 END;
16 /
SQL> EXECUTE SWAP_TEST;
A = 8
B = 3
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Call a Stored Function in Oracle? |
☺ | What Is Input Buffer in SQL*Plus? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | How To Invoke the Data Pump Import Utility? |
☺ | How To Run SQL*Plus Commands in SQL Developer? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |