GLOBAL TEMPORARY Table in Oracle



--====================================================
--GLOBAL TEMPORARY Table in Oracle with ON COMMIT PRESERVE ROWS
--====================================================

CREATE GLOBAL TEMPORARY TABLE XXSD_ON_COMMIT_DEL_ROW_TL
(
EMP_NO  NUMBER,
EMP_NAME      VARCHAR2(240 BYTE),
GRADE             VARCHAR2(240 BYTE),
SAL         NUMBER,
  CREATION_DATE                DATE             DEFAULT SYSDATE,
  LAST_UPDATE_DATE          DATE             DEFAULT SYSDATE,
  CREATED_BY                      NUMBER,
  LAST_UPDATED_BY             NUMBER
)
ON COMMIT PRESERVE ROWS

--==========  SESSION - 1 ========

select * from XXSD_ON_COMMIT_PRESE_ROW_TL

COMMIT;


insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '101','SESSION-1','L1','10000');

insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '102','SESSION-1','L2','20000');


--==========  SESSION- 2========

select * from XXSD_ON_COMMIT_PRESE_ROW_TL


insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '201','SESSION-2','L1','10000');

insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '202','SESSION-2','L2','20000');


COMMIT;


--==========  SESSION- 3 ========

select * from XXSD_ON_COMMIT_PRESE_ROW_TL

insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '301','SESSION-3','L1','10000');

insert into  XXSD_ON_COMMIT_PRESE_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '301','SESSION-3','L2','20000');


COMMIT;


--====================================================
--GLOBAL TEMPORARY Table in Oracle with ON COMMIT DELETE ROWS
--====================================================

--==========  SESSION - 1 ========

CREATE GLOBAL TEMPORARY TABLE XXSD_ON_COMMIT_DEL_ROW_TL
(
EMP_NO  NUMBER,
EMP_NAME      VARCHAR2(240 BYTE),
GRADE             VARCHAR2(240 BYTE),
SAL         NUMBER,
  CREATION_DATE                DATE             DEFAULT SYSDATE,
  LAST_UPDATE_DATE          DATE             DEFAULT SYSDATE,
  CREATED_BY                      NUMBER,
  LAST_UPDATED_BY             NUMBER
)
ON COMMIT DELETE ROWS

--==========  SESSION - 1 ========

select * from XXSD_ON_COMMIT_DEL_ROW_TL

COMMIT;


insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '101','SESSION-1','L1','10000');

insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '102','SESSION-1','L2','20000');


--==========  SESSION- 2========

select * from XXSD_ON_COMMIT_DEL_ROW_TL


insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '201','SESSION-2','L1','10000');

insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '202','SESSION-2','L2','20000');


COMMIT;


--==========  SESSION- 3 ========

select * from XXSD_ON_COMMIT_DEL_ROW_TL

insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '301','SESSION-3','L1','10000');

insert into  XXSD_ON_COMMIT_DEL_ROW_TL (EMP_NO, EMP_NAME, GRADE, SAL) VALUES ( '301','SESSION-3','L2','20000');


COMMIT;




Comments

Popular posts from this blog

E-Text Report In Fusion | Types of E-Text reports

Supplier API's

How to pass default Parameter in cursor