Understanding About Object Creation with same name | Object Overloading in PLSQL
-- FIRST Session ===================================
XXSD_TEST_FUN(PAR_1)
XXSD_TEST_FUN(PAR_1,PAR_2)
XXSD_TEST_FUN(PAR_1,PAR_1_2,PAR_3)
--=======================================
can we create DB Object with same name ?
how to use whenever it is required ?
--=======================================
---====== TABLE --==========
select * from XXMK_TEST
create table XXMK_TEST ( EMPID NUMBER, EMPNAME VARCHAR2(100) )
create table XXSD.XXMK_TEST ( EMPID NUMBER, EMPNAME VARCHAR2(100) )
create table XXMK_TEST ( EMPID NUMBER )
create table XXSD.XXMK_TEST ( EMPID NUMBER )
select * from all_objects
where object_name = 'XXMK_TEST'
edit XXMK_TEST
select * from XXMK_TEST
edit XXSD.XXMK_TEST
select * from XXSD.XXMK_TEST
---====== VIEW--==========
create or replace view XXMK_TEST as
select * from APPS.XXMK_TEST
create or replace view XXSD.XXMK_TEST as
select * from APPS.XXMK_TEST
create or replace view XXMK_TEST_V as
select * from APPS.XXMK_TEST
--drop view XXSD.XXMK_TEST
select * from all_objects
where object_name like 'XXMK_TEST%'
select * from XXMK_TEST_V
---====== SUB Program Function -==========
create or replace function XXMK_TEST RETURN NUMBER
AS
V_NUM NUMBER;
BEGIN
select 1 INTO V_NUM from dual;
RETURN V_NUM;
END;
--drop function XXMK_TEST1
select * from all_objects
where object_name = 'XXMK_TEST'
---====== SUB Program Procedure -==========
create or replace procedure XXMK_TEST
AS
V_NUM NUMBER;
BEGIN
select 1 INTO V_NUM from dual;
dbms_output.put_line (V_NUM);
END;
--drop procedure XXMK_TEST1
select * from all_objects
where object_name = 'XXMK_TEST'
--================= between Function and Procedure --===============
create or replace procedure XXMK_TEST_SUBPROGRAM
AS
V_NUM NUMBER;
BEGIN
select 1 INTO V_NUM from dual;
dbms_output.put_line (V_NUM);
END;
create or replace function XXMK_TEST_SUBPROGRAM RETURN NUMBER
AS
V_NUM NUMBER;
BEGIN
select 1 INTO V_NUM from dual;
dbms_output.put_line (V_NUM);
return V_NUM;
END;
--======================================
But when we change schema
--======================================
create or replace function XXSD.XXMK_TEST_SUBPROGRAM RETURN NUMBER
AS
V_NUM NUMBER;
BEGIN
select 1 INTO V_NUM from dual;
dbms_output.put_line (V_NUM);
return V_NUM;
END;
select * from all_objects
where object_name = 'XXMK_TEST_SUBPROGRAM'
--=========================================
can we create same subprogram with different -2 parameter same as
--=========================================
create or replace function XXMK_SUBPROGRAM ( P_PARA_1 NUMBER) RETURN NUMBER
AS
BEGIN
return P_PARA_1;
END;
create or replace function XXMK_SUBPROGRAM ( P_PARA_1 NUMBER, P_PARA_2 NUMBER) RETURN NUMBER
AS
BEGIN
return P_PARA_2;
END;
create or replace function XXMK_SUBPROGRAM ( P_PARA_1 NUMBER, P_PARA_2 NUMBER, P_PARA_3 NUMBER) RETURN NUMBER
AS
BEGIN
return P_PARA_3;
END;
--- How to use ablove all
select XXMK_SUBPROGRAM(1,2,3) from dual
select * from all_objects
where object_name = 'XXMK_SUBPROGRAM'
--=======================================
--yes we can create a function with same name in differnet schema
--=======================================
create function XXMK_SUBPROGRAM_N ( P_PARA_1 NUMBER) RETURN NUMBER
AS
BEGIN
return P_PARA_1;
END;
create function XXSD.XXMK_SUBPROGRAM_N ( P_PARA_1 NUMBER, P_PARA_2 NUMBER) RETURN NUMBER
AS
BEGIN
return P_PARA_2;
END;
--==========================================
--can we create procedure with same name or different schema
--==========================================
create or replace procedure XXMK_TEST_SUBPROGRAM ( P_PARA_1 IN NUMBER)
AS
BEGIN
dbms_output.put_line (P_PARA_1);
END;
create or replace procedure XXMK_TEST_SUBPROGRAM ( P_PARA_1 IN NUMBER, P_PARA_2 IN NUMBER)
AS
BEGIN
dbms_output.put_line (P_PARA_2);
END;
create or replace procedure XXSD.XXMK_TEST_SUBPROGRAM ( P_PARA_1 IN NUMBER, P_PARA_2 IN NUMBER,P_PARA_3 IN NUMBER)
AS
BEGIN
dbms_output.put_line (P_PARA_3);
END;
--========================================
can we create same in different schema -- NO
--========================================
Comments
Post a Comment