How To Define Default Values for Formal Parameters?
Submitted by: AdministratorIf you have an IN parameter, you can make it as an optional parameter for the calling statement by defining the formal parameter with the DEFAULT clause. This gives you the freedom of not providing the actual parameter when calling this procedure or function. See the following tutorial script shows you an example procedure with an optional parameter:
SQL> CREATE OR REPLACE PROCEDURE WELCOME AS
2 PROCEDURE GREETING(S IN CHAR DEFAULT 'globalguideline') AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('Welcome to ' || S);
5 END;
6 BEGIN
7 GREETING('MySpace.com');
8 GREETING;
9 END;
10 /
Procedure created.
SQL> EXECUTE WELCOME;
Welcome to MySpace.com
Welcome to globalguideline
Submitted by: Administrator
SQL> CREATE OR REPLACE PROCEDURE WELCOME AS
2 PROCEDURE GREETING(S IN CHAR DEFAULT 'globalguideline') AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('Welcome to ' || S);
5 END;
6 BEGIN
7 GREETING('MySpace.com');
8 GREETING;
9 END;
10 /
Procedure created.
SQL> EXECUTE WELCOME;
Welcome to MySpace.com
Welcome to globalguideline
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Run SQL*Plus Commands in SQL Developer? |
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | How To Create a Stored Procedure in Oracle? |
☺ | What Is Input Buffer in SQL*Plus? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |