Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews DB Oracle Interviews:Concepts and ArchitectureData AccessDatabase ArchitectureDatabase ManagementDatabase Security OracleDistributed ProcessingFlexfieldForms ReportsGeneral OracleMemory ManagementMTO-SAP Financial AccountingOCIOracle AOLOracle AROracle Backup RecoveryOracle D2KOracle DatabaseOracle Database DeveloperOracle DB OptimizationOracle DBAOracle DeveloperOracle ETLOracle Forms 3.0Oracle Forms 4.0Oracle GLOracle PL-SQLOracle RMANOracle ScenariosOracle SecurityOracle SQLOracle System ArchitectureOracle Technology Network (OTN)Programmatic ConstructsRAC (Real Application Clusters)SQL Plus
Copyright © 2018. All Rights Reserved
Oracle Database Interview Question:
How To Use "IN OUT" Parameter Properly?
Submitted by: AdministratorHere are the rules about IN OUT parameters:
► A formal IN OUT parameter acts like an initialized variable.
► An actual IN OUT parameter must be a variable.
► An actual IN OUT parameter passes a copy of its value to the formal parameter when entering the procedure or function.
► An actual IN OUT parameter will receive a copy of the value from the formal parameter at the end of the procedure or function.
Here is good example of a procedure with IN OUT 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(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
► A formal IN OUT parameter acts like an initialized variable.
► An actual IN OUT parameter must be a variable.
► An actual IN OUT parameter passes a copy of its value to the formal parameter when entering the procedure or function.
► An actual IN OUT parameter will receive a copy of the value from the formal parameter at the end of the procedure or function.
Here is good example of a procedure with IN OUT 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(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
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.