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 Define a Sub Function?
Submitted by: AdministratorA sub function is a function defined and used inside another procedure or function. You need to define a sub function in the declaration part of the enclosing procedure or function. Sub function definition starts with the FUNCTION key word. Here is a sample script showing you how to define and use a sub function:
SQL> CREATE OR REPLACE PROCEDURE SUM_TEST AS
2 FUNCTION MY_SUM(X NUMBER, Y NUMBER)
3 RETURN NUMBER AS
4 BEGIN
5 RETURN X + Y;
6 END;
7 BEGIN
8 DBMS_OUTPUT.PUT_LINE('3 + 5 = ' ||
9 TO_CHAR(MY_SUM(3,5)));
10 DBMS_OUTPUT.PUT_LINE('5 + 3 = ' ||
11 TO_CHAR(MY_SUM(5,3)));
12 END;
13 /
SQL> EXECUTE SUM_TEST;
3 + 5 = 8
5 + 3 = 8
Submitted by: Administrator
SQL> CREATE OR REPLACE PROCEDURE SUM_TEST AS
2 FUNCTION MY_SUM(X NUMBER, Y NUMBER)
3 RETURN NUMBER AS
4 BEGIN
5 RETURN X + Y;
6 END;
7 BEGIN
8 DBMS_OUTPUT.PUT_LINE('3 + 5 = ' ||
9 TO_CHAR(MY_SUM(3,5)));
10 DBMS_OUTPUT.PUT_LINE('5 + 3 = ' ||
11 TO_CHAR(MY_SUM(5,3)));
12 END;
13 /
SQL> EXECUTE SUM_TEST;
3 + 5 = 8
5 + 3 = 8
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.