Search Results g_file_ptr




Overview

AST_DEBUG_PUB is a public PL/SQL utility package in the APPS schema that provides a lightweight, file-based diagnostic logging facility for Oracle E-Business Suite release 12.1.1 and 12.2.2. Its stated purpose is to allow application and customer code to emit timestamped debug messages to an operating-system file without requiring the formal concurrent program or FND_LOG infrastructure. The package header carries the revision marker $Header: astidbgb.pls 115.4 2003/01/07 19:38:35 karamach ship $, confirming it is a long-standing shipped object rather than a customisation.

The central runtime artifact is the package variable G_FILE_PTR, a UTL_FILE file handle that is opened, written to, flushed, and closed on each logging call. Because the handle is a package-level global, its lifetime and validity are inseparable from the log file itself; this is the variable most commonly surfaced when searching for g_file_ptr in EBS source or runtime diagnostics. The package is classified as PUB, meaning its specification is a supported interface that other products may call directly.

Key Procedures and Functions

  • OPENFILE — a function that resolves the target directory and file name, then opens the log file and assigns the resulting handle to G_FILE_PTR. When no file name is supplied it derives a per-session name from v$session using the session's SID, producing a .AST file; when a file name is supplied it appends to that file. It returns the fully qualified path of the file it opened, and returns null on any error.
  • LOGMESSAGE — the primary logging entry point. It accepts a message, a debug level, and a flag controlling whether a date/time prefix is prepended. It compares the supplied level against the package debug level and, if the threshold is met, opens the file, writes the line via UTL_FILE, flushes and closes the handle, and suppresses all exceptions.
  • SETDEBUGLEVEL — establishes the debug threshold used by LOGMESSAGE. When invoked from within a running application session the effective level is taken from the profile option; when called outside that context the level is set programmatically by the caller.

Tables Accessed

The package reads three fixed views through APPS synonyms, and writes no database tables at all — all output is directed to the filesystem.

  • V$PARAMETER — queried for the utl_file_dir initialisation parameter when no directory has yet been cached. Because that parameter may hold a comma-separated list of directories, the package truncates the value at the first comma to obtain a usable single directory.
  • V$SESSION — queried by AUDIT_SID / USERENV('SESSIONID') to build the default per-session log file name, which prevents concurrent sessions from colliding on the same file.
  • UTL_FILE — the Oracle-supplied PL/SQL package used to open, write, flush, and close the operating-system file identified by G_FILE_PTR.

Usage Notes

AST_DEBUG_PUB is invoked by custom code, forms-level diagnostics, and other PL/SQL packages rather than by an end-user screen. ETRM records six packages referencing it, indicating it is embedded in shared library code and reached indirectly during normal processing. Typical invocation is to call SETDEBUGLEVEL early in a process, then bracket suspect logic with LOGMESSAGE calls at varying levels, leaving the calls in place at a high threshold so they remain dormant in production.

Two operational constraints follow from the implementation. First, the target directory must appear in utl_file_dir, because the package resolves its path from that parameter; on 12.2.x multi-node deployments this must be configured consistently on every application tier node that may execute the code. Second, the write/flush/close cycle means the file is held open only momentarily, so log output is durable immediately but incurs per-message I/O overhead — it is unsuitable for high-volume or tight-loop tracing. Because OPENFILE defaults to append mode for caller-supplied names, repeated calls accumulate output in a single file, and concurrent sessions sharing an explicitly named file may interleave lines. The blanket WHEN OTHERS THEN null handlers ensure that debug logging can never raise an error into the calling business transaction, but they also silently discard permission, directory, and file-handle failures, so an absent log file should be investigated at the database parameter and filesystem level rather than attributed to the calling program.