Oracle DBMS_INTERNAL_SAFE_SCN
Version 26ai

General Information
Library Note Morgan's Library Page Header
The best Oracle News for FY2026

Oracle Database 26ai is now availble. If you haven't you downloaded already: Why?
Purpose Undocumented but appears to relate to obtaining a safe System Change Number off the stack for use with DataPump.
AUTHID CURRENT_USER
Dependencies
DBMS_INTERNAL_LOGSTDBY KUPM$MCP KUPW$WORKER
DBMS_STREAMS_DATAPUMP    
Documented No
First Available Not known
Security Model Owned by SYS with EXECUTE granted to the EXECUTE_CATALOG_ROLE and LOGSTDBY ADMINISTRATOR roles
Source {ORACLE_HOME}/rdbms/admin/prvtlsss.plb
Subprograms
 
GET_EXPORT_DML_SCN
Undocumented dbms_internal_safe_scn.get_export_dml_scn(
schema        IN VARCHAR2,
tablename     IN VARCHAR2,
cookie        IN VARCHAR2,
flashback_scn IN NUMBER)
RETURN NUMBER;
TBD
 
MATCHED_PRIMARY
Returns 1 if the DBID is valid for the primary database dbms_internal_safe_scn.matched_primary(dbid IN NUMBER)RETURN NUMBER;
SELECT dbid, current_scn
FROM v$database;

       DBID CURRENT_SCN
----------- -----------
 1405253007   228637960


SELECT dbms_internal_safe_scn.matched_primary(428676178);

DBMS_INTERNAL_SAFE_SCN.MATCHED_PRIMARY(228638000)
-------------------------------------------------
                                                0
 
NEED_SCN
Undocumented dbms_internal_safe_scn.need_scn(
dblink        IN     VARCHAR2,
dbversion     IN     VARCHAR2,
compatibility IN     VARCHAR2,
interest         OUT BOOLEAN,
cookie        IN OUT VARCHAR2);
-- this test seems to indicate that this must be run from within a datapump job
DECLARE
 b BOOLEAN;
 c VARCHAR2(200) := 'TEST';
BEGIN
  dbms_internal_safe_scn.need_scn('','23.0.0.0','23.4.0', b, c);
  dbms_output.put_line(c);
END;
/
*
ORA-31623: a job is not attached to this session via the specified handle
 
SET_EXPORT_SCN
Undocumented dbms_internal_safe_scn.set_export_scn(
schema          IN VARCHAR2,
name            IN VARCHAR2,
type            IN VARCHAR2,
cookie          IN VARCHAR2,
SCN             IN NUMBER,
original_schema IN VARCHAR2,
original_name   IN VARCHAR2);
TBD
 
SET_SESSION_STATE
Undocumented dbms_internal_safe_scn.set_session_state(cookie IN VARCHAR2);
exec dbms_internal_safe_scn.set_session_state('TEST');

PL/SQL procedure successfully completed.
 
WAIT_FOR_SAFE_SCN
Returns the next, safe, SCN based above the current SCN dbms_internal_safe_scn.wait_for_safe_scn(
schema    IN VARCHAR2,
tablename IN VARCHAR2,
timeout   IN VARCHAR2,
scn       IN NUMBER,
dbid      IN NUMBER)
RETURN NUMBER;
SELECT current_scn
FROM v$database;

CURRENT_SCN
-----------
   18766958


DECLARE
 retVal NUMBER;
BEGIN
  retVal := dbms_internal_safe_scn.wait_for_safe_scn('UWCLASS', 'SERVERS', '1', 1, 1405253007);
  dbms_output.put_line(TO_CHAR(retVal));
END;
/
228638304

PL/SQL procedure successfully completed.

Related Topics
Built-in Functions
Built-in Packages
DBMS_INTERNAL_LOGSTDBY
What's New In 21c
What's New In 26ai

Morgan's Library Page Footer
This site is maintained by Daniel Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2026 Daniel A. Morgan All Rights Reserved