You are on page 1of 128

set echo off

undefine v_headerinfo
Define v_headerinfo = '$Header: OTL_Diag.sql 2.0'
undefine v_queries_ver
Define v_queries_ver = '26-Jan-2011'
undefine v_scriptlongname
Define v_scriptlongname = 'OTL Data Collection'
REM ========================================================
REM Copyright © 2007 Oracle Corporation Redwood Shores, California, USA
REM Oracle Support Services. All rights reserved.
REM ========================================================
REM PURPOSE: This is a collection of adhoc queries to get data
REM for specific issues as identified by OTL support.
REM PRODUCT: 311 - Oracle Time and Labor
REM PRODUCT VERSIONS: 11.5
REM PLATFORM: Generic
REM PARAMETERS: Parameter1: <Script Section>
REM Parameter2: dynamic by section
REM Parameter3: dynamic by section
REM =======================================================
REM USAGE: This script should be run in SQLplus in APPS Schema
REM and only at the request of OTL support.
REM EXAMPLE: in the SQL prompt execute :SQL>@c:\filepath\OTL_Diag.sql
REM OUTPUT: The output will be spooled to a dynamic filename based on
REM the parameters used. eg... OTL_vish_otl11i_0_0.html
REM =======================================================
REM ==============SQL PLUS Environment setup===================
set serveroutput on size 1000000
set autoprint off
set verify off
set echo off
REM ============== Define SQL Variables for input parameters =============
undefine v_date
undefine v_nls
undefine v_version
clear columns
variable v_nls varchar2(50);
variable v_version varchar2(17);
set head off feedback off
--Verify RDBMS version
DECLARE
BEGIN
select max(version)
into :v_version
from v$instance;
:v_version := substr(:v_version,1,9);
if :v_version < '8.1.6.0.0' and :v_version > '4' then
dbms_output.put_line(chr(10));
dbms_output.put_line('RDBMS Version = '||:v_version);
dbms_output.put_line('ERROR - The Script requires RDBMS version 8.1.6 or highe
r');
dbms_output.put_line('ACTION - Type Ctrl-C <Enter> to exit the script.');
dbms_output.put_line(chr(10));
end if;
exception
when others then
dbms_output.put_line(chr(10));
dbms_output.put_line('ERROR - RDBMS Version error: '|| sqlerrm);
dbms_output.put_line('ACTION - Please report the above error to Oracle Suppo
rt Services.' || chr(10) ||
' Type Ctrl-C <Enter> to exit the script.');
dbms_output.put_line(chr(10));
END;
/
--Verify NLS Character Set
DECLARE
BEGIN
select value
into :v_nls
from v$nls_parameters
where parameter = 'NLS_CHARACTERSET';
if :v_version < '8.1.7.4.0' and :v_version > '4' and :v_nls = 'UTF8' then
dbms_output.put_line(chr(10));
dbms_output.put_line('RDBMS Version = '||:v_version);
dbms_output.put_line('NLS Character Set = '||:v_nls);
dbms_output.put_line('ERROR - The HTML functionality of this script is incompa
tible with this Character Set for RDBMS version 8.1.7.3 and lower');
dbms_output.put_line('ACTION - Please report the above error to Oracle Support
Services.');
dbms_output.put_line(chr(10));
end if;
exception
when others then
dbms_output.put_line(chr(10));
dbms_output.put_line('ERROR - NLS Character Set error: '|| sqlerrm);
dbms_output.put_line('ACTION - Please report the above error to Oracle Suppo
rt Services.' || chr(10) ||
' Type Ctrl-C <Enter> to exit the script.' ||
chr(10) );
dbms_output.put_line(chr(10));
END;
/
REM ============ Get the Date ====================
set pagesize 200
set term off
--Get the Date and Time
COLUMN TODAY NEW_VALUE v_date
SELECT TO_CHAR(SYSDATE, 'MMDDHH24MI') TODAY
from sys.dual;
set term on
set head on feedback on
-- *****************************************************************************
**********************
-- *****************************************************************************
**********************
--undefine 1
Prompt Enter Parameter 1:
set termout off
Prompt &&1
set termout on
--undefine 2
Prompt Enter Parameter 2:
set termout off
Prompt &&2
set termout on
--undefine 3
Prompt Enter Parameter 3:
set termout off
Prompt &&3
set termout on
-- *****************************************************************************
**********************
-- *****************************************************************************
**********************
REM ============ Spooling the output file====================
Prompt
Prompt Running...
Prompt
set termout off
undefine l_instance_name
undefine outputfilename
--define outputfilename = OTL_Diag_&1._&2._diag.html -- OTL_Diag._&v_date._diag
.html
define l_instance_name = ''
column linstancename new_value l_instance_name
select substr(rpad(value,4,'_'),1,4) linstancename from v$parameter where name =
'db_name';
define outputfilename = ''
column outputfilename new_value outputfilename
select substr(replace(replace(replace(replace(replace(replace(replace(replace('O
TL_&&l_instance_name._&&1._&&2._&&3','.','_'),'+','_'),'$','_'),' ','_'),'~','_'
),'%','_'),'/','_'),'-','_'),1,25) || '.html' outputfilename from dual;
spool &outputfilename
set termout on
REM ================= Pl/SQL api start ========================================
set termout off
prompt <html lang="en,us"><head><!--
REM $Header: CoreApiHtml.sql 1.31.2 24-NOV-2003 support $
REM +=========================================================================+
REM | Copyright (c) 2001 Oracle Corporation Belmont, California, USA |
REM | All rights reserved. |
REM +=========================================================================+
REM ##########################################################################
REM PURPOSE: PLSQL API
REM PROGRAM: CoreApiHtml.sql
REM NOTE: No Note to Associate
REM CONFIG: support.cfg, Requires files to source (.env) and Passwords.
REM USAGE: API only, included in others as: @CoreApiHtml
REM FRAMEWORK: SDF OHS
REM PRODUCT_VER: 11.5.X
REM PRODUCT_CODE: 510
REM SUBCOMPONENT: FND
REM NODE: WEB
REM PARAMS: NONE
REM
REM ##########################################################################
REM ##########################################################################
REM Change History
REM 05-JUN-2002 ALUMPE Modified Display_SQL so that headers print only
REM if rows are returned
REM 02-JUL-2002 ALUMPE 1) Added Column_Exists API
REM 2) Added Show_Invalids API
REM 3) Added Feedback option and Number of rows option
REM To Run_SQL and Display_SQL API's
REM 4) Modified Get_DB_Patch_List to give appropriate
REM feedback if no rows retrieved
REM 5) Added CheckFinPeriod API
REM 6) Added CheckKeyFlexfield API
REM 7) Fixed font inconsistencies with Tab0Print
REM 05-AUG-2002 ALUMPE Added Init_Block and End_Block API's to enable
REM multi-block script without reprinting header info
REM 14-AUG-2002 ALUMPE Added NoticePrint API.
REM 30-AUG-2002 ALUMPE Modified Display_profiles to use the _VL views
REM rather than the _TL tables with a language condition
REM as userenv('LANG') = 'US' but language = 'AMERICAN'
REM on some 10.7 instances
REM 07-NOV-2002 ALUMPE Modified Display_SQL/Run_SQL to allow for indenting
REM of the table output.
REM 06-DEC-2002 ALUMPE Modified Display_SQL to convert chr(10) to html
REM <BR> in text values
REM 02-JAN-2003 ALUMPE Modified Display_SQL to fix bug with dates displaying
REM in DD-MON- format on certain DB versions.
REM 05-FEB-2003 ALUMPE Modified Compare_Pkg_Version to handle branched
REM code versions
REM 17-FEB-2003 ALUMPE Fixed bug in ActionWarningLink "spanclass" corrected
REM to "span class" to get correct text color.
REM 26-FEB-2003 ALUMPE Fixed issue with Show_Invalids. Error storing
REM variable was not being initialized for each object
REM 08-APR-2003 ALUMPE Modified CheckProfile to act like java api
REM Added parameter to include filename in
REM get_package_version/spec/body apis
REM Added global variable to control date format in SQL
REM 17-JUN-2003 ALUMPE Removed unused code and simplified display_sql
REM additionally added check to remove chr(0) where
REM found in text columns.
REM 20-NOV-2003 CMDRAKE Modified Display_SQL so that headers longer than 10
REM characters are broken at underscores
REM 21-NOV-2003 IGOVAERT Modified Display_SQL so that headers do not always
REM appear in InitCap
REM Modified Display_sql/Run_sql to allow to create a
REM See SQL link
REM ##########################################################################
REM Procedures/Functions Implemented
REM ActionErrorPrint()
REM ActionPrint()
REM ActionWarningPrint()
REM Begin_Pre()
REM BRPrint()
REM CheckFinPeriod()
REM CheckKeyFlexfield()
REM CheckProfile()
REM Column_Exists()
REM Compare_Pkg_Version()
REM Display_Profiles()
REM Display_SQL()
REM Display_Table()
REM End_Pre()
REM ErrorPrint()
REM Get_DB_Apps_Version()
REM Get_DB_Patch_List()
REM Get_Package_Body()
REM Get_Package_Spec()
REM Get_Package_Version()
REM Get_Profile_Option()
REM Get_RDBMS_Header()
REM Insert_HTML()
REM Insert_Style_Sheet()
REM NoticePrint()
REM Run_SQL()
REM SectionPrint()
REM Send_Email()
REM Set_Client()
REM Set_Org()
REM Show_Header()
REM Show_Invalids()
REM Show_Link()
REM Show_Table()
REM Tab0Print()
REM Tab1Print()
REM Tab2Print()
REM Tab3Print()
REM WarningPrint()
REM
REM Procedures/Functions Removed
REM BlackPrint() - 508 Compatibility
REM BluePrint() - 508 Compatibility
REM GreenPrint() - 508 Compatibility
REM Plain_SectionPrint() - Same as ActionPrint()
REM RedPrint() - 508 Compatibility
REM Steps_Results() - Standards Modification
REM SuccessPrint() - Same as Tab1Print()
REM
REM Functions to possibly implement
REM Compare_SQL_Data()
REM Execute_URL()
REM Validate_Apps_User()
REM
set serveroutput on size 1000000
set feedback off
set verify off
set echo off
set long 2000000000
set linesize 32767
set longchunksize 32767
set pagesize 0
set timing off
set trimout on
set trimspool on
set heading off
set autoprint on
undefine nbsp
define nbsp = ''
column lnbsp new_value nbsp noprint
select chr(38) || 'nbsp' lnbsp from dual;
undefine p_id
define p_id = ''
column lp_id new_value p_id noprint
select chr(38) || 'p_id' lp_id from dual;
undefine lt
define lt = ''
column llt new_value lt noprint
select chr(38) || 'lt' llt from dual;
undefine gt
define gt = ''
column lgt new_value gt noprint
select chr(38) || 'gt' lgt from dual;
undefine AMPER
define AMPER = ''
column lAMPER new_value AMPER noprint
select chr(38) lAMPER from dual;
undefine T_VARCHAR2
undefine T_ROWID
undefine T_NUMBER
undefine T_LONG
undefine T_DATE
undefine T_CHAR
undefine T_CLOB
variable g_hold_output clob;
declare
counter number := 0;
failures number := 0;
g_curr_loc number := 1;
/* Global defaults for SQL output formatting */
g_sql_date_format varchar2(100) := 'DD-MON-YYYY HH24:MI';
/* Global variables set by Set_Client which can be used throughout a script */
g_user_id number;
g_resp_id number;
g_appl_id number;
g_org_id number;
/* Global variable set by Set_Client or Get_DB_Apps_Version which can
be referenced in scripts which branch based on applications release */
g_appl_version varchar2(10);
type V2T is table of varchar2(32767);

procedure line_out (text varchar2) is


l_ptext varchar2(32767);
l_hold_num number;
begin
l_hold_num := mod(g_curr_loc, 32767);
if l_hold_num + length(text) > 32759 then
l_ptext := '<!--' || rpad('*', 32761-l_hold_num,'*') || '-->';
dbms_lob.write(:g_hold_output, length(l_ptext), g_curr_loc, l_ptext);
g_curr_loc := g_curr_loc + length(l_ptext);
end if;
dbms_lob.write(:g_hold_output, length(text)+1, g_curr_loc, text || chr(10));
g_curr_loc := g_curr_loc + length(text)+1;
end line_out;

-- Procedure Name: Insert_Style_Sheet


--
-- Usage:
-- Insert_Style_Sheet;
--
-- Output:
-- Inserts a Style Sheet into the output
--
-- Comments:
-- This is not normally needed as the style sheet is automatically
-- inserted with the header.
--
procedure Insert_Style_Sheet is
begin
line_out('<STYLE TYPE="text/css">');
line_out('<!--');
line_out('.ind1 {margin-left: .25in}');
line_out('.ind2 {margin-left: .50in}');
line_out('.ind3 {margin-left: .75in}');
line_out('.tab0 {font-size: 10pt; font-weight: normal}');
line_out('.tab1 {text-indent: .25in; font-size: 10pt; font-weight: normal}');
line_out('.tab2 {text-indent: .5in; font-size: 10pt; font-weight: normal}');
line_out('.tab3 {text-indent: .75in; font-size: 10pt; font-weight: normal}');
line_out('.error {color: #cc0000; font-size: 10pt; font-weight: normal}');
line_out('.errorbold {font-weight: bold; color: #cc0000; font-size: 10pt}');
line_out('.warning {font-weight: normal; color: #336699; font-size: 10pt}');
line_out('.warningbold {font-weight: bold; color: #336699; font-size: 10pt}')
;
line_out('.notice {font-weight: normal; font-style: italic; color: #663366; f
ont-size: 10pt}');
line_out('.noticebold {font-weight: bold; font-style: italic; color: #663366;
font-size: 10pt}');
line_out('.section {font-weight: normal; font-size: 10pt}');
line_out('.sectionbold {font-weight: bold; font-size: 14pt}');
line_out('.BigPrint {font-weight: bold; font-size: 14pt}');
line_out('.SmallPrint {font-weight: normal; font-size: 8pt}');
line_out('.BigError {color: #cc0000; font-size: 12pt; font-weight: bold}');
line_out('.code {font-weight: normal; font-size: 8pt; font-family: Courier Ne
w}');
line_out('body {background-color: white; font: normal 12pt Ariel;}');
line_out('table {background-color: #000000 color:#000000; font-size: 10pt; fo
nt-weight: bold; line-height:1.5; padding:2px; text-align:left}');
line_out('h1, h2, h3, h4 {color: #00000}');
line_out('h3 {font-size: 16pt}');
line_out('td {background-color: #f7f7e7; color: #000000; font-weight: normal;
font-size: 9pt; border-style: solid; border-width: 1; border-color: #CCCC99; wh
ite-space: nowrap}');
line_out('tr {background-color: #f7f7e7; color: #000000; font-weight: normal;
font-size: 9pt; white-space: nowrap}');
line_out('th {background-color: #CCCC99; color: #336699; height: 20; border-s
tyle: solid; border-width: 1; border-left-color: #f7f7e7; border-right-color: #f
7f7e7; border-top-width: 0; border-bottom-width: 0; white-space: nowrap}');
line_out('th.rowh {background-color: #CCCC99; color: #336699; height: 20; bor
der-style: solid; border-width: 1; border-top-color: #f7f7e7; border-bottom-colo
r: #f7f7e7; border-left-width: 0; border-right-width: 0; white-space: nowrap}');
line_out('-->');
line_out('</style>');
end;
-- Procedure Name: Insert_HTML
--
-- Usage:
-- Insert_HMTL('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string
--
-- Examples:
-- begin
-- Insert_HTML('<em>This can be any text you want.</em>');
-- end;
--
-- Notes:
-- Usage of this procedure may make the script not compatible with
-- standards or 508. Please avoid if possible.
--
procedure Insert_HTML(p_text varchar2) is
begin
line_out(p_text);
end Insert_HTML;
-- Procedure Name: ActionErrorPrint
--
-- Usage:
-- ActionErrorPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string with the word ACTION - prior to the string
--
-- Examples:
-- begin
-- ActionErrorPrint('Run Gather Schema Statistics');
-- end;
--
procedure ActionErrorPrint(p_text varchar2) is
begin
line_out('<span class="errorbold">ACTION - </span><span class="error">' || p
_text || '</span><br>');
end ActionErrorPrint;
-- Procedure Name: ActionPrint
--
-- Usage:
-- ActionPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string
--
-- Examples:
-- begin
-- ActionPrint('Run Gather Schema Statistics');
-- end;
--
procedure ActionPrint(p_text varchar2) is
begin
line_out(p_text || '<br>');
end ActionPrint;
-- Procedure Name: ActionWarningPrint
--
-- Usage:
-- ActionWarningPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string in warning format
--
-- Examples:
-- begin
-- ActionWarningPrint('Run Gather Schema Statistics');
-- end;
--
procedure ActionWarningPrint(p_text varchar2) is
begin
line_out('<span class="warningbold">ACTION - </span><span class="warning">'
|| p_text || '</span><br>');
end ActionWarningPrint;
-- Procedure Name: WarningPrint
--
-- Usage:
-- WarningPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string in warning format
--
-- Examples:
-- begin
-- WarningPrint('Statistics are not up to date');
-- end;
--
procedure WarningPrint(p_text varchar2) is
begin
line_out('<span class="warningbold">WARNING - </span><span class="warning">'
|| p_text || '</span><br>');
end WarningPrint;
-- Procedure Name: ActionErrorLink
--
-- Usage:
-- ActionErrorLink('Pre_String','Note_Number','Post_String');
-- ActionErrorLink('Pre_String','URL','Link_Text', 'Post_String');
--
-- Parameters:
-- Pre_String - Text to appear prior to the link
-- Note_Number - Number of a metalink note to link to
-- URL - Any valid URL
-- Link_Text - Text for the link to URL
-- Post_String - Text to appear after the link
--
-- Output:
-- Displays the pre-link string, the link (as specified either by the
-- note number or by the URL and link text), and the post-link string
-- all in the format of an Error Action
--
-- Examples:
-- begin
-- ActionErrorLink('For clarification see note', 112233.1,
-- 'which provides more information on the subject');
-- ActionErrorLink('For clarification see the',
-- 'http://someurl.us.com/somepage.html','Development Homepage',
-- 'which provides more information on the subject');
-- end;
--
procedure ActionErrorLink(p_txt1 varchar2
, p_note varchar2
, p_txt2 varchar2) is
begin
line_out('<span class="errorbold">ACTION - </span><span class="error">'
|| p_txt1
|| ' <a href="http://metalink.oracle.com/metalink/plsql/ml2_documents.s
howDocument?p_database_id=NOT&p_id='
|| p_note
|| '">'
|| p_note
|| '</a> '
|| p_txt2
|| '</span><br>');
end ActionErrorLink;
procedure ActionErrorLink(p_txt1 varchar2
, p_url varchar2
, p_link_txt varchar2
, p_txt2 varchar2) is
begin
line_out('<span class="errorbold">ACTION - </span><span class="error">'
|| p_txt1
|| ' <a href="'
|| p_url
|| '">'
|| p_link_txt
|| '</a> '
|| p_txt2
|| '</span><br>');
end ActionErrorLink;
-- Procedure Name: ActionWarningLink
--
-- Usage:
-- ActionWarningLink('Pre_String','Note_Number','Post_String');
-- ActionWarningLink('Pre_String','URL','Link_Text', 'Post_String');
--
-- Parameters:
-- Pre_String - Text to appear prior to the link
-- Note_Number - Number of a metalink note to link to
-- URL - Any valid URL
-- Link_Text - Text for the link to URL
-- Post_String - Text to appear after the link
--
-- Output:
-- Displays the pre-link string, the link (as specified either by the
-- note number or by the URL and link text), and the post-link string
-- all in the format of a Warning Action
--
-- Examples:
-- begin
-- ActionWarningLink('For clarification see note', 112233.1,
-- 'which provides more information on the subject');
-- ActionWarningLink('For clarification see the',
-- 'http://someurl.us.com/somepage.html','Development Homepage',
-- 'which provides more information on the subject');
-- end;
--
procedure ActionWarningLink(p_txt1 varchar2
, p_note varchar2
, p_txt2 varchar2) is
begin
line_out('<span class="warningbold">ACTION - </span><span class="warning">'
|| p_txt1
|| ' <a href="http://metalink.oracle.com/metalink/plsql/'
|| 'ml2_documents.showDocument?p_database_id=NOT&p_id='
|| p_note
|| '">'
|| p_note
|| '</a> '
|| p_txt2
|| '</span><br>');
end ActionWarningLink;
procedure ActionWarningLink(p_txt1 varchar2
, p_url varchar2
, p_link_txt varchar2
, p_txt2 varchar2) is
begin
line_out('<span class="warningbold">ACTION - </span><span class="warning">'
|| p_txt1
|| ' <a href="'
|| p_url
|| '">'
|| p_link_txt
|| '</a> '
|| p_txt2
|| '</span><br>');
end ActionWarningLink;
-- Procedure Name: ErrorPrint
--
-- Usage:
-- ErrorPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string
--
-- Examples:
-- begin
-- ErrorPrint('Statistics have not been run');
-- end;
--
procedure ErrorPrint(p_text varchar2) is
begin
line_out('<span class="errorbold">ERROR - </span><span class="error">' || p_
text || '</span><br>');
end ErrorPrint;
-- Procedure Name: NoticePrint
--
-- Usage:
-- NoticePrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string in italics preceded by the word 'ATTENTION - '
--
-- Examples:
-- begin
-- NoticePrint('Be alert to this information');
-- end;
--
procedure NoticePrint (p_text varchar2) is
begin
line_out('<span class="noticebold">ATTENTION - </span>'||
'<span class="notice">'||p_text||'</span><br>');
end NoticePrint;
-- Procedure Name: SectionPrint
--
-- Usage:
-- SectionPrint('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string in bold print
--
-- Examples:
-- begin
-- SectionPrint('Checking OE Parameters');
-- end;
--
procedure SectionPrint (p_text varchar2) is
begin
line_out('<br><span class="sectionbold">' || p_text || '</span><br>');
end SectionPrint;
-- Procedure Name: Tab0Print
--
-- Usage:
-- Tab0Print('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string with no indentation
--
-- Examples:
-- begin
-- Tab0Print('Layer 0');
-- end;
--
procedure Tab0Print (p_text varchar2) is
begin
line_out('<div class="tab0">' || p_text || '</div>');
end Tab0Print;
-- Procedure Name: Tab1Print
--
-- Usage:
-- Tab1Print('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string indented .25 inch
--
-- Examples:
-- begin
-- Tab1Print('Layer 1');
-- end;
--
procedure Tab1Print (p_text varchar2) is
begin
line_out('<div class="tab1">' || p_text || '</div>');
end Tab1Print;
-- Procedure Name: Tab2Print
--
-- Usage:
-- Tab2Print('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string indented .50 inch
--
-- Examples:
-- begin
-- Tab2Print('Layer 2');
-- end;
--
procedure Tab2Print (p_text varchar2) is
begin
line_out('<div class="tab2">' || p_text || '</div>');
end Tab2Print;
-- Procedure Name: Tab3Print
--
-- Usage:
-- Tab3Print('String');
--
-- Parameters:
-- String - Any text string
--
-- Output:
-- Displays the text string indented .75 inch
--
-- Examples:
-- begin
-- Tab3Print('Layer 3');
-- end;
--
procedure Tab3Print (p_text varchar2) is
begin
line_out('<div class="tab3">' || p_text || '</div>');
end Tab3Print;
-- Procedure Name: BRPrint
--
-- Usage:
-- BRPrint;
--
-- Output:
-- Displays a blank Line
--
-- Examples:
-- begin
-- Tab3Print('Layer 3');
-- BRPrint;
-- Tab3Print('Layer 4');
-- end;
--
procedure BRPrint is
begin
line_out('<br>');
end BRPrint;
-- Procedure Name: CheckFinPeriod
--
-- Usage:
-- CheckFinPeriod('Set of Books ID','Application ID');
--
-- Paramteters:
-- Set of Books ID - ID for the set of books
-- Application ID - ID of the application whose periods are being checked
--
-- Output:
-- List the number of defined and open periods. Indicate the latest
-- open period. Produce warnings if no periods are open or if the
-- current date is not in an open period.
--
-- Examples:
-- CheckFinPeriod(62, 222); -- Check open periods for AR SOB 62
-- CheckFinPeriod(202, 201); -- Check open periods for PO SOB 202
--
procedure checkFinPeriod (p_sobid NUMBER, p_appid NUMBER ) IS
l_appname VARCHAR2(50) :=NULL;
l_period_name VARCHAR2(50);
l_user_period_type VARCHAR2(50);
l_start_date DATE;
l_end_date DATE;
l_sysdate DATE;
l_sysopen VARCHAR2(1);
CURSOR C1 IS
select a.name sobname,
count(b.period_name) total_periods,
count(decode(b.closing_status,'O',b.PERIOD_NAME,null)) open_periods,
a.accounted_period_type period_type
from gl_sets_of_books a,
gl_period_statuses b
where a.set_of_books_id = b.set_of_books_id (+)
and b.application_id = p_appId
and a.set_of_books_id = p_sobId
and b.period_type = a.accounted_period_type
group by a.name, a.accounted_period_type;
c1_rec c1%rowtype;
no_rows exception;
BEGIN
select application_name
into l_appname
from fnd_application_vl
where application_id = p_appid ;
open c1;
fetch c1 into c1_rec;
IF c1%notfound THEN
raise no_rows;
END IF;
select user_period_type into l_user_period_type
from gl_period_types
where period_type = c1_rec.period_type;
Tab1Print('Set of books '|| c1_rec.sobname ||' for application '
|| l_appname || ' has ' || to_char(c1_rec.total_periods)
|| ' periods defined and '|| to_char(c1_rec.open_periods)
|| ' periods open for period type '|| l_user_period_type);
IF c1_rec.total_periods = 0 THEN
WarningPrint('There are no periods defined for this Set of books');
ActionWarningPrint('There must be periods defined for this set of books');
END IF;
IF c1_rec.open_periods = 0 THEN
WarningPrint('There are no open periods defined for this Set of books');
ActionWArningprint('Please consider opening a period for this '||
'application and set of books');
ELSE
BEGIN
SELECT period_name, start_date, end_date, sysdate
INTO l_period_name, l_start_date, l_end_date, l_sysdate
FROM gl_period_statuses
WHERE adjustment_period_flag = 'N'
AND period_type = c1_rec.period_type
AND start_date = (
SELECT MAX(start_date)
FROM gl_period_statuses
WHERE closing_status = 'O'
AND adjustment_period_flag = 'N'
AND period_type = c1_rec.period_type
AND application_id = p_appId
AND set_of_books_id = p_sobId )
AND closing_status = 'O'
AND application_id = p_appId
AND set_of_books_id = p_sobId;
/* check if sysdate is in the latest open period*/
l_sysopen := 'N';
IF l_sysdate >= l_start_date AND l_sysdate <= l_end_date THEN
l_sysOpen := 'Y';
END IF;
Tab1Print('Latest open period is '|| l_period_name
|| ' with a start date of '|| to_char(l_start_date)
|| ' and an end date of ' || to_char(l_end_date) );
IF l_sysopen = 'Y' THEN
Tab2Print('Current date '|| to_char(l_sysdate)
|| ' is in the latest open period');
ELSE
BEGIN
SELECT period_name, start_date, end_date, sysdate
INTO l_period_name, l_start_date, l_end_date, l_sysdate
FROM gl_period_statuses
WHERE adjustment_period_flag = 'N'
AND period_type = c1_rec.period_type
AND sysdate between start_date and end_date
AND closing_status = 'O'
AND application_id = p_appId
AND set_of_books_id = p_sobId;
Tab2Print('Current date '|| to_char(sysDate)
|| ' is in the open period ' || l_period_name
|| ' with a start date of ' || to_char(l_start_date)
|| ' and an end date of ' || to_char(l_end_date) );
EXCEPTION WHEN NO_DATA_FOUND THEN
WarningPrint('Current date '|| to_char(l_sysdate)
|| ' is not in an open period');
ActionwarningPrint('Please consider opening the current period');
END;
END IF;
EXCEPTION WHEN NO_DATA_FOUND THEN
/* not really possible to fall in this exception as we already
checked that there were open periods */
WarningPrint('There are no open periods defined for this Set of books');
ActionWArningprint('Please consider opening a period for this '||
'application and set of books');
END;
END IF;
EXCEPTION
WHEN NO_ROWS THEN
WarningPrint('There are no accounting periods defined in '||
'gl_period_statuses for this application and set of books');
ActionWArningprint('If required, define the accounting calendar for this '||
'application and set of books');
WHEN NO_DATA_FOUND THEN
ErrorPrint('Invalid Application id passed to checkFinPeriod');
ActionErrorPrint('Application id ' || to_char(p_appid)
|| ' is not valid on this system');
WHEN OTHERS THEN
ErrorPrint(sqlerrm||' occurred in CheckFinPeriod');
ActionErrorPrint('Report this error to your support representative');
END checkFinPeriod;

-- Function Name: CheckKeyFlexfield


-- Procedure Name: CheckKeyFlexfield
--
-- Usage:
-- CheckKeyFlexfield('Key Flex Code','Flex Structure ID','Print Header');
--
-- Parameters:
-- Key Flex Code - The code of the Key Flexfield to be displayed. For
-- example, for the Accounting Flexfield use 'GL#'.
-- Flex Structure ID - The id_flex_num of the specific structure
-- of the key flexfield whose details are to be
-- displayed. If null, print details of all
-- structures. (default NULL)
-- Print Header - A boolean (true or false) indicating whether the output
-- should print a heading before outputting the details
-- of the key flexfield. (default TRUE)
-- Returns:
-- If value has been provided for the Flex Structure ID, the function
-- will returns an array of character strings with the following structure
-- 1 name of the flexfield
-- 2 enabled flag
-- 3 frozen flag
-- 4 dynamic instert flag
-- 5 cross validation allowed flag
-- 6 number of enabled segments defined
-- 7 number of enabled segments with value sets
-- 8 Y if any segment has security otherwise N
-- If no value is passed to the parameter the function will return an
-- array will null values.:w
--
-- Output:
-- Displays key information about the flexfield, its structure, and the
-- individual flexfield segments that make it up.
--
-- Examples:
-- declare
-- flexarray V2T;
-- begin
-- CheckKeyFlexfield('GL#', 50577, true);
-- CheckKeyFlexfield('MSTK', null, false);
-- flexarray := CheckKeyFlexfield('GL#', 12345, false);
-- end;
--
Function CheckKeyFlexfield(p_flex_code in varchar2
, p_flex_num in number default null
, p_print_heading in boolean default true)
return V2T is
l_ret_array V2T := V2T(null,null,null,null,null,null,null,null);
l_no_value_sets integer := 0;
l_any_sec_enabled varchar2(1) := 'N';
l_sec_enabled varchar2(1) := 'N';
l_flex_name fnd_id_flexs.id_flex_name%type;
l_counter integer := 0;
l_counter2 integer := 0;
l_num_segs integer := 0;
l_num_segs_vs integer := 0;
l_rule_count integer := 0;
l_rule_assign_count integer := 0;
l_value_set_str varchar2(400);
leave_api exception;
cursor get_structs (p_f_code varchar2, p_f_num number) is
select id_flex_num flex_str_num,
id_flex_structure_name flex_str_name,
to_char(last_update_date,'DD-MON-YYYY HH24:MI:SS') last_updated,
cross_segment_validation_flag cross_val,
dynamic_inserts_allowed_flag dyn_insert,
enabled_flag enabled,
freeze_flex_definition_flag frozen
from fnd_id_flex_structures_vl
where id_flex_code = p_f_code
and enabled_flag ='Y'
and id_flex_num = nvl(p_f_num,id_flex_num);
cursor get_segments (p_f_code varchar2, p_f_num number) is
select s.application_column_name col_name,
s.segment_name seg_name,
s.segment_num seg_num,
s.enabled_flag enabled,
s.required_flag required,
s.display_flag displayed,
s.flex_value_set_id value_set_id,
vs.flex_value_set_name value_set_name,
DECODE(vs.validation_type,
'I', 'Independent', 'N', 'None', 'D', 'Dependent',
'U', 'Special', 'P', 'Pair', 'F', 'Table',
'X', 'Translatable Independent', 'Y', 'Translatable Dependent',
vs.validation_type) validation_type,
s.security_enabled_flag seg_security,
nvl(vs.security_enabled_flag,'N') value_set_security
from fnd_id_flex_segments_vl s, fnd_flex_value_sets vs
where s.flex_value_set_id = vs.flex_value_set_id (+)
and s.id_flex_code = p_f_code
and s.id_flex_num = p_f_num
order by s.segment_num ;
cursor get_qualifiers(p_f_code varchar2, p_f_num number, p_col_name varchar2) is
select segment_prompt
from fnd_segment_attribute_values sav,
fnd_segment_attribute_types sat
where sav.attribute_value = 'Y'
and sav.segment_attribute_type <> 'GL_GLOBAL'
and sav.application_id = sat.application_id
and sav.id_flex_code = sat.id_flex_code
and sav.segment_attribute_type = sat.segment_attribute_type
and sav.id_flex_code = p_f_code
and sav.id_flex_num = p_f_num
and sav.application_column_name = p_col_name;
begin
begin
select id_flex_name into l_flex_name
from fnd_id_flexs
where id_flex_code = p_flex_code;
exception when no_data_found then
WarningPrint('ID Flex Code passed '||p_flex_code||' is not valid on this '||
'system');
ActionWarningPrint('ID Flex Code '||p_flex_code||' will not be tested');
end;
BRPrint;
if p_flex_num is null then
if (p_print_heading) then
SectionPrint('Details of Key flexfield: '||l_flex_name);
else
Tab0Print('Key flexfield: '||l_flex_name);
end if;
else
l_ret_array(1) := l_flex_name;
if (p_print_heading) then
SectionPrint('Details of Key flexfield: '||l_flex_name
||' with id_flex_num '||to_char(p_flex_num));
else
Tab0Print('Key flexfield: '||l_flex_name||' with id_flex_num '
|| to_char(p_flex_num));
end if;
end if;
l_counter := 0;
for str in get_structs(p_flex_code, p_flex_num) loop
l_counter := l_counter + 1;
if p_flex_num is not null then
l_ret_array(2) := str.enabled;
l_ret_array(3) := str.frozen;
l_ret_array(4) := str.dyn_insert;
l_ret_array(5) := str.cross_val;
end if;
if l_counter > 1 then
BRPrint;
end if;
Tab1Print('Structure '||str.flex_str_name||' (ID='||
to_char(str.flex_str_num) ||')');
Tab1Print('Enabled Flag = '||str.enabled||', Frozen = '||str.frozen
||', Dynamic Inserts = '||str.dyn_insert||', Cross Validation Allowed = '
||str.cross_val||', Last Updated '||str.last_updated);

l_counter2 := 0;
l_num_segs := 0;
l_num_segs_vs := 0;
for seg in get_segments(p_flex_code, str.flex_str_num) loop
if l_counter2 = 0 then
Tab1Print('Segment Details for '||str.flex_str_name);
BRPrint;
end if;
l_counter2 := l_counter2 + 1;
if (p_flex_num is not null) then
if seg.enabled = 'Y' then
l_num_segs := l_num_segs + 1;
if (seg.value_set_id is not null) then
l_num_segs_vs := l_num_segs_vs + 1;
end if;
end if;
end if;
l_sec_enabled := 'N';
if (seg.seg_security = 'Y' and seg.value_set_security in ('Y','H')) then
l_any_sec_enabled := 'Y';
l_sec_enabled := 'Y';
end if;
if (seg.value_set_id is not null) then
l_value_set_str := ', Value Set = '||seg.value_set_name||
', Value Set Type = '||seg.validation_type;
else
l_value_set_str := ' with no value set assigned';
end if;
Tab2Print('Segment Name = '||seg.seg_name);
Tab2Print('Enabled = '||seg.enabled||', Displayed = '||
seg.displayed||l_value_set_str);
for qual in get_qualifiers(p_flex_code,str.flex_str_num,seg.col_name) loop
Tab3Print('Qualifier '||qual.segment_prompt||' is assigned to '||
'segment '|| seg.seg_name);
end loop;
if l_sec_enabled = 'Y' then
select count(*) into l_rule_count
from fnd_flex_value_rules_vl
where flex_value_set_id = seg.value_set_id;
select count(*) into l_rule_assign_count
from fnd_flex_value_rules_vl r,
fnd_flex_value_rule_usages ru
where r.flex_value_rule_id = ru.flex_value_rule_id
and r.flex_value_set_id = seg.value_set_id;
Tab3Print('Security is enabled for this segment and value set with '||
to_char(l_rule_count)||' rules defined and '||
to_char(l_rule_assign_count)||' rule assignments');
end if;
end loop;
if (p_flex_num is not null) then
l_ret_array(6) := to_char(l_num_segs);
l_ret_array(7) := to_char(l_num_segs_vs);
l_ret_array(8) := l_any_sec_enabled;
end if;
if l_counter2 = 0 then
ErrorPrint('There are no segments defined for this structure');
ActionErrorPrint('Please enable or define at least one segment for '||
str.flex_str_name);
end if;
end loop;
if l_counter = 0 then
if p_flex_num is null then
ErrorPrint('There are no Key Flexfields enabled for ' || p_flex_code);
ActionErrorPrint('Please enable or define a Key Flexfield for ' ||
p_flex_code);
else
ErrorPrint('The requested flexfield structure (ID_FLEX_NUM='||
to_char(p_flex_num)||') is inactive or does not exist');
ActionErrorPrint('Verify that the flexfield structure is defined '||
'and enabled for Key Flexfield '||p_flex_code);
end if;
end if;
return l_ret_array;
exception
when leave_api then
return l_ret_array;
end CheckKeyFlexfield;
procedure CheckKeyFlexfield(p_flex_code in varchar2
, p_flex_num in number default null
, p_print_heading in boolean default true) is
dummy_v2t V2T;
begin
dummy_v2t := CheckKeyFlexfield(p_flex_code, p_flex_num, p_print_heading);
end CheckKeyFlexfield;
-- Function/Procedure Name: CheckProfile
--
-- Usage:
-- CheckProfile('Profile Name', UserID, ResponsibilityID,
-- ApplicationID, 'Default Value', Indent Level, Align At,
-- 'Error Flag');
--
-- Parameters:
-- Profile Name - System name of the profile option being checked
-- UserID - The identifier of that applications user for which the
-- profile option is to be checked.
-- ResponsibilityID - The identifier of the responsibility for which
-- the profile option is to be checked
-- ApplicationID - The identifier of the application for which the profile
-- option is to be checked
-- Default Value - The value that will be used as a default if the profile
-- option is not set by the users (Default=NULL)
-- Indent Level - Number of tabs (0,1,2,3) that output should be indented
-- (Default=0)
-- Align At - Not used in HTML API's. Only present for consistency
-- with text API's where this will place the '=' at the
-- indicated character position from the beginning of the
-- text.
-- Error Flag - 'E', 'W', or 'N' to indicate if a profile that is not set
-- should produce an error, a warning, or neither. (default=E)
--
-- Returns:
-- If called as a function the return value will be either --
-- 1 the value of the profile option if set
-- 2 'DOESNOTEXIST' if the profile option does not exist
-- 3 'DISABLED' if the profile option has been end dated
-- 4 null if the profile option is not set
-- Output:
-- If the profile is set, displays its current setting. Else indicates
-- whether the option does not exist, is not active, or is not set.
-- If the profile option is not set the error flag indicates whether a
-- warning or error should be printed as well.
-- Examples:
-- declare
-- profile_val fnd_profile_option_values.profile_option_value%type;
-- begin
-- profile_val := CheckProfile('PA_SELECTIVE_FLEX_SEG',g_user_id,
-- g_resp_id, g_appl_id, null, 1, 0, 'W');
-- CheckProfile('PA_DEBUG_MODE',g_user_id, g_resp_id, g_appl_id);
-- CheckProfile('PA_DEBUG_MODE',g_user_id, g_resp_id, g_appl_id,'Y',2,
-- 45,'E');
-- end;
--
function CheckProfile(p_prof_name in varchar2
, p_user_id in number
, p_resp_id in number
, p_appl_id in number
, p_default in varchar2 default null
, p_indent in integer default 0
, p_align_at in integer default 0
, p_error in varchar2 default 'E')
return varchar2 is
l_user_prof_name fnd_profile_options_tl.user_profile_option_name%type;
l_prof_value fnd_profile_option_values.profile_option_value%type;
l_start_date date;
l_end_date date;
l_opt_defined boolean;
l_output_txt varchar2(500);
begin
begin
select user_profile_option_name,
nvl(start_date_active,sysdate-1),
nvl(end_date_active,sysdate+1)
into l_user_prof_name, l_start_date, l_end_date
from fnd_profile_options_vl
where profile_option_name = p_prof_name;
exception
when no_data_found then
l_prof_value := 'DOESNOTEXIST';
l_output_txt := p_prof_name||' does not exist.';
when others then
ErrorPrint(sqlerrm||' occured while getting profile option '||
'information');
ActionErrorPrint('Report the above information to Oracle '||
'Support Services');
return(null);
end;
if (nvl(l_prof_value,'X') != 'DOESNOTEXIST' and
((sysdate < l_start_date) or (sysdate > l_end_date))) then
l_prof_value := 'DISABLED';
l_output_txt := l_user_prof_name||' is not active.';
end if;
if (nvl(l_prof_value,'X') not in ('DOESNOTEXIST','DISABLED')) then
fnd_profile.get_specific(p_prof_name, p_user_id, p_resp_id, p_appl_id,
l_prof_value, l_opt_defined);
if not l_opt_defined then
l_prof_value := null;
end if;
if l_prof_value is null then
if p_default is null then
l_output_txt := l_user_prof_name||' is not set.';
else
l_output_txt := l_user_prof_name||' is not set, but defaults to '||
p_default;
end if;
else
l_output_txt := l_user_prof_name||' = "'||l_prof_value||'"';
end if;
end if;
if p_indent = 1 then
Tab1Print(l_output_txt);
elsif p_indent = 2 then
Tab2Print(l_output_txt);
elsif p_indent = 3 then
Tab3Print(l_output_txt);
else
Tab0Print(l_output_txt);
end if;
if l_prof_value is null and p_error = 'E' then
ErrorPrint(l_user_prof_name || ' profile option is not set');
ActionErrorPrint('Please set the profile option according to '||
'the product user manual');
elsif l_prof_value is null and p_error = 'W' then
WarningPrint(l_user_prof_name || ' profile option is not set');
ActionWarningPrint('Please set the profile option according to '||
'the product user manual');
end if;
return(l_prof_value);
exception when others then
ErrorPrint(sqlerrm||' occured in CheckProfile');
ActionErrorPrint('Please report this error to your support representative');
end CheckProfile;
procedure CheckProfile(p_prof_name in varchar2
, p_user_id in number
, p_resp_id in number
, p_appl_id in number
, p_default in varchar2 default null
, p_indent in integer default 0
, p_align_at in integer default 0
, p_error in varchar2 default 'E' ) is
l_dummy_prof_value fnd_profile_option_values.profile_option_value%type;
begin
l_dummy_prof_value := CheckProfile(p_prof_name, p_user_id, p_resp_id,
p_appl_id, p_default, p_indent, p_align_at, p_error);
end CheckProfile;
-- Function Name: Column_Exists
--
-- Usage:
-- Column_Exists('Table Name','Column Name');
--
-- Paramteters:
-- Table Name - Table in which to check for the column
-- Column Name - Column to check
--
-- Returns:
-- 'Y' if the column exists in the table, 'N' if not.
--
-- Example:
-- declare
-- sqltxt varchar2(1000);
-- begin
-- if Column_Exists('PA_IMPLEMENTATIONS_ALL','UTIL_SUM_FLAG') = 'Y' then ;
-- sqltxt := sqltxt||' and i.util_sum_flag is not null';
-- end if;
-- end;
--
function Column_Exists(p_tab in varchar, p_col in varchar) return varchar2 is
l_counter integer:=0;
begin
select count(*) into l_counter
from all_tab_columns
where table_name = upper(p_tab)
and column_name = upper(p_col);
if l_counter > 0 then
return('Y');
else
return('N');
end if;
exception when others then
ErrorPrint(sqlerrm||' occured in Column_Exists');
ActionErrorPrint('Report this information to your support analyst');
raise;
end Column_Exists;
-- Procedure Name: Begin_Pre
--
-- Usage:
-- Begin_Pre;
--
-- Output:
-- Allows the following output to be preformatted
--
-- Examples:
-- begin
-- Begin_Pre;
-- end;
--
procedure Begin_Pre is
begin
line_out('<pre>');
end Begin_Pre;
-- Procedure Name: End_Pre
--
-- Usage:
-- End_Pre;
--
-- Output:
-- Closes the Begin_Pre procedure
--
-- Examples:
-- begin
-- End_Pre;
-- end;
--
procedure End_Pre is
begin
line_out('</pre>');
end End_Pre;

procedure Show_Table(p_type varchar2, p_values V2T, p_caption varchar2 default n


ull, p_options V2T default null,
p_valuesN V2T default null/*jsh added*/, p_null varchar2 default 'Y'/*jsh added*
/,p_spaces varchar2 default 'Y'/*jsh added*/ ) is
l_hold_option varchar2(500);
l_continue varchar2(1) := 'N';
v_describe varchar2(1);
begin
if upper(p_type) in ('START','TABLE') then
if p_caption is null then
line_out('<table cellspacing=0>');
else
line_out('<br><table cellspacing=0 summary="' || p_caption || '">');
end if;
end if;
if upper(p_type) in ('TABLE','ROW', 'HEADER') then
line_out('<tr>');
for i in 1..p_values.COUNT loop
----> jsh added for null columns
if p_valuesN is not null then
if p_valuesN(i) is not null then
l_continue := 'Y';
end if;
end if;
----> jsh added for null columns

if (l_continue = 'Y' and p_values(i) is not null) or p_null = 'Y' or p_valuesN i


s null then ----> jsh added for null columns and show spaces
--if p_values(i) is not null or (p_values(i) is null and p_null = 'Y') then ---
-> jsh added for null columns and show spaces

if p_options is not null then


l_hold_option := ' ' || p_options(i);
end if;
if p_values(i) = '&nbsp;'
or p_values(i) is null then
if upper(p_type) = 'HEADER' then
line_out('<th id=' || i || '>&nbsp;</th>');
else
line_out('<td headers=' || i || '>&nbsp;</td>');
end if;
else
if upper(p_type) = 'HEADER' then
line_out('<th' || l_hold_option || ' id=' || i || '>' || p_values
(i) || '</th>');
else
if p_spaces = 'Y' then
begin
if p_values(i) - p_values(i) = 0 then
v_describe := 'Y';
end if;
exception when others then
v_describe := 'N';
end;
if v_describe = 'Y' then
line_out('<td' || l_hold_option || ' headers=' |
| i || '>' || p_values(i) || '</td>');
else
line_out('<td' || l_hold_option || ' headers=' |
| i || '>' || p_values(i) || '</td>');
end if;
else
line_out('<td' || l_hold_option || ' headers=' || i || '
>' || p_values(i) || '</td>');
end if;
end if;
end if;
end if; ----->jsh added for null columns and show spaces
l_continue := 'N';
end loop;
line_out('</tr>');
end if;
if upper(p_type) in ('TABLE','END') then
line_out('</TABLE>');
end if;
end Show_Table;

procedure Show_Table(p_values V2T) is


begin
Show_Table('TABLE',p_values);
end Show_Table;
procedure Show_Table(p_type varchar2) is
begin
Show_Table(p_type,null);
end Show_Table;
procedure Show_Table_Row(p_values V2T, p_options V2T default null,
p_valuesN V2T default null/*jsh added*/, p_null varchar2 default 'Y'/*jsh added*
/, p_spaces varchar2 default 'N'/*jsh added*/) is
begin
Show_Table('ROW', p_values, null, p_options, p_valuesN/*jsh added*/, p_null/*
jsh added*/, p_spaces/*jsh added*/);
end Show_Table_Row;
procedure Show_Table_Header(p_values V2T, p_options V2T default null,
p_valuesN V2T default null/*jsh added*/, p_null varchar2 default 'Y'/*jsh added*
/, p_spaces varchar2 default 'N'/*jsh added*/) is
begin
Show_Table('HEADER', p_values, null, p_options, p_valuesN/*jsh added*/, p_nul
l/*jsh added*/, p_spaces);
end Show_Table_Header;
procedure Start_Table (p_caption varchar2 default null) is
begin
Show_Table('START',null, p_caption);
end Start_Table;
procedure End_Table is
begin
Show_Table('END',null);
end End_Table;
-- Function Name: Display_SQL
--
-- Usage:
-- a_number := Display_SQL('SQL statement','Name for Header','Long Flag',
-- 'Feedback','Max Rows','Indent Level', 'Show sql' );
--
-- Parameters:
-- SQL Statement - Any valid SQL Select Statement
-- Name for Header - Text String to for heading the output
-- Long Flag - Y or N - If set to N then this will not output
-- any LONG columns (default = Y)
-- Feedback - Y or N indicates whether to indicate the number of rows
-- selected automatically in the output (default = Y)
-- Max Rows - Limits the number of rows output to this number. NULL or
-- ZERO value indicates unlimited. (Default = NULL)
-- Indent Level - Indicates if the table should be indented and if so
-- how far: 0 = no indent, 1=.25in, 2=.5in, 3 = .75in
-- (Default = 0)
-- Show Sql - creates a link called See sql which shows the SQL-statement
-- (Default = N)
--
-- Returns:
-- The function returns the # of rows selected.
-- If there is an error then the function returns -1.
--
-- Output:
-- Displays the output of the SQL statement as an HTML table.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Display_SQL('select * from ar_system_parameters_all',
-- 'AR Parameters', 'Y', 'N',null);
-- num_rows := Display_SQL('select * from pa_implementations_all',
-- 'PA Implementation Options');
-- end;
--
function Display_SQL (p_sql_statement varchar2
, p_table_alias varchar2
, display_longs varchar2 default 'Y'
, p_feedback varchar2 default 'Y'
, p_max_rows number default null
, p_ind_level number default 0
, p_show_sql varchar2 default 'N'
, p_current_exec number default 0
, p_null varchar2 default 'Y'
--jsh added
, p_spaces varchar2 default 'Y') return number is
--jsh added
c number;
l_error_pos number;
l_error_len number;
l_row_count number;
l_exclude_cols boolean;
l_header_val varchar2(1000);
l_col_val varchar2(32767);
l_col_opts varchar2(32767) default null;
l_col_max_len integer;
l_col_num binary_integer default 1;
l_num_cols binary_integer default 1;
l_dummy integer;
l_old_date_format varchar2(40);
l_max_rows integer;
l_feedback_txt varchar2(200);
l_format varchar2(1);
l_hold_long long;
l_values V2T;
l_options V2T;
l_sql_descr dbms_sql.desc_tab;
T_VARCHAR2 constant integer := 1;
T_NUMBER constant integer := 2;
T_LONG constant integer := 8;
T_ROWID constant integer := 11;
T_DATE constant integer := 12;
T_CHAR constant integer := 96;
T_CLOB constant integer := 112;
v_valuesN V2T := V2T('');
v_valuesN2 V2T := V2T('');
row_counter2 number;
v_dummy integer;
begin
if nvl(p_max_rows,0) = 0 then
l_max_rows := null;
else
l_max_rows := p_max_rows;
end if;
select value
into l_old_date_format
from nls_session_parameters
where parameter = 'NLS_DATE_FORMAT';
execute immediate 'alter session set nls_date_format = ''' || g_sql_date
_format || '''';
c := dbms_sql.open_cursor;
dbms_sql.parse(c, p_sql_statement, dbms_sql.native);
DBMS_SQL.DESCRIBE_COLUMNS(c, l_num_cols, l_sql_descr);
dbms_sql.describe_columns(c, l_num_cols, l_sql_descr);
for l_col_num in 1..l_num_cols loop
l_col_max_len := to_number(l_sql_descr(l_col_num).col_max_len);
if l_sql_descr(l_col_num).col_type in (T_DATE, T_VARCHAR2, T_NUM
BER,T_CHAR, T_ROWID) then
dbms_sql.define_column(c, l_col_num,l_col_val,greatest(l
_col_max_len,30));
elsif l_sql_descr(l_col_num).col_type in (T_LONG) then
dbms_sql.define_column(c, l_col_num,l_col_val,32767);
end if;
l_header_val := l_sql_descr(l_col_num).col_name;
------------------
-- IFREEBER
-- make column_name show on one line
------------------
-- if length(l_header_val) > 10 then
-- l_header_val := replace(l_header_val,'_','_|');
-- end if;
------------------
-- set column_name format to initcap
l_header_val := initcap(l_header_val);
------------------
if l_col_num = 1 then
l_values := V2T(replace(l_header_val,'|','<br>'));
else
l_values.EXTEND;
l_values(l_col_num) := replace(l_header_val,'|','<br>');
end if;
end loop;
if nvl(p_ind_level,0) != 0 then
line_out('<div class=ind'||to_char(p_ind_level)||'>');
end if;
v_dummy := DBMS_SQL.EXECUTE(c); -------->jsh added begin find null colu
mns
row_counter2 := 1;
loop
if DBMS_SQL.FETCH_ROWS(c) = 0 then
exit;
end if;
for l_col_num in 1..l_num_cols loop
if l_sql_descr(l_col_num).col_type in (T_DATE, T_VARCHAR
2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.COLUMN_VALUE(c, l_col_num, l_col_val);
else
DBMS_SQL.COLUMN_VALUE(c, l_col_num, l_col_val);
l_col_val := 'CLOB';
end if;
l_col_opts := null;
if l_sql_descr(l_col_num).col_type = T_DATE then
l_col_val := replace(l_col_val,' ','&nbsp;');
l_col_opts := 'nowrap align=right';
elsif l_sql_descr(l_col_num).col_type = T_VARCHAR2 then
l_col_val := replace(replace(l_col_val,'<','&lt;
'),'>','&gt;');
if l_col_val != rtrim(l_col_val) then
l_col_opts := 'nowrap bgcolor=yellow';
else
l_col_opts := 'nowrap';
end if;
elsif l_sql_descr(l_col_num).col_type = T_NUMBER then
l_col_opts := 'nowrap align=right';
else
null;
end if;
l_col_val := replace(l_col_val,' ','&nbsp;');
if l_col_num = 1 then
if l_col_val is null then
v_valuesN := V2T(null);
else
v_valuesN := V2T('n');
end if;
else
v_valuesN.EXTEND;
if l_col_val is null then
v_valuesN(l_col_num) := null;
else
v_valuesN(l_col_num) := 'n';
end if;
end if;
v_valuesN2.EXTEND;
v_valuesN2(l_col_num) := v_valuesN2(l_col_num)||v_values
N(l_col_num);
end loop;
row_counter2 := row_counter2 + 1;
end loop;
if p_table_alias is not null then
line_out('<br><span class="BigPrint">'||p_table_alias||'</span>'
);
end if;
l_dummy := dbms_sql.EXECUTE(c);
l_row_count := 1;
loop
if dbms_sql.FETCH_ROWS(c) = 0 then
exit;
end if;
if l_row_count = 1 then
Start_Table(p_table_alias);
Show_Table_Header(l_values,null, v_valuesN2, p_null, p_s
paces); ------> jsh added for null columns
end if;
for l_col_num in 1..l_num_cols loop
if l_sql_descr(l_col_num).col_type in (T_DATE, T_VARCHAR
2, T_NUMBER,T_CHAR, T_ROWID) then
dbms_sql.column_value(c,l_col_num,l_col_val);
elsif l_sql_descr(l_col_num).col_type = T_LONG then
dbms_sql.column_value(c,l_col_num,l_col_val);
elsif l_sql_descr(l_col_num).col_type = T_CLOB then
l_col_val := 'CLOB';
else
l_col_val := 'Unsupported Datatype';
end if;
l_col_val := nvl(l_col_val,'&nbsp;');
l_col_opts := null;
if l_sql_descr(l_col_num).col_type = T_DATE then
l_col_val := replace(l_col_val,' ','&nbsp;');
l_col_opts := 'nowrap align=right';
elsif l_sql_descr(l_col_num).col_type = T_VARCHAR2 then
l_col_val := replace(replace(l_col_val,'<','&lt;
'),'>','&gt;');
l_col_val := replace(replace(l_col_val, chr(10),
'<BR>'),chr(0),'^@');
if l_col_val != rtrim(l_col_val) then
l_col_opts := 'nowrap bgcolor=yellow';
else
l_col_opts := 'nowrap';
end if;
elsif l_sql_descr(l_col_num).col_type = T_NUMBER then
l_col_opts := 'nowrap align=right';
end if;
if l_col_num = 1 then
l_values := V2T(l_col_val);
l_options := V2T(l_col_opts);
else
l_values.EXTEND;
l_values(l_col_num) := l_col_val;
l_options.EXTEND;
l_options(l_col_num) := l_col_opts;
end if;
end loop;
Show_Table_Row(l_values, l_options, v_valuesN2, p_null, p_spaces
); ------> jsh added for null columns
l_row_count := l_row_count + 1;
if l_row_count > nvl(l_max_rows,l_row_count) then
exit;
end if;
end loop;
dbms_sql.close_cursor(c);
End_Table;
if p_feedback = 'Y' then
if l_row_count = 1 then
l_feedback_txt := '<BR><span class="SmallPrint">'||'0 Ro
ws Selected</span><br>';
elsif l_row_count = 2 then
l_feedback_txt := '<span class="SmallPrint">'||'1 Row Se
lected</span><br>';
else
l_feedback_txt := '<span class="SmallPrint">'||ltrim(to_
char(l_row_count - 1,'9999999')) ||' Rows Selected</span><br>';
end if;
line_out(l_feedback_txt);
end if;
if p_show_sql = 'Y' then
line_out('<A HREF="javascript:document.write('||chr(39)||'<A HRE
F=javascript:window.history.go(-1);\>Back</A\><BR\>'||replace(replace(replace(re
place(p_sql_statement,chr(34),chr(38)||'#34'),chr(39),chr(92)||chr(39)),chr(40),
chr(38)||'#40'),chr(41),chr(38)||'#41')||'<BR\>'||chr(39)||');">See SQL</A><BR>'
);
end if;
if nvl(p_ind_level,0) != 0 then
line_out('</div>');
end if;
execute immediate 'alter session set nls_date_format = ''' ||
l_old_date_format || '''';
return l_row_count-1;
exception when others then
line_out('</table><br>');
l_error_pos := dbms_sql.last_error_position;
ErrorPrint(sqlerrm || ' occurred in Display_SQL');
ActionErrorPrint('Please report the error below to Oracle Support Servic
es');
line_out('Position: ' || l_error_pos || ' of ' ||
length(p_sql_statement) || '<br>');
line_out(replace(substr(p_sql_statement,1,l_error_pos),chr(10),'<br>'));
l_error_len := instr(p_sql_statement,' ',l_error_pos+1) - l_error_pos;
line_out('<span class="error">' ||
replace(substr(p_sql_statement,l_error_pos+1,
l_error_len),chr(10),'<br>') || '</span>');
line_out(replace(substr(p_sql_statement,l_error_pos+
l_error_len+1),chr(10),'<br>') || '<br>');
dbms_sql.close_cursor(c);
execute immediate 'alter session set nls_date_format = ''' ||
l_old_date_format || '''';
return -1;
end Display_SQL;
-- Function Name: Run_SQL
--
-- Usage:
-- a_number := Run_SQL('Heading', 'SQL statement');
-- a_number := Run_SQL('Heading', 'SQL statement', 'Feedback');
-- a_number := Run_SQL('Heading', 'SQL statement', 'Max Rows');
-- a_number := Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows');
-- a_number := Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows',
'Indent Level');
-- a_number := Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows',
'Indent Level', 'Show Sql');
--
-- Parameters:
-- Heading - Text String to for heading the output
-- SQL Statement - Any valid SQL Select Statement
-- Feedback - Y or N to indicate whether to automatically print the
-- number of rows returned (default 'Y')
-- Max Rows - Limit the output to this many rows. NULL or ZERO values
-- indicate unlimited rows (default NULL)
-- Indent Level - Indicate if table should be indented and by how much
-- 0=No indentation, 1=.25in, 2=.5in, 3=.75in (default 0)
-- Show Sql - create a link called See sql which shows the SQL-statement (D
efault = N)
--
-- Returns:
-- The function returns the # of rows selected.
-- If there is an error then the function returns -1.
--
-- Output:
-- Displays the output of the SQL statement as an HTML table.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Run_SQL('AR Parameters',
-- 'select * from ar_system_parameters_all');
-- end;
--
-- Comments:
-- The date format default is DD-MON-YYYY HH24:MI. If a different
-- date format is required, set the value of the global variable
-- g_sql_date_format to the appropriate format string prior to calling
-- Run_SQL
--
function Run_SQL(p_title varchar2, p_sql_statement varchar2) return number is
begin
return(Display_SQL(p_sql_statement , p_title ,'Y','Y',null));
end Run_SQL;
function Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2) return number is
begin
return(Display_SQL(p_sql_statement , p_title ,'Y',p_feedback,null,0));
end Run_SQL;
function Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_max_rows number) return number is
begin
return(Display_SQL(p_sql_statement , p_title ,'Y','Y',p_max_rows,0));
end Run_SQL;
function Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number) return number is
begin
return(Display_SQL(p_sql_statement , p_title ,'Y',p_feedback,p_max_rows,0));
end Run_SQL;
function Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number
, p_ind_level number) return number is
begin
return(Display_SQL(p_sql_statement , p_title , 'Y', p_feedback, p_max_rows, p
_ind_level));
end Run_SQL;
function Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number
, p_ind_level number
, p_show_sql varchar2 ) return number is
begin
return(Display_SQL(p_sql_statement , p_title , 'Y', p_feedback, p_max_rows, p
_ind_level, p_show_sql ));
end Run_SQL;
-- Procedure Name: Run_SQL
--
-- Usage:
-- Run_SQL('Heading', 'SQL statement');
-- Run_SQL('Heading', 'SQL statement', 'Feedback');
-- Run_SQL('Heading', 'SQL statement', 'Max Rows');
-- Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows');
-- Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows', 'Indent Leve
l');
-- Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows', 'Indent Leve
l', 'Show SQL');
--
-- Parameters:
-- Heading - Text String to for heading the output
-- SQL Statement - Any valid SQL Select Statement
-- Feedback - Y or N to indicate whether to automatically print the
-- number of rows returned (default 'Y')
-- Max Rows - Limit the output to this many rows. NULL or ZERO values
-- indicate unlimited rows (default NULL)
-- Indent Level - Indicate if table should be indented and by how much
-- 0=No indentation, 1=.25in, 2=.5in, 3=.75in (default 0)
-- Show Sql - create a link called See sql which shows the SQL-statement (De
fault = N)
--
-- Output:
-- Displays the output of the SQL statement as an HTML table.
--
-- Examples:
-- begin
-- Run_SQL('AR Parameters', 'select * from ar_system_parameters_all');
-- end;
--
procedure Run_SQL(p_title varchar2, p_sql_statement varchar2) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y','Y',null,0);
end Run_SQL;
procedure Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y', p_feedback, null,0);
end Run_SQL;
procedure Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_max_rows number) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y', 'Y', p_max_rows,0);
end Run_SQL;
procedure Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y', p_feedback, p_max_rows
,0);
end Run_SQL;
procedure Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number
, p_ind_level number) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y', p_feedback, p_max_rows
, p_ind_level);
end Run_SQL;
procedure Run_SQL(p_title varchar2
, p_sql_statement varchar2
, p_feedback varchar2
, p_max_rows number
, p_ind_level number
, p_show_sql varchar2 ) is
dummy number;
begin
dummy := Display_SQL (p_sql_statement , p_title , 'Y', p_feedback, p_max_rows
, p_ind_level, p_show_sql );
end Run_SQL;
-- Procedure Name: Display_Table
--
-- Usage:
-- Display_Table('Table Name', 'Heading', 'Where Clause', 'Order By', 'Long
Flag');
--
-- Parameters:
-- Table Name - Any Valid Table or View
-- Heading - Text String to for heading the output
-- Where Clause - Where clause to apply to the table dump
-- Order By - Order By clause to apply to the table dump
-- Long Flag - 'Y' or 'N' - If set to 'N' then this will not output any LO
NG columns
--
-- Output:
-- Displays the output of the 'select * from table' as an HTML table.
--
-- Examples:
-- begin
-- Display_Table('AR_SYSTEM_PARAMETERS_ALL', 'AR Parameters', 'Where Org
_id != -3113'
-- , 'order by org_id, set_of_books_id', 'N');
-- end;
--
procedure Display_Table (p_table_name varchar2,
p_table_alias varchar2,
p_where_clause varchar2,
p_order_by_clause varchar2 default null,
p_display_longs varchar2 default 'Y') is
dummy number;
hold_char varchar(1) := null;
begin
if p_where_clause is not null then
hold_char := chr(10);
end if;
dummy := Display_SQL ('select * from ' ||
replace(upper(p_table_name),'V_$','V$') || chr(10) || p_where_clause ||
hold_char || nvl(p_order_by_clause,'order by 1')
, nvl(p_table_alias, p_table_name)
, p_display_longs);
end Display_Table;
-- Function Name: Display_Table
--
-- Usage:
-- a_number := Display_Table('Table Name', 'Heading', 'Where Clause', 'Orde
r By', 'Long Flag');
--
-- Parameters:
-- Table Name - Any Valid Table or View
-- Heading - Text String to for heading the output
-- Where Clause - Where clause to apply to the table dump
-- Order By - Order By clause to apply to the table dump
-- Long Flag - 'Y' or 'N' - If set to 'N' then this will not output any LO
NG columns
--
-- Output:
-- Displays the output of the 'select * from table' as an HTML table.
--
-- Returns:
-- Number of rows displayed.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Display_Table('AR_SYSTEM_PARAMETERS_ALL', 'AR Parameters'
, 'Where Org_id != -3113'
-- , 'order by org_id, set_of_books_id', 'N'
);
-- end;
--
function Display_Table (p_table_name varchar2,
p_table_alias varchar2,
p_where_clause varchar2,
p_order_by_clause varchar2 default null,
p_display_longs varchar2 default 'Y') return number is
begin
return(Display_SQL ('select * from ' ||
replace(upper(p_table_name),'V_$','V$') || chr(10) || p_where_clause ||
chr(10) || nvl(p_order_by_clause,'order by 1')
, nvl(p_table_alias, p_table_name)
, p_display_longs));
end Display_Table;
-- Function Name: Get_DB_Apps_Version
--
-- Usage:
-- a_varchar := Get_DB_Apps_Version;
--
-- Returns:
-- The version of applications from fnd_product_groups
-- Also sets the variable g_appl_version to '10.7','11.0', or '11.5'
-- as appropriate.
--
-- Examples:
-- declare
-- apps_ver varchar2(20);
-- begin
-- apps_ver := Get_DB_Apps_Version;
-- end;
--
function Get_DB_Apps_Version return varchar2 is
l_appsver fnd_product_groups.release_name%type := null;
begin
select release_name into l_appsver from fnd_product_groups;
g_appl_version := substr(l_appsver,1,4);
return(l_appsver);
end;
-- Procedure Name: Init_Block
--
-- Usage:
-- Init_Block;
--
-- Parameters:
-- None
--
-- Output:
-- No output. Simple initializes the output CLOB for use in
-- multi-block scripts.
--
-- Examples:
-- begin
-- Init_Block;
-- end;
--
procedure Init_Block is
l_instance_name varchar2(16) := null;
l_host_name varchar2(64) := null;
l_version varchar2(17) := null;
begin
DBMS_LOB.CREATETEMPORARY(:g_hold_output,TRUE,DBMS_LOB.SESSION);
line_out('-->');
Insert_Style_Sheet;
line_out('</head><body>');
end Init_Block;
-- Procedure Name: End_Block
--
-- Usage:
-- End_Block;
--
-- Output:
-- No output. Adds the closing body and html tags to end a pl/sql
-- block without calling Show_Footer (for use in multi-block scripts).
--
-- Examples:
-- begin
-- End_Block;
-- end;
--
procedure End_Block is
begin
line_out('</body></html>');
end End_Block;
-- Procedure Name: Show_Header
--
-- Usage:
-- Show_Header('Note Number', 'Title');
--
-- Parameters:
-- Note Number - Any Valid Metalink Note Number
-- Title - Text string to go beside the note link
--
-- Output:
-- Displays Standard Header Information
--
-- Examples:
-- begin
-- Show_Header('139684.1', 'Oracle Applications Current Patchsets Compar
ison to applptch.txt');
-- end;
--
procedure Show_Header(p_note varchar2, p_title varchar2) is
l_instance_name varchar2(16) := null;
l_host_name varchar2(64) := null;
l_version varchar2(17) := null;
begin
DBMS_LOB.CREATETEMPORARY(:g_hold_output,TRUE,DBMS_LOB.SESSION);
select instance_name
, host_name
, version
into l_instance_name
, l_host_name
, l_version
from v$instance;
line_out('-->');
Insert_Style_Sheet;
line_out('</head><body>');
line_out('<table cellspacing=0 summary="Header Table to start off Script"><tr
>');
line_out('<th class=rowh align=LEFT id="note" nowrap>Note</th>');
line_out('<td align=left headers="note" nowrap><a href=http://metalink.oracle
.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=' || p_not
e || ' target=new>' || p_note || '</a><a href=http://metalink.oracle.com/metalin
k/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=' || p_note || 'target
=new></a>' || p_title || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="machine" nowrap>Machine</th>');
line_out('<td align=left headers="machine" nowrap>' || l_host_name || '</td>'
);
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="date" nowrap>Date Run</th>');
line_out('<td align=left headers="date" nowrap>' || to_char(sysdate,'DD-MON-Y
YYY HH24:MI') || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="info" nowrap>Oracle Info</th>');
line_out('<td align=left headers="info" nowrap>SID: ' || l_instance_name || '
Version: ' || l_version || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="appver" nowrap>Apps Version</th>');
line_out('<td align=left headers="appver" nowrap>' || Get_DB_Apps_Version ||
'</td>');
line_out('</tr></table><br>' );
end Show_Header;
-- Procedure Name: Show_Header
--
-- Usage:
-- Show_Header('Note Number', 'Title', 'Version');
--
-- Parameters:
-- Note Number - Any Valid Metalink Note Number
-- Title - Text string to go beside the note link
-- Version - Text string showing version info
--
-- Output:
-- Displays Standard Header Information
--
-- Examples:
-- begin
-- Show_Header('139684.1', 'Oracle Applications Current Patchsets Compar
ison to applptch.txt', 'Version 1.0');
-- end;
--
procedure Show_Header(p_note varchar2, p_title varchar2, p_ver varchar2, p_queri
es_ver varchar2) is
l_instance_name varchar2(16) := null;
l_host_name varchar2(64) := null;
l_version varchar2(17) := null;
l_multiorg varchar2(4) := null;
l_user varchar2(100) := null;
begin
DBMS_LOB.CREATETEMPORARY(:g_hold_output,TRUE,DBMS_LOB.SESSION);
select instance_name
, host_name
, version
into l_instance_name
, l_host_name
, l_version
from v$instance;
select decode (multi_org_flag, 'Y', 'Yes', 'No') into l_multiorg from fnd_pro
duct_groups;
select user
into l_user
from dual;
line_out('-->');
-- Add the ability to display a popup text window
line_out('<script language="JavaScript" type="text/javascript">');
line_out('function popupText(pText){');
line_out('var frog = window.open("","SQL","width=800,height=500,top=100,left=3
00,location=0,status=0,scrollbars=1,resizable=1")');
line_out('var html = "<html><head><"+"/head><body>"+ pText +"<"+"/body><"+"/ht
ml>";');
line_out('frog.document.open();');
line_out('frog.document.write(html);');
line_out('frog.document.close();');
line_out('}');
line_out('</script>');
Insert_Style_Sheet;
line_out('</head><body>');
line_out('<table cellspacing=0 summary="Header Table to start off Script"><tr
>');
-- line_out('<th class=rowh align=LEFT id="note" nowrap>Note</th>');
-- line_out('<td align=left headers="note" nowrap><a href=http://metalink.ora
cle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=' || p_
note || ' target=new>' || p_note || '</a><a href=http://metalink.oracle.com/meta
link/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=' || p_note || 'tar
get=new></a>' || p_title || '</td>');
line_out('<th class=rowh align=LEFT id="title" nowrap>Title</th>');
line_out('<td align=left headers="title" nowrap>' || p_title || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="ver" nowrap>Version</th>');
line_out('<td align=left headers="ver" nowrap>' || p_ver || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="update" nowrap>Update</th>');
line_out('<td align=left headers="update" nowrap>' || p_queries_ver || '</td>
');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="machine" nowrap>Machine</th>');
line_out('<td align=left headers="machine" nowrap>' || l_host_name || '</td>'
);
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="info" nowrap>Oracle Info</th>');
line_out('<td align=left headers="info" nowrap>SID: ' || l_instance_name || '
Version: ' || l_version || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="appver" nowrap>Apps Version</th>');
line_out('<td align=left headers="appver" nowrap>' || Get_DB_Apps_Version ||
'</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="multiorg" nowrap>Multi-Org</th>');
line_out('<td align=left headers="multiorg" nowrap>' || l_multiorg || '</td>'
);
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="date" nowrap>Date Run</th>');
line_out('<td align=left headers="date" nowrap>' || to_char(sysdate,'DD-MON-Y
YYY HH24:MI') || '</td>');
line_out('</tr><tr>');
line_out('<th class=rowh align=left id="user" nowrap>User</th>');
line_out('<td align=left headers="user" nowrap>' || l_user || '</td>');
line_out('</tr></table><br>' );
end Show_Header;
-- Procedure Name: Show_Footer
--
-- Usage:
-- Show_Footer('Script Name','Header');
--
-- Output:
-- Displays Standard Footer
--
-- Examples:
-- begin
-- Show_Footer('AR Setup Script',
-- '$Header: ARTrxInfo.sql 1.0 01/12/11 12:33:24 support $');
-- end;
--
procedure Show_Footer(p_script_name varchar2, p_header varchar2) is
begin
Tab0Print('<br><br>Please provide <a href="'||
'mailto:support-diagnostics_ww@oracle.com?Subject=Standalone '||
'Diagnostic feedback for ' || p_script_name || '&AMPER.BODY=' ||
p_script_name || ' - ' || p_header || '">feedback</a> regarding '||
'the usefulness of this test and/or tool.');
Tab0Print('We appreciate your feedback, however, there will be no '||
'replies to feedback emails.');
Tab0Print('For support issues, please log an iTar (Service Request).');
line_out('</body></html>');
end Show_Footer;
-- Procedure Name: Show_Link
--
-- Usage:
-- Show_Link('Note #');
--
-- Output:
-- Displays A link to a Metalink Note
--
-- Examples:
-- begin
-- Show_Link('139684.1');
-- end;
--
procedure Show_Link(p_note varchar2) is
begin
line_out('Click to see Note: <a href=http://metalink.oracle.com/metalink/plsq
l/ml2_documents.showDocument?p_database_id=NOT&p_id=' || p_note || '>' || p_not
e || '</a>');
end Show_Link;
-- Procedure Name: Show_Link
--
-- Usage:
-- Show_Link('URL', 'Name');
--
-- Output:
-- Displays A link to a URL using the Name Parameter
--
-- Examples:
-- begin
-- Show_Link('http://metalink.us.oracle.com', 'Metalink');
-- end;
--
procedure Show_Link(p_link varchar2, p_link_name varchar2 ) is
begin
line_out('<a href=' || p_link || '>' || p_link_name || '</a>');
end Show_Link;

-- Procedure Name: Send_Email


--
-- Usage:
-- Send_Email('Sender', 'Recipient', 'Subject', 'Message', 'SMTP Host');
--
-- Output:
-- Sends E-mail - No screen output.
--
-- Examples:
-- begin
-- Send_Email ('somebody@oracle.com','tosomebody@oracle.com','this is a
subject', 'this is a body','gmsmtp01.oraclecorp.com');
-- end;
--
procedure Send_Email ( p_sender varchar2
, p_recipient varchar2
, p_subject varchar2
, p_message varchar2
, p_mailhost varchar2) is
l_mail_conn utl_smtp.connection;
begin
l_mail_conn := utl_smtp.open_connection(p_mailhost, 25);
utl_smtp.helo(l_mail_conn, p_mailhost);
utl_smtp.mail(l_mail_conn, p_sender);
utl_smtp.rcpt(l_mail_conn, p_recipient);
utl_smtp.open_data(l_mail_conn);
if p_subject is not null then
utl_smtp.write_data(l_mail_conn, 'Subject: ' || p_subject || utl_tcp.CRLF)
;
end if;
utl_smtp.write_data(l_mail_conn, utl_tcp.CRLF || p_mailhost);
utl_smtp.close_data(l_mail_conn);
utl_smtp.quit(l_mail_conn);
exception
when others then
utl_smtp.quit(l_mail_conn);
ErrorPrint('<br>Error in Sending Mail' || sqlerrm);
end Send_Email;
-- Function Name: Get_Package_Version
--
-- Usage:
-- a_varchar := Get_Package_Version ('Object Type', 'Schema', 'Package Name',
-- 'Include Filename');
--
-- Parameters:
-- Object Type - 'PACKAGE' or 'PACKAGE BODY' to indicate what type of
-- object to get the version of
-- Schema - Owner of the package
-- Package Name - Name of the package
-- Include Filename - 'Y' or 'N' to indicate whether or not to include
-- the file name with the returned value (default='N')
--
-- Returns:
-- The version of the package or spec or null if the package does not
-- exist
--
-- Examples:
-- declare
-- spec_ver varchar2(20);
-- body_ver varchar2(20);
-- begin
-- spec_ver := Get_Package_Version('PACKAGE','APPS','ARH_ADDR_PKG','Y');
-- body_ver := Get_Package_Version('PACKAGE BODY','APPS','ARH_ADDR_PKG'
-- 'N');
-- end;
-- Comments
-- Called by Get_Package_Spec and Get_Package_Body which can be used for
-- objects owned by APPS.
--
function Get_Package_Version (p_type varchar2,
p_schema varchar2,
p_package varchar2,
p_include_fname varchar2 default 'N')
return varchar2 is
l_version varchar2(50);
begin
select substr(text, instr(text,'$Header')+9, 40)
into l_version
from all_source
where name = p_package
and type = p_type
and owner = p_schema
and text like '%$Header%'
and rownum = 1;
if nvl(p_include_fname,'N') != 'Y' then
l_version := substr(l_version, instr(l_version,' ')+1, 50);
l_version := substr(l_version, 1, instr(l_version,' ')-1);
return (l_version);
else
l_version := substr(l_version, 1, instr(l_version,' ',1,2)-1);
return (l_version);
end if;
exception
when no_data_found then
ErrorPrint(p_type||' '||p_package||' owned by '||p_schema||
' does not exist');
ActionErrorPrint('Verify that this object is valid for this version of '||
'applications and that the owner indicated is correct');
return(null);
when others then
ErrorPrint(sqlerrm||' occured in Get_Package_Version');
ActionErrorPrint('Please provide this information to Oracle '||
'Support Services');
raise;
end Get_Package_Version;
-- Function Name: Get_Package_Spec
--
-- Usage:
-- a_varchar := Get_Package_Spec('Package Name','Include Filename');
--
-- Returns:
-- The version of the package specification in the APPS schema
--
-- Examples:
-- declare
-- spec_ver varchar2(20);
-- begin
-- spec_ver := Get_Package_Spec('ARH_ADDR_PKG');
-- spec_ver := Get_Package_Spec('ARH_ADDR_PKG','Y');
-- end;
--
function Get_Package_Spec(p_package varchar2
, p_include_fname varchar2 default 'N')
return varchar2 is
begin
return Get_Package_Version('PACKAGE','APPS',p_package,p_include_fname);
end Get_Package_Spec;
-- Function Name: Get_Package_Body
--
-- Usage:
-- a_varchar := Get_Package_Spec('Package Name','Include Filename');
--
-- Parameters:
-- Package Name - Name of the package
-- Include Filename - 'Y' or 'N' to indicate whether or not to include
-- the file name with the returned value (default='N')
--
-- Returns:
-- The version of the package body in the APPS schema
--
-- Examples:
-- declare
-- body_ver varchar2(20);
-- begin
-- body_ver := Get_Package_Body('ARH_ADDR_PKG');
-- body_ver := Get_Package_Body('ARH_ADDR_PKG','N');
-- end;
--
function Get_Package_Body(p_package varchar2,
p_include_fname varchar2 default 'N')
return varchar2 is
begin
return Get_Package_Version('PACKAGE BODY','APPS',p_package,p_include_fname);
end Get_Package_Body;
-- Procedure Name: Display_Profiles
--
-- Usage:
-- Display_Profiles(application id, 'profile short name');
--
-- Output:
-- Displays all Profile settings for the application or profile
-- in an HTML table
--
-- Examples:
-- begin
-- Display_Profiles(222,null);
-- Display_Profiles(null, 'AR_ALLOW_OVERAPPLICATION_IN_LOCKBOX');
-- end;
--
procedure Display_Profiles (p_application_id varchar2
, p_short_name varchar2 default null) is
begin
Run_SQL('Profile Options',
'select b.user_profile_option_name "Long<br>Name"'
|| ' , a.profile_option_name "Short<br>Name"'
|| ' , decode(to_char(c.level_id),''10001'',''Site'''
|| ' ,''10002'',''Application'''
|| ' ,''10003'',''Responsibility'''
|| ' ,''10004'',''User'''
|| ' ,''Unknown'') "Level"'
|| ' , decode(to_char(c.level_id),''10001'',''Site'''
|| ' ,''10002'',nvl(h.application_short_name,to_char(c.level_value))'
|| ' ,''10003'',nvl(g.responsibility_name,to_char(c.level_value))'
|| ' ,''10004'',nvl(e.user_name,to_char(c.level_value))'
|| ' ,''Unknown'') "Level<br>Value"'
|| ' , c.PROFILE_OPTION_VALUE "Profile<br>Value"'
|| ' , c.profile_option_id "Profile<br>ID"'
|| ' , to_char(c.LAST_UPDATE_DATE,''DD-MON-YYYY HH24:MI'') '
|| ' "Updated<br>Date"'
|| ' , nvl(d.user_name,to_char(c.last_updated_by)) "Updated<br>By"'
|| ' from fnd_profile_options a'
|| ' , FND_PROFILE_OPTIONS_VL b'
|| ' , FND_PROFILE_OPTION_VALUES c'
|| ' , FND_USER d'
|| ' , FND_USER e'
|| ' , FND_RESPONSIBILITY_VL g'
|| ' , FND_APPLICATION h'
|| ' where a.application_id = nvl(' || nvl(p_application_id,'null')
|| ' , a.application_id)'
|| ' and a.profile_option_name = nvl(''' || p_short_name
|| ''' , a.profile_option_name)'
|| ' and a.profile_option_name = b.profile_option_name'
|| ' and a.profile_option_id = c.profile_option_id'
|| ' and a.application_id = c.application_id'
|| ' and c.last_updated_by = d.user_id (+)'
|| ' and c.level_value = e.user_id (+)'
|| ' and c.level_value = g.responsibility_id (+)'
|| ' and c.level_value = h.application_id (+)'
|| ' order by b.user_profile_option_name, c.level_id, '
|| ' decode(to_char(c.level_id),''10001'',''Site'''
|| ' ,''10002'',nvl(h.application_short_name,to_char(c.level_value))'
|| ' ,''10003'',nvl(g.responsibility_name,to_char(c.level_value))'
|| ' ,''10004'',nvl(e.user_name,to_char(c.level_value))'
|| ' ,''Unknown'')');
end;
-- Procedure Name: Get_Profile_Option
--
-- Usage:
-- a_varchar := Get_Profile_Option('Short Name');
--
-- Parameters:
-- Short Name - The Short Name of the Profile Option
--
-- Returns:
-- The value of the profile option based on the user.
-- If Set_Client has not been run successfully then
-- it will return the site level.
--
-- Output:
-- None
--
-- Examples:
-- declare
-- prof_value varchar2(150);
-- begin
-- prof_value := Get_Profile_Option('AR_ALLOW_OVERAPPLICATION_IN_LOCKBOX
')
-- end;
--
function Get_Profile_Option (p_profile_option varchar2) return varchar2 is
begin
return FND_PROFILE.VALUE(p_profile_option);
end;
-- Procedure Name: Set_Org
--
-- Usage:
-- Set_Org(org_id);
--
-- Parameters:
-- Org_ID - The id of the organization to set.
--
-- Output:
-- None
--
-- Examples:
-- begin
-- Set_Org(204);
-- end;
--
procedure Set_Org (p_org_id number) is
begin
fnd_client_info.set_org_context(p_org_id);
end Set_Org;
-- Procedure Name: Set_Client
--
-- Description:
-- Validates user_name, responsibility_id, and application_id parameters
-- If valid it initializes the session (which results in the operating
-- unit being set for the session as well. Also sets the global variables
-- g_user_id, g_resp_id, g_appl_id, and g_org_id which can then be used
-- throughout the script.
--
-- Usage:
-- Set_Client(UserName, Responsibility_ID);
-- Set_Client(UserName, Responsibility_ID, Application_ID);
-- Set_Client(UserName, Responsibility_ID, Application_ID, SecurityGrp_ID);
--
-- Parameters:
-- UserName - The Name of the Applications User
-- Responsibility_ID - Any Valid Responsibility ID
-- Application_ID - Any Valid Application ID (275=PA) If no value
-- provided, attempt to obtain from responsibility_id
-- SecurityGrp_ID - A valid security_group_id
--
-- Examples:
-- begin
-- Set_Client('JOEUSER',50719, 222);
-- end;
procedure Set_Client(p_user_name varchar2, p_resp_id number,
p_app_id number, p_sec_grp_id number) is
l_cursor integer;
l_num_rows integer;
l_user_name fnd_user.user_name%type;
l_user_id number;
l_app_id number;
l_counter integer;
l_appl_vers fnd_product_groups.release_name%type;
sqltxt varchar2(32767);
inv_user exception;
inv_resp exception;
inv_app exception;
no_app exception;
begin
l_user_name := upper(p_user_name);
begin
select user_id into l_user_id
from fnd_user where user_name = l_user_name;
exception
when others then
raise inv_user;
end;
l_appl_vers := get_db_apps_version; -- sets g_appl_version
if g_appl_version = '11.0' or g_appl_version = '10.7' then
sqltxt := 'select distinct rg.application_id '||
'from fnd_user_responsibility rg '||
'where rg.responsibility_id = '||to_char(p_resp_id)||' '||
'and rg.user_id = '||to_char(l_user_id);
elsif g_appl_version = '11.5' then
sqltxt := 'select distinct rg.responsibility_application_id '||
'from fnd_user_resp_groups rg '||
'where rg.responsibility_id = '||to_char(p_resp_id)||' '||
'and rg.user_id = '||to_char(l_user_id);
end if;
begin
l_cursor := dbms_sql.open_cursor;
dbms_sql.parse(l_cursor, sqltxt, dbms_sql.native);
dbms_sql.define_column(l_cursor, 1, l_app_id);
l_num_rows := dbms_sql.execute_and_fetch(l_cursor, TRUE);
dbms_sql.column_value(l_cursor, 1, l_app_id);
dbms_sql.close_cursor(l_cursor);
exception
when no_data_found then
raise inv_resp;
when too_many_rows then
if p_app_id is null then
raise no_app;
else
dbms_sql.close_cursor(l_cursor);
l_cursor := dbms_sql.open_cursor;
dbms_sql.parse(l_cursor, sqltxt, dbms_sql.native);
dbms_sql.define_column(l_cursor, 1, l_app_id);
l_num_rows := dbms_sql.execute(l_cursor);
while dbms_sql.fetch_rows(l_cursor) > 0 loop
dbms_sql.column_value(l_cursor, 1, l_app_id);
if l_app_id = p_app_id then
exit;
end if;
end loop;
dbms_sql.close_cursor(l_cursor);
if l_app_id != p_app_id then
raise inv_app;
end if;
end if;
end;
l_cursor := dbms_sql.open_cursor;
if g_appl_version = '11.5' then
sqltxt := 'begin '||
'fnd_global.apps_initialize(:user, :resp, '||
':appl, :secg); '||
'end; ';
dbms_sql.parse(l_cursor, sqltxt, dbms_sql.native);
dbms_sql.bind_variable(l_cursor,':user',l_user_id);
dbms_sql.bind_variable(l_cursor,':resp',p_resp_id);
dbms_sql.bind_variable(l_cursor,':appl',l_app_id);
dbms_sql.bind_variable(l_cursor,':secg',p_sec_grp_id);
else
sqltxt := 'begin '||
'fnd_global.apps_initialize(:user,:resp,:appl); '||
'end; ';
dbms_sql.parse(l_cursor, sqltxt, dbms_sql.native);
dbms_sql.bind_variable(l_cursor,':user',l_user_id);
dbms_sql.bind_variable(l_cursor,':resp',p_resp_id);
dbms_sql.bind_variable(l_cursor,':appl',l_app_id);
end if;
l_num_rows := dbms_sql.execute(l_cursor);
g_user_id := l_user_id;
g_resp_id := p_resp_id;
g_appl_id := l_app_id;
g_org_id := Get_Profile_Option('ORG_ID');
exception
when inv_user then
ErrorPrint('Unable to initialize client due to invalid username: '||
l_user_name);
ActionErrorPrint('Set_Client has been passed an invalid username '||
'parameter. Please correct this parameter if possible, and if not, '||
'inform your support representative.');
raise;
when inv_resp then
ErrorPrint('Unable to initialize client due to invalid responsibility '||
'ID: '||to_char(p_resp_id));
ActionErrorPrint('Set_Client has been passed an invalid responsibility '||
'ID parameter. This responsibility_id either does not exist or has not '||
'been assigned to the user ('||l_user_name||'). Please correct these '||
'parameter values if possible, and if not inform your support '||
'representative.');
raise;
when inv_app then
ErrorPrint('Unable to initialize client due to invalid application ID: '||
to_char(p_app_id));
ActionErrorPrint('Set_Client has been passed an invalid application ID '||
'parameter. This application either does not exist or is not '||
'associated with the responsibility id ('||to_char(p_resp_id)||'). '||
'Please correct this parameter value if possible, and if not inform '||
'your support representative.');
raise;
when no_app then
ErrorPrint('Set_Client was unable to obtain an application ID to '||
'initialize client settings');
ActionErrorPrint('No application_id was supplied and Set_Client was '||
'unable to determine this from the responsibility because multiple '||
'responsibilities with the same responsibility_id have been assigned '||
'to this user ('||l_user_name||').');
raise;
when others then
ErrorPrint(sqlerrm||' occured in Set_Client');
ActionErrorPrint('Please inform your support representative');
raise;
end Set_Client;
procedure Set_Client(p_user_name varchar2, p_resp_id number) is
begin
Set_Client(p_user_name, p_resp_id, null, null);
end Set_Client;
procedure Set_Client(p_user_name varchar2, p_resp_id number,
p_app_id number ) is
begin
Set_Client(p_user_name, p_resp_id, p_app_id, null);
end Set_Client;
-- Procedure Name: Get_DB_Patch_List
--
-- Usage:
-- a_string := Get_DB_Patch_List('heading', 'short name', 'bug number', 'st
art date');
--
-- Parameters:
-- Heading = Title to go at the top of TABLE or TEXT outputs
-- Short Name = Limits to Bugs that match this expression for the Applicati
ons Production Short Name (LIKE)
-- Bug Number = Limits to bugs that match this expression (LIKE)
-- Start Date = Limits to Bugs created after this date
--
-- Output:
-- An HTML table of patches applied for the application since the date
-- indicated is displayed.
--
-- Examples:
-- begin
-- Get_DB_Patch_List(null, 'AD','%', '03-MAR-2002', 'SILENT');
-- end;
--
procedure Get_DB_Patch_List (p_heading varchar2 default 'AD_BUGS'
, p_app_short_name varchar2 default '%'
, p_bug_number varchar2 default '%'
, p_start_date date default to_date('01-JAN-1960','DD-MON-YYYY')
, p_output_option varchar2 default 'TABLE') is
l_cursor integer;
l_sqltxt varchar2(32767);
l_list_out varchar2(32767);
l_hold_comma varchar2(2);
l_counter integer;
l_app_short_name varchar2(50);
l_bug_number varchar2(30);
l_creation_date date;
begin
select count(*) into l_counter
from all_tables
where table_name = 'AD_BUGS';
if l_counter > 0 then
l_sqltxt := 'select application_short_name'
|| ' , bug_number'
|| ' , creation_date'
|| ' from ad_bugs'
|| ' where upper(application_short_name) like '''
|| upper(p_app_short_name)
|| ''' and creation_date >= '''
|| nvl(to_char(p_start_date,'DD-MON-YYYY'),'01-JAN-1960')
|| ''' and bug_number like '''||p_bug_number||'''';
Run_SQL(p_heading, l_sqltxt);
else
WarningPrint('Table AD_BUGS does not exist');
ActionWarningPrint('Unable to retrieve a patch list from the database as t
his feature is not available on this version of the applications');
end if;
end Get_DB_Patch_List;
-- Function Name: Get_RDBMS_Header
--
-- Usage:
-- Get_RDBMS_Header;
--
-- Returns:
-- Version of the Database from v$version
--
-- Examples:
-- declare
-- RDBMS_Ver := v$version.banner%type;
-- begin
-- RDBMS_Ver := Get_RDBMS_Header;
-- end;
--
Function Get_RDBMS_Header return varchar2 is
l_hold_name v$database.name%type;
l_DB_Ver v$version.banner%type;
begin
begin
select name
into l_hold_name
from v$database;
exception
when others then
l_hold_name := 'Not Available';
end;
begin
select banner
into l_DB_Ver
from v$version
where banner like 'Oracle%';
exception
when others then
l_DB_Ver := 'Not Available';
end;
return(l_hold_name || ' - ' || l_DB_Ver);
end Get_RDBMS_Header;
-- Function Name: Compare_Pkg_Version
--
-- Usage:
-- Compare_Pkg_Version('package_name','obj_type','obj_owner', 'outversvar',
-- 'reference_version');
-- Compare_Pkg_Version('package_name','obj_type', 'outversvar',
-- 'reference_version');
--
-- Parameters:
-- package_name - Name of the package whose version is being checked
-- obj_type - Either BODY or SPEC to determine which piece to check
-- obj_owner - The owner of the package being checked. If null or
-- not supplied the default is APPS.
-- outversvar - A text out variable to hold the actual package version
-- of the package as returned from the database
-- reference_version - A string containing the version to which the
-- package version should be compared (in
-- format ###.##, ie, in a format convertible
-- to a number. As opposed to, for example,
-- 11.5.119, use 115.119.
--
-- Returns:
-- 'greater' if the version of the object is greater than the reference
-- 'less' if the version of the object is less than the reference
-- 'equal' if the version of the object is equal to the reference
-- 'null' if either the reference or db version is null
--
-- Examples:
-- declare
-- Comparison_Var varchar2(8);
-- Package_Version varchar2(10);
-- begin
-- Comparison_Var := Compare_Pkg_Version('PA_UTILS2','BODY','APPS',
-- Package_Version, '115.13');
-- Comparison_Var := Compare_Pkg_Version('PA_UTILS2','BODY',
-- Package_Version, '115.13');
-- end;
--
Function Compare_Pkg_Version(
package_name in varchar2,
object_type in varchar2,
object_owner in varchar2,
version_str in out varchar2,
compare_version in varchar2)
return varchar2 is
vers_line varchar2(1000);
l_object_owner varchar2(250);
db_vers_key_chr varchar2(30);
db_vers_key number;
in_vers_key number;
begin
l_object_owner := object_owner;
if l_object_owner is null then
l_object_owner := 'APPS';
end if;
in_vers_key :=
to_number(substr(compare_version,instr(compare_version,'.')+1));
if upper(object_type) = 'BODY' then
select text into vers_line
from dba_source
where name = package_name
and owner = l_object_owner
and text like '%$Header%'
and type = 'PACKAGE BODY';
else
select text into vers_line
from dba_source
where name = package_name
and owner = l_object_owner
and text like '%$Header%'
and type = 'PACKAGE';
end if;
vers_line := substr(vers_line,instr(vers_line,'$Header:')+9);
vers_line := ltrim(vers_line);
vers_line := substr(vers_line,1,instr(vers_line,' ',1,2)-1);
vers_line := substr(vers_line,instr(vers_line,' ')+1);
version_str := vers_line;
db_vers_key_chr := substr(vers_line,instr(vers_line,'.')+1);
if instr(db_vers_key_chr,'.',1,1) != 0 then
db_vers_key_chr :=
substr(db_vers_key_chr,1,instr(db_vers_key_chr,'.',1,1)-1)||'.'||
replace(substr(db_vers_key_chr,instr(db_vers_key_chr,'.',1,1)+1),
'.','');
end if;
db_vers_key := to_number(db_vers_key_chr);
if db_vers_key < in_vers_key then
return('less');
elsif db_vers_key > in_vers_key then
return('greater');
elsif db_vers_key = in_vers_key then
return('equal');
elsif db_vers_key is null or in_vers_key is null then
return('null');
end if;
exception when others then
ErrorPrint('Unable to verify package version for '||package_name||' ('||
object_type||') -- '||sqlerrm||' occured in Compare_Pkg_Version');
ActionErrorPrint('Contact your support representative and supply the '||
'above error information');
return('null');
end Compare_Pkg_Version;
Function Compare_Pkg_Version(
package_name in varchar2,
object_type in varchar2,
version_str in out varchar2,
compare_version in varchar2 default null)
return varchar2 is
begin
return(compare_pkg_version(
package_name, object_type, null, version_str,compare_version));
end Compare_Pkg_Version;
-- Procedure Name: Show_Invalids
--
-- Usage:
-- Show_Invalids('start string', 'include errors', 'heading');
--
-- Parameters:
-- start string - An string indicating the beginning of object names to
-- be included. The underscore '_' character will be
-- escaped in this string so that it does not act as a
-- wild card character. For example, 'PA_' will not match
-- 'PAY' even though it normally would in SQL*Plus.
-- include errors - Y or N to indicate whether to search on and report
-- the errors from ALL_ERRORS for each of the invalid
-- objects found. (DEFAULT = N)
-- heading - An optional heading for the table. If null the heading will
-- be "Invalid Objects (Starting with 'XXX')" where XXX is
-- the start string parameter.
--
-- Output:
-- A listing of invalid objects whose name starts with the 'start string'.
-- For packages, procedures, and functions, file versions will be included,
-- and when requested, error messages associated with the object will
-- be reported.
--
-- Examples:
-- Show_Invalids('PA_','Y');
-- Show_Invalids('GL_');
--
Procedure Show_Invalids (p_start_string varchar2
, p_include_errors varchar2 default 'N'
, p_heading varchar2 default null) is
l_start_string varchar2(60);
l_errors varchar2(32767);
l_file_version varchar2(100);
l_heading varchar2(500);
l_first_row boolean := true;
l_table_row V2T;
l_row_options V2T;
cursor get_invalids(c_start_string varchar2) is
select o.object_name, o.object_type, o.owner
from all_objects o
where o.status = 'INVALID'
and o.object_name like c_start_string escape '~'
order by o.object_name;
cursor get_file_version(
c_obj_name varchar2
, c_obj_type varchar2
, c_obj_owner varchar2) is
select substr(substr(s.text,instr(s.text,'$Header')+9),1,
instr(substr(s.text,instr(s.text,'$Header')+9),' ',1,2)-1) file_vers
from all_source s
where name = c_obj_name
and type = c_obj_type
and owner = c_obj_owner
and text like '%$Header%';
cursor get_errors (
c_obj_name varchar2
, c_obj_type varchar2
, c_obj_owner varchar2) is
select to_char(sequence)||') LINE: '||to_char(line)||' CHR: '||
to_char(position)||' '||text error_row
from all_errors
where name = c_obj_name
and type = c_obj_type
and owner = c_obj_owner;
begin
l_start_string := upper(replace(p_start_string,'_','~_')) || '%';
if p_heading is null then
l_heading := 'Invalid Objects (Starting with '''||p_start_string||''')';
else
l_heading := p_heading;
end if;
line_out('<br><span class="BigPrint">' || l_heading || '</span>');
for inv_rec in get_invalids(l_start_string) loop
if l_first_row then
Start_Table('Invalid Objects');
if p_include_errors = 'Y' then
Show_Table_Header(V2T('Object Name','Object Type', 'Owner',
'File Version', 'Errors'));
else
Show_Table_Header(V2T('Object Name', 'Object Type', 'Owner',
'File Version'));
end if;
l_first_row := false;
end if;
if inv_rec.object_type like 'PACKAGE%' or
inv_rec.object_type in ('PROCEDURE','FUNCTION') then
open get_file_version(inv_rec.object_name, inv_rec.object_type,
inv_rec.owner);
fetch get_file_version into l_file_version;
if get_file_version%notfound then
l_file_version := null;
end if;
close get_file_version;
else
l_file_version := null;
end if;
if p_include_errors = 'Y' then
l_errors := null;
for err_rec in get_errors(inv_rec.object_name, inv_rec.object_type,
inv_rec.owner) loop
l_errors := l_errors||err_rec.error_row||'<br>';
end loop;
l_table_row := V2T(inv_rec.object_name, inv_rec.object_type,
inv_rec.owner, l_file_version, l_errors);
l_row_options := V2T(null,'nowrap',null,'nowrap','nowrap');
Show_Table_Row(l_table_row,l_row_options);
else
l_table_row := V2T(inv_rec.object_name, inv_rec.object_type,
inv_rec.owner, l_file_version);
Show_Table_Row(l_table_row);
end if;
end loop;
End_Table;
if l_first_row then
Insert_HTML('<br><span class="SmallPrint">No Rows Selected</span><br>');
end if;
exception when others then
ErrorPrint(sqlerrm||' occured in Show_Invalids');
ActionErrorPrint('Use the feedback link to report the above error to '||
'support');
end Show_Invalids;
--------------------- Pl/SQL api end ------------------------------------------
--------------------- Addon API start -----------------------------------------
/*******************************************************************************
******************************************
Modified display_sql Code. The code was modified to allow the columns to be dis
played in Portrait layout format
********************************************************************************
*****************************************/
-- Function Name: Display_SQLP
--
-- Usage:
-- a_number := Display_SQLP('SQL statement','Name for Header','Long Flag',
-- 'Feedback','Max Rows','Indent Level','Null Columns', 'Show Sp
aces');
--
-- Parameters:
-- SQL Statement - Any valid SQL Select Statement
-- Name for Header - Text String to for heading the output
-- Long Flag - Y or N - If set to N then this will not output
-- any LONG columns (default = Y)
-- Feedback - Y or N indicates whether to indicate the number of rows
-- selected automatically in the output (default = Y)
-- Max Rows - Limits the number of rows output to this number. NULL or
-- ZERO value indicates unlimited. (Default = NULL)
-- Indent Level - Indicates if the table should be indented and if so
-- how far: 0 = no indent, 1=.25in, 2=.5in, 3 = .75in
-- (Default = 0)
-- Null Columns - Y or N - If set to Y, columns with Null values will be d
isplayed. If set to N,
-- columns with null values will not be displayed.
--
-- Show Spaces - Y or N - If set to Y, column value will be enclosed by ><
to show leading and
-- trailing spaces. If set to N, only the column value
will be displayed.
-- Returns:
-- The function returns the # of rows selected.
-- If there is an error then the function returns -1.
--
-- Output:
-- Displays the output of the SQL statement in various HTML table formats.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Display_SQLPL('select * from ar_system_parameters_all',
-- 'AR Parameters', 'Y', 'N',null, 'P', 'Y');
-- end;
--
function Display_SQLP (p_sql_statement varchar2
, table_alias varchar2
, display_longs varchar2 default 'Y'
, p_feedback varchar2 default 'Y'
, p_max_rows number default null
, p_ind_level number default 0
, p_null varchar2 default 'Y'
, p_spaces varchar2 default 'N'
, p_current_exec number default 0) return number is
error_position number;
error_position_end number;
row_counter number;
hold_exclude_cols boolean;
hold_sql_needed varchar2(3);
hold_string varchar2(32767) default null;
hold_option varchar2(32767) default null;
hold_sql varchar2(32767) default null;
hold_sql_remain varchar2(32767) default null;
hold_element varchar2(32767) default null;
hold_long long;
hold_clob clob;
hold_length integer;
hold_bgcolor varchar2(40);
hold_color varchar2(40);
hold_open_paren number;
hold_curr_loc number;
hold_end_pos number;
column_counter binary_integer default 1;
value_counter binary_integer default 1;
column_high binary_integer default 1;
value_high binary_integer default 1;
v_cursor_id number;
v_dummy integer;
l_hold_length varchar2(20);
l_hold_date_format varchar2(40);
l_hold_type varchar2(40);
v_col_headers V2T;
v_values V2T;
v_options V2T;
v_describe dbms_sql.desc_tab;
T_VARCHAR2 constant integer := 1;
T_NUMBER constant integer := 2;
T_LONG constant integer := 8;
T_ROWID constant integer := 11;
T_DATE constant integer := 12;
T_RAW constant integer := 23;
T_CHAR constant integer := 96;
T_TYPE constant integer := 109;
T_CLOB constant integer := 112;
T_BLOB constant integer := 113;
T_BFILE constant integer := 114;
l_max_rows integer;
l_feedback_txt varchar2(240);
begin
if nvl(p_max_rows,0) = 0 then
l_max_rows := null;
else
l_max_rows := p_max_rows;
end if;

if p_current_exec = 0 then
select value into l_hold_date_format from nls_session_parameters
where parameter = 'NLS_DATE_FORMAT';
execute immediate 'alter session set nls_date_format = ''DD-MON-
YYYY HH24:MI''';
end if;
begin
v_cursor_id := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor_id, p_sql_statement, DBMS_SQL.V7);
DBMS_SQL.DESCRIBE_COLUMNS(v_cursor_id, column_high, v_describe);
hold_sql := 'select ';
hold_sql_needed := null;
hold_exclude_cols := false;
hold_sql_remain := ltrim(substr(replace(p_sql_statement,chr(10),
' '), 7));
for value_counter in 1..column_high loop
if v_describe(value_counter).col_type = T_LONG then
hold_length := 25000;
else
hold_length := to_number(v_describe(value_counte
r).col_max_len);
end if;
if v_describe(value_counter).col_type in (T_DATE, T_VARC
HAR2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.DEFINE_COLUMN(v_cursor_id, value_counte
r, hold_string, greatest(hold_length,30));
elsif v_describe(value_counter).col_type = T_CLOB then
DBMS_SQL.DEFINE_COLUMN(v_cursor_id, value_counte
r, hold_clob);
else
null;
end if;
hold_string := v_describe(value_counter).col_name;
if value_counter = 1 then
v_col_headers := V2T(replace(initcap(hold_string
),'|','<br>'));
else
v_col_headers.EXTEND;
v_col_headers(value_counter) := replace(initcap(
hold_string),'|','<br>');
end if;
if substr(hold_sql_remain,1,1) != '*' then
hold_end_pos := 1;
hold_open_paren := 0;
loop
if substr(hold_sql_remain,hold_end_pos,1
) = '(' then
hold_open_paren := hold_open_par
en + 1;
elsif substr(hold_sql_remain,hold_end_po
s,1) = ')' then
hold_open_paren := hold_open_par
en - 1;
elsif substr(hold_sql_remain,hold_end_po
s,1) = ','
or lower(substr(hold_sql_remain, hold
_end_pos, 4)) = ' from ' then
if hold_open_paren = 0 then
exit;
end if;
end if;
hold_end_pos := hold_end_pos + 1;
if hold_end_pos > length(p_sql_statement
) then
exit;
end if;
end loop;
hold_element := substr(hold_sql_remain, 1, hold_
end_pos);
hold_sql_remain := ltrim(substr(hold_sql_remain,
hold_end_pos + 1));
else
hold_element := v_describe(value_counter).col_na
me;
end if;
if v_describe(value_counter).col_type in (T_VARCHAR2, T_
CHAR, T_NUMBER, T_DATE, T_LONG, T_CLOB, T_ROWID) then
hold_sql := hold_sql || hold_sql_needed || hold_
element;
else
hold_exclude_cols := true;
end if;
hold_sql_needed := ', ';
end loop;
if hold_exclude_cols then
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);
hold_sql := hold_sql || ' ' || substr(p_sql_statement,in
str(lower(p_sql_statement),' from '));
row_counter := Display_SQL (hold_sql, table_alias, displ
ay_longs, p_current_exec + 1) + 1;
else
if nvl(p_ind_level,0) != 0 then
line_out('<div class=ind'||to_char(p_ind_level)||'>');
end if;
if table_alias is not null then
line_out('<br><span class="BigPrint">' || table_
alias ||'</span>');
end if;
Start_Table(table_alias);
line_out('<tr>');
line_out('<th id=1>Column</th>');
line_out('<th id=2>Value</th>');
line_out('</tr>');
v_dummy := DBMS_SQL.EXECUTE(v_cursor_id);
row_counter := 1;
loop
if DBMS_SQL.FETCH_ROWS(v_cursor_id) = 0 then
exit;
end if;
for value_counter in 1..column_high loop
if v_describe(value_counter).col_type in
(T_DATE, T_VARCHAR2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_string);
else
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_clob);
hold_string := 'CLOB';
end if;
hold_option := null;
if v_describe(value_counter).col_type =
T_DATE then
hold_string := replace(hold_stri
ng,' ','&nbsp;');
elsif v_describe(value_counter).col_type
= T_VARCHAR2 then
hold_string := replace(replace(h
old_string,'<','&lt;'),'>','&gt;');
else
null;
end if;
hold_string := replace(hold_string,' ','
&nbsp;');
if value_counter = 1 then
v_values := V2T(hold_string);
else
v_values.EXTEND;
v_values(value_counter) := hold_
string;
end if;
end loop;
if row_counter > 1 then
line_out('<br><span class="BigPrint">' || table_alias ||' Row '||row_cou
nter||' </span> ');
line_out('</style>') ;
line_out('</head><body>');
line_out('<table cellspacing=0 summary="' || table_alias ||' Row '||row_
counter||' "><tr> ');
line_out('<tr>');
line_out('<th id=1>Column</th>');
line_out('<th id=2>Value</th>');
line_out('</tr>');

end if;
for i in 1..v_values.COUNT loop
if v_values(i) is null then
if upper(nvl(p_null,'Y')) = 'Y' then
line_out('<tr>');
line_out('<td align=left headers="'||1||'" nowrap>'||'<tt>' ||v_col_headers(i)||
' </tt>'||'</td>');
line_out('<td align=left headers="'||2||'" nowrap>'||'<tt>&gt&lt;</tt>'||'</td>'
);
line_out('</tr>');
end if;
else
line_out('<tr>');
line_out('<td align=left headers="'||1||'" nowrap>'||'<tt>' ||v_col_headers(i)||
' </tt>'||'</td>');
if p_spaces = 'Y' then
if v_describe(i).col_type in (T_NUMBER, T_DATE) then
line_out('<td align=left headers="'||2||'" nowrap>'||'<tt>' ||v_values(i
)||'</tt>'||'</td>');
else
line_out('<td align=left headers="'||2||'" nowrap>'||'<tt>&gt;' ||v_valu
es(i)||'&lt; </tt>'||'</td>');
end if;
else
line_out('<td align=left headers="'||2||'" nowrap>'||'<tt>' ||v_values(i)||'</tt
>'||'</td>');
end if;
line_out('</tr>');
end if;
end loop;
line_out('<br>');
row_counter := row_counter + 1;
if row_counter > nvl(l_max_rows,row_counter) then
exit;
end if;
line_out('</tr></table><br>');
end loop;
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);
Show_Table('END');
end if;
if p_current_exec = 0 and p_feedback = 'Y' then
if row_counter = 1 then
l_feedback_txt := '<BR><span class="SmallPrint">'||
'0 Rows Selected</span><br>';
elsif row_counter = 2 then
l_feedback_txt := '<span class="SmallPrint">'||
'1 Row Selected</span><br>';
else
l_feedback_txt := '<span class="SmallPrint">'||
ltrim(to_char(row_counter - 1,'9999999')) ||
' Rows Selected</span><br>';
end if;
line_out(l_feedback_txt);
execute immediate 'alter session set nls_date_format = '
'' || l_hold_date_format || '''';
end if;
return row_counter-1;
exception
when others then
line_out('</table><br>');
error_position := DBMS_SQL.LAST_ERROR_POSITION;
ErrorPrint(sqlerrm || ' occurred in Display_SQLP');
ActionErrorPrint('Please report the error below to suppo
rt.');
line_out('Position: ' || error_position || ' of ' || le
ngth(p_sql_statement) || '<br>');
line_out(replace(substr(p_sql_statement,1,error_position
),chr(10),'<br>'));
error_position_end := instr(p_sql_statement,' ',error_po
sition+1) - error_position;
line_out('<span class="error">' || replace(substr(p_sql_
statement,error_position+1, error_position_end),chr(10),'<br>') || '</span>');
line_out(replace(substr(p_sql_statement,error_position+e
rror_position_end+1),chr(10),'<br>') || '<br>');
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);
if p_current_exec = 0 then
execute immediate 'alter session set nls_date_fo
rmat = ''' || l_hold_date_format || '''';
end if;
return -1;
end;
end display_sqlP;

-- Function Name: Display_SQLPL


--
-- Usage:
-- a_number := Display_SQLPL('SQL statement','Name for Header','Long Flag',
-- 'Feedback','Max Rows','Indent Level', 'Null Columns', 'Show S
paces');
--
-- Parameters:
-- SQL Statement - Any valid SQL Select Statement
-- Name for Header - Text String to for heading the output
-- Long Flag - Y or N - If set to N then this will not output
-- any LONG columns (default = Y)
-- Feedback - Y or N indicates whether to indicate the number of rows
-- selected automatically in the output (default = Y)
-- Max Rows - Limits the number of rows output to this number. NULL or
-- ZERO value indicates unlimited. (Default = NULL)
-- Indent Level - Indicates if the table should be indented and if so
-- how far: 0 = no indent, 1=.25in, 2=.5in, 3 = .75in
-- (Default = 0)
-- Null Columns - Y or N - If set to Y Null columns will Null values will be
displayed. If set to N
-- columns with null values will not be displayed.
--
-- Show Spaces - Y or N - If set to Y, column value will be enclosed by ><
to show leading and
-- trailing spaces. If set to N, only the column value
will be displayed.
-- Returns:
-- The function returns the # of rows selected.
-- If there is an error then the function returns -1.
--
-- Output:
-- Displays the output of the SQL statement in various HTML table formats.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Display_SQLPL('select * from ar_system_parameters_all',
-- 'AR Parameters', 'Y', 'N',null, 'P', 'Y');
-- end;
--
function Display_SQLPL (p_sql_statement varchar2
, table_alias varchar2
, display_longs varchar2 default 'Y'
, p_feedback varchar2 default 'Y'
, p_max_rows number default null
, p_ind_level number default 0
, p_null varchar2 default 'Y'
, p_spaces varchar2 default 'N'
, p_current_exec number default 0) return number is
error_position number;
error_position_end number;
row_counter number;
row_counter2 number;
hold_exclude_cols boolean;
hold_sql_needed varchar2(3);
hold_string varchar2(32767) default null;
hold_option varchar2(32767) default null;
hold_string2 varchar2(32767) default null;
hold_option2 varchar2(32767) default null;
hold_sql varchar2(32767) default null;
hold_sql_remain varchar2(32767) default null;
hold_element varchar2(32767) default null;
hold_long long;
hold_clob clob;
hold_length integer;
hold_bgcolor varchar2(40);
hold_color varchar2(40);
hold_open_paren number;
hold_curr_loc number;
hold_end_pos number;
column_counter binary_integer default 1;
value_counter binary_integer default 1;
column_high binary_integer default 1;
column_high2 binary_integer default 1;
value_high binary_integer default 1;
v_cursor_id number;
v_dummy integer;
l_hold_length varchar2(20);
l_hold_date_format varchar2(40);
l_hold_type varchar2(40);
v_col_values_count number;
v_col_values V2T;
v_values v2t;
v_valuesN v2t;
v_options v2t;
v_values2 v2t;
v_options2 v2t;
nullCounter number;
v_describe dbms_sql.desc_tab;
T_VARCHAR2 constant integer := 1;
T_NUMBER constant integer := 2;
T_LONG constant integer := 8;
T_ROWID constant integer := 11;
T_DATE constant integer := 12;
T_RAW constant integer := 23;
T_CHAR constant integer := 96;
T_TYPE constant integer := 109;
T_CLOB constant integer := 112;
T_BLOB constant integer := 113;
T_BFILE constant integer := 114;
l_max_rows integer;
l_feedback_txt varchar2(240);

begin
if nvl(p_max_rows,0) = 0 then
l_max_rows := null;
else
l_max_rows := p_max_rows;
end if;

if p_current_exec = 0 then
select value into l_hold_date_format from nls_session_parameters
where parameter = 'NLS_DATE_FORMAT';
execute immediate 'alter session set nls_date_format = ''DD-MON-
YYYY HH24:MI''';
end if;
begin
v_cursor_id := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor_id, p_sql_statement, DBMS_SQL.V7);
DBMS_SQL.DESCRIBE_COLUMNS(v_cursor_id, column_high, v_describe);
hold_sql := 'select ';
hold_sql_needed := null;
hold_exclude_cols := false;
hold_sql_remain := ltrim(substr(replace(p_sql_statement,chr(10),
' '), 7));
for value_counter in 1..column_high loop
if v_describe(value_counter).col_type = T_LONG then
hold_length := 25000;
else
hold_length := to_number(v_describe(value_counte
r).col_max_len);
end if;
if v_describe(value_counter).col_type in (T_DATE, T_VARC
HAR2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.DEFINE_COLUMN(v_cursor_id, value_counte
r, hold_string, greatest(hold_length,30));
elsif v_describe(value_counter).col_type = T_CLOB then
DBMS_SQL.DEFINE_COLUMN(v_cursor_id, value_counte
r, hold_clob);
else
null;
end if;
hold_string := v_describe(value_counter).col_name;
if value_counter = 1 then
v_col_values := V2T(replace(initcap(hold_string)
,'|','<br>'));
else
v_col_values.EXTEND;
v_col_values(value_counter) := replace(initcap(h
old_string),'|','<br>');
end if;
if substr(hold_sql_remain,1,1) != '*' then
hold_end_pos := 1;
hold_open_paren := 0;
loop
if substr(hold_sql_remain,hold_end_pos,1
) = '(' then
hold_open_paren := hold_open_par
en + 1;
elsif substr(hold_sql_remain,hold_end_po
s,1) = ')' then
hold_open_paren := hold_open_par
en - 1;
elsif substr(hold_sql_remain,hold_end_po
s,1) = ','
or lower(substr(hold_sql_remain, hold
_end_pos, 4)) = ' from ' then
if hold_open_paren = 0 then
exit;
end if;
end if;
hold_end_pos := hold_end_pos + 1;
if hold_end_pos > length(p_sql_statement
) then
exit;
end if;
end loop;
hold_element := substr(hold_sql_remain, 1, hold_
end_pos);
hold_sql_remain := ltrim(substr(hold_sql_remain,
hold_end_pos + 1));
else
hold_element := v_describe(value_counter).col_na
me;
end if;
if v_describe(value_counter).col_type in (T_VARCHAR2, T_
CHAR, T_NUMBER, T_DATE, T_LONG, T_CLOB, T_ROWID) then
hold_sql := hold_sql || hold_sql_needed || hold_
element;
else
hold_exclude_cols := true;
end if;
hold_sql_needed := ', ';
end loop;
if hold_exclude_cols then
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);
hold_sql := hold_sql || ' ' || substr(p_sql_statement,in
str(lower(p_sql_statement),' from '));
row_counter := Display_SQL (hold_sql, table_alias, displ
ay_longs, p_current_exec + 1) + 1;
else
if nvl(p_ind_level,0) != 0 then
line_out('<div class=ind'||to_char(p_ind_level)||'>');
end if;
v_dummy := DBMS_SQL.EXECUTE(v_cursor_id); -------->find
null columns
row_counter2 := 1;
loop
if DBMS_SQL.FETCH_ROWS(v_cursor_id) = 0 then
exit;
end if;
for value_counter in 1..column_high loop
if v_describe(value_counter).col_type in
(T_DATE, T_VARCHAR2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_string);
else
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_clob);
hold_string := 'CLOB';
end if;
hold_option := null;
if v_describe(value_counter).col_type =
T_DATE then
hold_string := replace(hold_stri
ng,' ','&nbsp;');
hold_option := 'nowrap align=rig
ht';
elsif v_describe(value_counter).col_type
= T_VARCHAR2 then
hold_string := replace(replace(h
old_string,'<','&lt;'),'>','&gt;');
if hold_string != rtrim(hold_str
ing) then
hold_option := 'nowrap b
gcolor=yellow';
else
hold_option := 'nowrap';
end if;
elsif v_describe(value_counter).col_type
= T_NUMBER then
hold_option := 'nowrap align=rig
ht';
else
null;
end if;
hold_string := replace(hold_string,' ','
&nbsp;');
if value_counter = 1 then
v_valuesN := v2t(hold_string);
else
v_valuesN.EXTEND;
v_valuesN(value_counter) := v_va
luesN(value_counter)||hold_string;
end if;
end loop;
row_counter2 := row_counter2 + 1;
end loop;
if table_alias is not null then
line_out('<br><span class="BigPrint">' || table_
alias ||'</span>');
end if;
Start_Table(table_alias);
line_out('<tr>');
line_out('<th id=1>Column</th>');
for i in 1..row_counter2-1 loop
if i > l_max_rows then
exit;
end if;
line_out('<th id='||(i)||'> Row '||(i)||'</th>')
;

end loop;
line_out('</tr>');
column_high2 := column_high;

v_values2 := V2T('');
v_options2 := V2T('');

v_dummy := DBMS_SQL.EXECUTE(v_cursor_id);
row_counter := 1;
loop
if DBMS_SQL.FETCH_ROWS(v_cursor_id) = 0 then
exit;
end if;
for value_counter in 1..column_high loop
if v_describe(value_counter).col_type in
(T_DATE, T_VARCHAR2, T_NUMBER, T_CHAR, T_ROWID) then
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_string);
else
DBMS_SQL.COLUMN_VALUE(v_cursor_i
d, value_counter, hold_clob);
hold_string := 'CLOB';
end if;
--hold_string := nvl(hold_string,NULL);
--hold_string := nvl(hold_string,'&nbsp;
');
hold_option := null;
if v_describe(value_counter).col_type =
T_DATE then
hold_string := replace(hold_stri
ng,' ','&nbsp;');
hold_option := 'nowrap align=rig
ht';
elsif v_describe(value_counter).col_type
= T_VARCHAR2 then
hold_string := replace(replace(h
old_string,'<','&lt;'),'>','&gt;');
if hold_string != rtrim(hold_str
ing) then
hold_option := 'nowrap b
gcolor=yellow';
else
hold_option := 'nowrap';
end if;
elsif v_describe(value_counter).col_type
= T_NUMBER then
hold_option := 'nowrap align=rig
ht';
else
null;
end if;
hold_string := replace(hold_string,' ','&nbsp;');
if value_counter = 1 then
v_values := V2T('~1~2'||hold_str
ing||'~8~9');
else
v_values.EXTEND;
v_values(value_counter) := '~1~2
'||hold_string||'~8~9';
end if;
v_values2.EXTEND;
v_values2(value_counter) := v_values2(value_counter)||v_values(value_counter);

end loop;
row_counter := row_counter + 1;
if row_counter > nvl(l_max_rows,row_counter) then
exit;
end if;
v_col_values_count := v_col_values.count;
end loop;
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);

if v_col_values_count <> 0 then


for i in 1..v_col_values_count loop

if v_valuesN(i) is not null or p_null = 'Y' then


line_out('<tr>');
if p_spaces = 'Y' then
if v_describe(i).col_type in (T_NUMBER, T_DATE) then
line_out('<td align=left headers="'||1||'" nowrap>'||'<tt>' ||v_col_valu
es(i)||' </tt>'||'</td></N>'||chr(10)||
replace(replace(v_values2(i),'~1~2','<td align=left headers="'||(i)||'"
nowrap><tt>'), '~8~9','</tt></td></N>')||chr(10));
else

line_out('<td align=left headers="'||1||'" nowrap>'||'<tt>' ||v_col_valu


es(i)||' </tt>'||'</td></N>'||chr(10)||
replace(replace(v_values2(i),'~1~2','<td align=left headers="'||(i)||'"
nowrap><tt>&gt;'), '~8~9','&lt;</tt></td></N>')||chr(10));
end if;
else
line_out('<td align=left headers="'||1||'" nowrap>'||'<tt>' ||v_col_values(i)||'
</tt>'||'</td></N>'||chr(10)||
replace(replace(v_values2(i),'~1~2','<td align=left headers="'||(i)||'" nowrap><
tt>'), '~8~9','</tt></td></N>')||chr(10));
end if;
line_out('</tr>');
end if;

end loop;
end if;
Show_Table('END');
end if;
if p_current_exec = 0 and p_feedback = 'Y' then
if row_counter = 1 then
l_feedback_txt := '<BR><span class="SmallPrint">'||
'0 Rows Selected</span><br>';
elsif row_counter = 2 then
l_feedback_txt := '<span class="SmallPrint">'||
'1 Row Selected</span><br>';
else
l_feedback_txt := '<span class="SmallPrint">'||
ltrim(to_char(row_counter - 1,'9999999')) ||
' Rows Selected</span><br>';
end if;
line_out(l_feedback_txt);
execute immediate 'alter session set nls_date_format = '
'' || l_hold_date_format || '''';
end if;
return row_counter-1;
exception
when others then
line_out('</table><br>');
error_position := DBMS_SQL.LAST_ERROR_POSITION;
ErrorPrint(sqlerrm || ' occurred in display_sqlPL');
ActionErrorPrint('Please report the error below to suppo
rt.');
line_out('Position: ' || error_position || ' of ' || le
ngth(p_sql_statement) || '<br>');
line_out(replace(substr(p_sql_statement,1,error_position
),chr(10),'<br>'));
error_position_end := instr(p_sql_statement,' ',error_po
sition+1) - error_position;
line_out('<span class="error">' || replace(substr(p_sql_
statement,error_position+1, error_position_end),chr(10),'<br>') || '</span>');
line_out(replace(substr(p_sql_statement,error_position+e
rror_position_end+1),chr(10),'<br>') || '<br>');
DBMS_SQL.CLOSE_CURSOR(v_cursor_id);
if p_current_exec = 0 then
execute immediate 'alter session set nls_date_fo
rmat = ''' || l_hold_date_format || '''';
end if;
return -1;
end;
end display_sqlPL;

-- Function Name: Run_SQLPL


--
-- Usage:
-- a_number := Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows',
-- 'Indent Level', 'Layout', 'Null Columns', 'Show Spac
es');
--
-- Parameters:
-- Heading - Text String to for heading the output
-- SQL Statement - Any valid SQL Select Statement
-- Feedback - Y or N to indicate whether to automatically print the
-- number of rows returned (default 'Y')
-- Max Rows - Limit the output to this many rows. NULL or ZERO values
-- indicate unlimited rows (default NULL)
-- Indent Level - Indicate if table should be indented and by how much
-- 0=No indentation, 1=.25in, 2=.5in, 3=.75in (default 0)
-- Layout - P, PL or L - If set to P the columns for each row will be prin
ted
-- down the page in a portrait format. And each additional row wil
l be printed below the
-- previous in the same format. If set to PL the columns for e
ach row will
-- be printed down the page in a portrait format. And each add
itional row will be printed next
-- to the previous in the same format. If set to L the columns
will be printed
-- across the page in a landscape format.
-- Null Columns - Y or N - If set to Y Null columns will Null values will be
displayed. If set to N
-- columns with null values will not be displayed.
-- Show Spaces - Y or N - If set to Y, column value will be enclosed by ><
to show leading and
-- trailing spaces. If set to N, only the column value
will be displayed.
--
-- Returns:
-- The function returns the # of rows selected.
-- If there is an error then the function returns -1.
--
-- Output:
-- Displays the output of the SQL statement as an HTML table.
--
-- Examples:
-- declare
-- num_rows number;
-- begin
-- num_rows := Run_SQL('AR Parameters','select * from ar_system_paramete
rs_all', 'N',0,0,'P','Y','Y');
-- end;
--
function RUN_SQLPL(p_title varchar2, p_sql_statement varchar2, p_feedback varcha
r2 default 'Y', p_max_rows number default 0, p_ind_level number, p_layout varcha
r2 default 'P', p_null varchar2 default 'Y', p_spaces varchar2 default 'N') retu
rn number is
begin
if p_layout = 'P' then
return(display_sqlP(p_sql_statement, p_title, 'Y', p_feedback, p_max_row
s, p_ind_level, p_null, p_spaces));
elsif p_layout = 'PL' then
return(display_sqlP(p_sql_statement, p_title, 'Y', p_feedback, p_max_row
s, p_ind_level, p_null, p_spaces));
else
return(Display_SQL(p_sql_statement, p_title, 'Y','Y',null,0,'N',0,p_null
, p_spaces));

end if;
end RUN_SQLPL;

-- Procedure Name: Run_SQL


--
-- Usage:
-- Run_SQL('Heading', 'SQL statement', 'Feedback', 'Max Rows', 'Indent Leve
l', 'Layout', 'Null Columns', 'Show Spaces');
--
-- Parameters:
-- Heading - Text String to for heading the output
-- SQL Statement - Any valid SQL Select Statement
-- Feedback - Y or N to indicate whether to automatically print the
-- number of rows returned (default 'Y')
-- Max Rows - Limit the output to this many rows. NULL or ZERO values
-- indicate unlimited rows (default NULL)
-- Indent Level - Indicate if table should be indented and by how much
-- 0=No indentation, 1=.25in, 2=.5in, 3=.75in (default 0)
-- Layout - P, PL or L - If set to P the columns for each row will be prin
ted
-- down the page in a portrait format. And each additional row wil
l be printed below the
-- previous in the same format. If set to PL the columns for e
ach row will
-- be printed down the page in a portrait format. And each add
itional row will be printed next
-- to the previous in the same format. If set to L the columns
will be printed
-- across the page in a landscape format.
-- Null Columns - Y or N - If set to Y Null columns will Null values will be
displayed. If set to N
-- columns with null values will not be displayed.
-- Show Spaces - Y or N - If set to Y, column value will be enclosed by ><
to show leading and
-- trailing spaces. If set to N, only the column value
will be displayed.
--
-- Output:
-- Displays the output of the SQL statement as an HTML table.
--
-- Examples:
-- begin
-- Run_SQL('AR Parameters','select * from ar_system_parameters_all', 'N'
,0,0,'P','Y');
-- end;
--

procedure RUN_SQLPL(p_title varchar2, p_sql_statement varchar2, p_feedback varch


ar2 default 'Y', p_max_rows number default 0, p_ind_level number default 0, p_la
yout varchar2 default 'P', p_null varchar2 default 'Y', p_spaces varchar2 defaul
t 'N') is
dummy number;
begin
if p_layout = 'P' then
dummy := display_sqlP(p_sql_statement, p_title, 'Y', p_feedback, p_max_r
ows, p_ind_level, p_null, p_spaces);
elsif p_layout = 'PL' then
dummy := display_sqlPL(p_sql_statement, p_title, 'Y', p_feedback, p_max_
rows, p_ind_level, p_null, p_spaces);
else
dummy := Display_SQL(p_sql_statement, p_title, 'Y','Y',null,0,'N',0,p_nu
ll, p_spaces);
end if;
end RUN_SQLPL;

/*******************************************************************************
******************************************
End of Modified Run_SQL Code. The code was modified to allow the columns to be
displayed in Portrait layout format
********************************************************************************
*****************************************/
--------------------- Addon API end--------------------------------------------
--------------------- CUSTOM API start ----------------------------------------
function get_db_version
return varchar2 is
l_ver varchar2(17);
begin
select max(version) into l_ver from v$instance;
return l_ver;
end get_db_version;
function get_fnd_version
return varchar2 is
l_ver varchar2(50);
begin
select release_name into l_ver from fnd_product_groups where product_group_id
= 1;
return l_ver;
end get_fnd_version;
function check_version(p_ver1 varchar2, p_ver2 varchar2)
return varchar2 is
l_ver1 varchar2(50) := p_ver1;
l_ver2 varchar2(50) := p_ver2;
v1 varchar2(50);
v2 varchar2(50);
begin
if lower(l_ver1) = 'db' then
l_ver1 := get_db_version;
elsif lower(l_ver1) = 'fnd' then
l_ver1 := get_fnd_version;
end if;
if lower(l_ver2) = 'db' then
l_ver2 := get_db_version;
elsif lower(l_ver2) = 'fnd' then
l_ver2 := get_fnd_version;
end if;
l_ver1 := replace(l_ver1,' ','')||'.';
l_ver2 := replace(l_ver2,' ','')||'.';
loop
exit when l_ver1 is null and l_ver2 is null;
v1 := nvl(to_number(substr(l_ver1, 1, instr(l_ver1,'.', 1,1)-1)),0);
v2 := nvl(to_number(substr(l_ver2, 1, instr(l_ver2,'.', 1,1)-1)),0);
if v1>v2 then
return('greater');
end if;
if v1<v2 then
return('lesser');
end if;
l_ver1 := substr(l_ver1, instr(l_ver1,'.',1,1)+1, length(l_ver1)-instr(l_ver1,
'.',1,1)+1);
l_ver2 := substr(l_ver2, instr(l_ver2,'.',1,1)+1, length(l_ver2)-instr(l_ver2,
'.',1,1)+1);
end loop;
return('equal');
exception
when others then
return('error');
end check_version;
procedure show_code(p_code varchar2) is
begin
line_out('<br><span class="code">');
line_out(replace(replace(p_code,chr(10),'<br>'),' ','&nbsp;'));
line_out('</span><br>');
end show_code;
procedure new_section(p_text varchar2) is
begin
line_out('<hr><center><h3>'||p_text||'</h3></center>');
end new_section;
--------------------- CUSTOM API end ------------------------------------------
begin -- begin1
declare
sqlTxt varchar2(32767);
l_param1 varchar2(100) := '&&1'; --rtrim(ltrim('&&1'));
l_param2 varchar2(100) := '&&2'; --rtrim(ltrim('&&2'));
l_param3 varchar2(100) := '&&3'; --rtrim(ltrim('&&3'));
l_var1 varchar2(4000);
l_var2 varchar2(4000);
l_var3 varchar2(4000);
l_var4 varchar2(4000);
l_var5 varchar2(4000);
l_num1 number;
l_num2 number;
l_num3 number;
l_num4 number;
l_num5 number;
l_date1 date;
l_date2 date;
l_date3 date;
l_date4 date;
l_date5 date;
l_timecard_id number;
l_ovn number;
l_resource_id number;
l_start_date varchar2(11);
l_stop_date varchar2(11);
l_timid number;
begin -- begin2
--Show_Header('9999999.999', '&v_scriptlongname');
Show_Header('9999999.999', '&v_scriptlongname', '&v_headerinfo', '&v_queries_ver
');
sqlTxt := 'select ''&&1'' Parameter1, ''&&2'' Parameter2, ''&&3'' Parameter3 fro
m dual';
run_sql('Parameters', sqltxt);

if upper('&&1') = 'HXC.HXC_TC' then


-- ************************
-- *** HXC.HXC_TC.. Syntax: Parameter1: HXC.HXC_TC, Parameter2: <person_id>, Pa
rameter3: <start date>
-- ************************
select time_building_block_id, object_version_number, resource_id, to_char(start
_time,'DD-MON-YYYY'), to_char(stop_time,'DD-MON-YYYY')
into l_timecard_id, l_ovn, l_resource_id, l_start_date, l_stop_date
from HXC.HXC_time_building_blocks
where (time_building_block_id, object_version_number) =
(select time_building_block_id, max(object_version_number)
from HXC.HXC_time_building_blocks
where time_building_block_id in
(select max(time_building_block_id)
from HXC.HXC_time_building_blocks
where scope = 'TIMECARD'
and resource_id = ('&&2')
and trunc(start_time) = to_date('&&3'))
group by time_building_block_id);

sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD''


and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'') order by t
ime_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date('
'&&3''))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date
(''&&3''))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DAY'' and
parent_building_block_id in (select time_building_block_id from HXC.HXC_time_bui
lding_blocks where scope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(st
art_time) = to_date(''&&3'')) order by time_building_block_id, object_version_nu
mber';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DAY'' and parent_building_block_id in (select time_building_block_id fro
m HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and resource_id = (''&
&2'') and trunc(start_time) = to_date(''&&3'')))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DAY'' and parent_building_block_id in (select time_building_block_id f
rom HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and resource_id = ('
'&&2'') and trunc(start_time) = to_date(''&&3'')))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' a
nd parent_building_block_id in (select time_building_block_id from HXC.HXC_time_
building_blocks where scope = ''DAY'' and parent_building_block_id in (select ti
me_building_block_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'
' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))) order b
y time_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DETAIL'' and parent_building_block_id in (select time_building_block_id
from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bloc
k_id in (select time_building_block_id from HXC.HXC_time_building_blocks where s
cope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(
''&&3''))))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DETAIL'' and parent_building_block_id in (select time_building_block_i
d from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bl
ock_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_dat
e(''&&3''))))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope not in (''TIME
CARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and trunc(start_time) = t
o_date(''&&3'') order by time_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and tru
nc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and t
runc(start_time) = to_date(''&&3''))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Other', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TC_AUDIT_SUMMARY where timecard_id in (select
time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECA
RD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
--run_sql('HXC.HXC_TC_AUDIT_SUMMARY', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TIMECARD_AUDIT_SUMMARY where timecard_id in (
select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''
TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))
';
--run_sql('HXC.HXC_TIMECARD_AUDIT_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIMECARD_SUMMARY where timecard_id in (select t
ime_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD
'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TIMECARD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TC_AP_LINKS where timecard_id in (select time_b
uilding_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD'' an
d resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TC_AP_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_APP_PERIOD_SUMMARY where application_period_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''APPLICATION_PERIOD'' and resource_id = (''&&2'') and trunc(start_time) = to_
date(''&&3''))';
run_sql('HXC.HXC_APP_PERIOD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_AP_DETAIL_LINKS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from H
XC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id i
n (select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'
'))))';
run_sql('HXC.HXC_AP_DETAIL_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_LATEST_DETAILS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = '
'DETAIL'' and parent_building_block_id in (select time_building_block_id from HX
C.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in
(select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''
))))';
run_sql('HXC.HXC_LATEST_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTION_DETAILS where time_building_block_i
d in (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scop
e = ''DETAIL'' and parent_building_block_id in (select time_building_block_id fr
om HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''
&&3''))))';
run_sql('HXC.HXC_TRANSACTION_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTIONS where transaction_id in (select tr
ansaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id in (s
elect time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''D
ETAIL'' and parent_building_block_id in (select time_building_block_id from HXC.
HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in (
select time_building_block_id from HXC.HXC_time_building_blocks where scope = ''
TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))
))) order by transaction_date';
run_sql('HXC.HXC_TRANSACTIONS', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGES where transaction_id in (selec
t transaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id i
n (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3
'')))))';
run_sql('HXC.HXC_RETRIEVAL_RANGES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGE_RESOURCES where resource_id = (
''&&2'') and retrieval_range_id in (select retrieval_range_id from HXC.HXC_retri
eval_ranges where transaction_id in (select transaction_id from HXC.HXC_TRANSACT
ION_DETAILS where time_building_block_id in (select time_building_block_id from
HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''DAY'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and resource_id = (''&&
2'') and trunc(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_RETRIEVAL_RANGE_RESOURCES', sqltxt);
sqlTxt := 'select * from HXC.HXC_DEPOSIT_PROCESSES where deposit_process_id in (
select transaction_process_id from HXC.HXC_transactions where type = ''DEPOSIT''
and transaction_id in (select transaction_id from HXC.HXC_TRANSACTION_DETAILS w
here time_building_block_id in (select time_building_block_id from HXC.HXC_TIME_
BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_id in (select
time_building_block_id from HXC.HXC_time_building_blocks where scope = ''DAY''
and parent_building_block_id in (select time_building_block_id from HXC.HXC_time
_building_blocks where scope = ''TIMECARD'' and resource_id = (''&&2'') and trun
c(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_DEPOSIT_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_PROCESSES where retrieval_process_id
in (select transaction_process_id from HXC.HXC_transactions where type = ''RETRI
EVAL'' and transaction_id in (select transaction_id from HXC.HXC_TRANSACTION_DET
AILS where time_building_block_id in (select time_building_block_id from HXC.HXC
_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_id in (
select time_building_block_id from HXC.HXC_time_building_blocks where scope = ''
DAY'' and parent_building_block_id in (select time_building_block_id from HXC.HX
C_time_building_blocks where scope = ''TIMECARD'' and resource_id = (''&&2'') an
d trunc(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_RETRIEVAL_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPLICATION_SET_COMPS_V where application_set_i
d in (select application_set_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''
))';
run_sql('HXC.HXC_APPLICATION_SET_COMPS_V', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_STYLES where approval_style_id in (sel
ect approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD
'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_APPROVAL_STYLES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_COMPS where approval_style_id in (sele
ct approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'
' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_APPROVAL_COMPS', sqltxt);
sqlTxt := 'select * from nuan_per_people_f_mv where person_id = (''&&2'') order
by effective_start_date';
run_sql('nuan_per_people_f_mv', sqltxt);
sqlTxt := 'select * from PER_ALL_ASSIGNMENTS_F where person_id = (''&&2'') order
by effective_start_date';
run_sql('PER_ALL_ASSIGNMENTS_F', sqltxt);
Display_Table('HR_SOFT_CODING_KEYFLEX', Null, 'where soft_coding_keyflex
_id in (select soft_coding_keyflex_id from PER_ALL_ASSIGNMENTS_F where person_id
= (''&&2''))', null, 'Y');
--new_section('Workflow');
sqlTxt := '
select item_type
,item_key
,name
,text_value
,number_value
,date_value
--,event_value
,security_group_id
from WF_ITEM_ATTRIBUTE_VALUES
where item_type = ''HXC.HXCEMP''
and name = ''TC_BLD_BLK_ID''
and number_value in (select time_building_block_id from HXC.HXC_time_building_bl
ocks where scope = ''TIMECARD'' and resource_id = (''&&2'') and trunc(start_time
) = to_date(''&&3''))
order by item_key';
run_sql('WF_ITEM_ATTRIBUTE_VALUES', sqltxt);
sqlTxt := 'select * from WF_ITEMS where (item_type, item_key) in (select item_ty
pe, item_key from WF_ITEM_ATTRIBUTE_VALUES where item_type = ''HXC.HXCEMP'' and
name = ''TC_BLD_BLK_ID'' and number_value in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and resource_id = (''&&
2'') and trunc(start_time) = to_date(''&&3''))) order by item_key';
run_sql('WF_ITEMS', sqltxt);
sqlTxt := '
select item_type
, item_key
, process_activity
, activity_status
, activity_result_code
, assigned_user
, notification_id
, begin_date
, end_date
, execution_time
, error_name
, error_message
, error_stack
--, outbound_queue_id
, due_date
, security_group_id
, action
, performed_by
from wf_item_activity_statuses where (item_type, item_key) in (select item_type,
item_key from WF_ITEM_ATTRIBUTE_VALUES where item_type = ''HXC.HXCEMP'' and nam
e = ''TC_BLD_BLK_ID'' and number_value in (select time_building_block_id from HX
C.HXC_time_building_blocks where scope = ''TIMECARD'' and resource_id = (''&&2''
) and trunc(start_time) = to_date(''&&3'')))
order by item_key, process_activity';
run_sql('WF_ITEM_ACTIVITY_STATUSES', sqltxt);
--new_section('Projects');
sqlTxt := '
select ''TC Details'' source, sum(det.measure) total
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
and det.parent_building_block_ovn = day.object_version_number
and det.date_to = to_date(''31-DEC-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
UNION ALL
select ''TC Summary'' source, sum(recorded_hours) total
from HXC.HXC_timecard_summary sum
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
UNION ALL
select ''PA Expenditures'' source, sum(exp.quantity) total
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
, pa_expenditure_items_all exp
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
-- and det.parent_building_block_ovn = day.object_version_number
-- and det.date_to = to_date(''31-DEC-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
and det.time_building_block_id || '':'' || det.object_version_number = exp.or
ig_transaction_reference (+)';
run_sql('OTL/PA Totals Compare', sqltxt);
sqlTxt := 'select *
from pa_expenditures_all
where expenditure_id in (
select exp.expenditure_id
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
, pa_expenditure_items_all exp
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
-- and det.parent_building_block_ovn = day.object_version_number
-- and det.date_to = to_date(''31-Dec-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
and det.time_building_block_id || '':'' || det.object_version_number = exp.or
ig_transaction_reference (+))';
run_sql('PA_EXPENDITURES_ALL', sqltxt);
sqlTxt := 'select eia.*
from pa_expenditure_items_all eia
, pa_expenditures_all ea
, HXC.HXC_timecard_summary tcs
where eia.expenditure_id = ea.expenditure_id
and ea.incurred_by_person_id = tcs.resource_id
and tcs.resource_id = (''&&2'')
and tcs.start_time = to_date(''&&3'')
and eia.expenditure_item_date between tcs.start_time and tcs.stop_t
ime
order by expenditure_item_date';
run_sql('PA_EXPENDITURE_ITEMS_ALL', sqltxt);
sqlTxt := 'select det.time_building_block_id, det.object_version_number, exp.ori
g_transaction_reference, exp.transaction_source
, exp.expenditure_id, exp.expenditure_item_id
, day.start_time otl_day, exp.expenditure_item_date
, decode(to_char(det.date_to, ''DD-MON-YYYY''), ''31-DEC-4712'', ''ACTIVE''
, ''INACTIVE'') OTL_STATE
, det.measure otl_hours, exp.quantity
, att.attribute1 otl_project_id, exp.project_id
, att.attribute2 otl_task_id, exp.task_id
, att.attribute3 otl_expenditure_type, exp.expenditure_type
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
, pa_expenditure_items_all exp
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
-- and det.parent_building_block_ovn = day.object_version_number
-- and det.date_to = to_date(''31-DEC-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
and det.time_building_block_id || '':'' || det.object_version_number = exp.or
ig_transaction_reference (+)
order by day.start_time, det.time_building_block_id, object_version_number';
run_sql('OTL/PA Details Compare', sqltxt);
--new_section('Payroll');
sqlTxt := '
select *
from HXT_TIMECARDS_F
where for_person_id = '||l_resource_id||'
and Time_Period_Id in (
select Time_Period_Id
from PER_TIME_PERIODS
where start_date between to_date('''||l_start_date||''') and to_date('''||l_stop
_date||''')
or end_date between to_date('''||l_start_date||''') and to_date('''||l_stop
_date||''')
)';
run_sql('HXT_TIMECARDS_F', sqltxt);

--new_section('Past Timecards');
sqlTxt := 'select ''HXC.HXC_TC'' Parameter1, resource_id Parameter2, to_char(sta
rt_time, ''DD-MON-YYYY'') Parameter3 from HXC.HXC_TIMECARD_SUMMARY where resourc
e_id = (''&&2'') and start_time > sysdate - 180 order by start_time';
run_sql('Parameters to Output Timecards For Last 6 Months', sqltxt);
end if;
if upper('&&1') = 'HXC.HXC_TEMP' then
-- ************************
-- *** HXC.HXC_TEMP.. Syntax: Parameter1: HXC.HXC_TEMP, Parameter2: <person_id>
, Parameter3: <start date>
-- ************************
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD_T
EMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'') o
rder by time_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) =
to_date(''&&3''))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time)
= to_date(''&&3''))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DAY'' and
parent_building_block_id in (select time_building_block_id from HXC.HXC_time_bui
lding_blocks where scope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and
trunc(start_time) = to_date(''&&3'')) order by time_building_block_id, object_v
ersion_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DAY'' and parent_building_block_id in (select time_building_block_id fro
m HXC.HXC_time_building_blocks where scope = ''TIMECARD_TEMPLATE'' and resource_
id = (''&&2'') and trunc(start_time) = to_date(''&&3'')))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DAY'' and parent_building_block_id in (select time_building_block_id f
rom HXC.HXC_time_building_blocks where scope = ''TIMECARD_TEMPLATE'' and resourc
e_id = (''&&2'') and trunc(start_time) = to_date(''&&3'')))) order by time_attri
bute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' a
nd parent_building_block_id in (select time_building_block_id from HXC.HXC_time_
building_blocks where scope = ''DAY'' and parent_building_block_id in (select ti
me_building_block_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD_
TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))
) order by time_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DETAIL'' and parent_building_block_id in (select time_building_block_id
from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bloc
k_id in (select time_building_block_id from HXC.HXC_time_building_blocks where s
cope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) =
to_date(''&&3''))))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DETAIL'' and parent_building_block_id in (select time_building_block_i
d from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bl
ock_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time)
= to_date(''&&3''))))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope not in (''TIME
CARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and trunc(start_time) = t
o_date(''&&3'') order by time_building_block_id, object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and tru
nc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and t
runc(start_time) = to_date(''&&3''))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Other', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TC_AUDIT_SUMMARY where timecard_id in (select
time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECA
RD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'
'))';
--run_sql('HXC.HXC_TC_AUDIT_SUMMARY', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TIMECARD_AUDIT_SUMMARY where timecard_id in (
select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''
TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(
''&&3''))';
--run_sql('HXC.HXC_TIMECARD_AUDIT_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIMECARD_SUMMARY where timecard_id in (select t
ime_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD
_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'')
)';
run_sql('HXC.HXC_TIMECARD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TC_AP_LINKS where timecard_id in (select time_b
uilding_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD_TEMP
LATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TC_AP_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_APP_PERIOD_SUMMARY where application_period_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''APPLICATION_PERIOD'' and resource_id = (''&&2'') and trunc(start_time) = to_
date(''&&3''))';
run_sql('HXC.HXC_APP_PERIOD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_AP_DETAIL_LINKS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from H
XC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id i
n (select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_da
te(''&&3''))))';
run_sql('HXC.HXC_AP_DETAIL_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_LATEST_DETAILS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = '
'DETAIL'' and parent_building_block_id in (select time_building_block_id from HX
C.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in
(select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_dat
e(''&&3''))))';
run_sql('HXC.HXC_LATEST_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTION_DETAILS where time_building_block_i
d in (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scop
e = ''DETAIL'' and parent_building_block_id in (select time_building_block_id fr
om HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = t
o_date(''&&3''))))';
run_sql('HXC.HXC_TRANSACTION_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTIONS where transaction_id in (select tr
ansaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id in (s
elect time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''D
ETAIL'' and parent_building_block_id in (select time_building_block_id from HXC.
HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in (
select time_building_block_id from HXC.HXC_time_building_blocks where scope = ''
TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(
''&&3''))))) order by transaction_date';
run_sql('HXC.HXC_TRANSACTIONS', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGES where transaction_id in (selec
t transaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id i
n (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_d
ate(''&&3'')))))';
run_sql('HXC.HXC_RETRIEVAL_RANGES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGE_RESOURCES where resource_id = (
''&&2'') and retrieval_range_id in (select retrieval_range_id from HXC.HXC_retri
eval_ranges where transaction_id in (select transaction_id from HXC.HXC_TRANSACT
ION_DETAILS where time_building_block_id in (select time_building_block_id from
HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''DAY'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''TIMECARD_TEMPLATE'' and resource_i
d = (''&&2'') and trunc(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_RETRIEVAL_RANGE_RESOURCES', sqltxt);
sqlTxt := 'select * from HXC.HXC_DEPOSIT_PROCESSES where deposit_process_id in (
select transaction_process_id from HXC.HXC_transactions where type = ''DEPOSIT''
and transaction_id in (select transaction_id from HXC.HXC_TRANSACTION_DETAILS w
here time_building_block_id in (select time_building_block_id from HXC.HXC_TIME_
BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_id in (select
time_building_block_id from HXC.HXC_time_building_blocks where scope = ''DAY''
and parent_building_block_id in (select time_building_block_id from HXC.HXC_time
_building_blocks where scope = ''TIMECARD_TEMPLATE'' and resource_id = (''&&2'')
and trunc(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_DEPOSIT_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_PROCESSES where retrieval_process_id
in (select transaction_process_id from HXC.HXC_transactions where type = ''RETRI
EVAL'' and transaction_id in (select transaction_id from HXC.HXC_TRANSACTION_DET
AILS where time_building_block_id in (select time_building_block_id from HXC.HXC
_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_id in (
select time_building_block_id from HXC.HXC_time_building_blocks where scope = ''
DAY'' and parent_building_block_id in (select time_building_block_id from HXC.HX
C_time_building_blocks where scope = ''TIMECARD_TEMPLATE'' and resource_id = (''
&&2'') and trunc(start_time) = to_date(''&&3''))))))';
run_sql('HXC.HXC_RETRIEVAL_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPLICATION_SET_COMPS_V where application_set_i
d in (select application_set_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_dat
e(''&&3''))';
run_sql('HXC.HXC_APPLICATION_SET_COMPS_V', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_STYLES where approval_style_id in (sel
ect approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD
_TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3'')
)';
run_sql('HXC.HXC_APPROVAL_STYLES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_COMPS where approval_style_id in (sele
ct approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD_
TEMPLATE'' and resource_id = (''&&2'') and trunc(start_time) = to_date(''&&3''))
';
run_sql('HXC.HXC_APPROVAL_COMPS', sqltxt);
sqlTxt := 'select * from nuan_per_people_f_mv where person_id = (''&&2'') order
by effective_start_date';
run_sql('nuan_per_people_f_mv', sqltxt);
sqlTxt := 'select * from PER_ALL_ASSIGNMENTS_F where person_id = (''&&2'') order
by effective_start_date';
run_sql('PER_ALL_ASSIGNMENTS_F', sqltxt);
sqlTxt := '
select ''TC Details'' source, sum(det.measure) total
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
and det.parent_building_block_ovn = day.object_version_number
and det.date_to = to_date(''31-DEC-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
UNION ALL
select ''TC Summary'' source, sum(recorded_hours) total
from HXC.HXC_timecard_summary sum
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
UNION ALL
select ''PA Expenditures'' source, sum(exp.quantity) total
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
, pa_expenditure_items_all exp
where sum.resource_id = (''&&2'')
and trunc(sum.start_time) = to_date(''&&3'')
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
-- and det.parent_building_block_ovn = day.object_version_number
-- and det.date_to = to_date(''31-DEC-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and att.attribute_category = ''PROJECTS''
and det.time_building_block_id || '':'' || det.object_version_number = exp.or
ig_transaction_reference (+)';
run_sql('OTL/PA Totals Compare', sqltxt);
sqlTxt := 'select ''HXC.HXC_TC'' Parameter1, resource_id Parameter2, to_char(sta
rt_time, ''DD-MON-YYYY'') Parameter3 from HXC.HXC_TIMECARD_SUMMARY where resourc
e_id = (''&&2'') and start_time > sysdate - 180 order by start_time';
run_sql('Parameters to Output Timecards For Last 6 Months', sqltxt);
end if;

if upper('&&1') = 'HXC.HXC_TC_P' then


-- ************************
-- *** HXC.HXC_TC_P.. Syntax: Parameter1: HXC.HXC_TC_P, Parameter2: <person_id>
, Parameter3: <start date>
-- ************************
-- Modified for performance. Will not show records related to deleted timecards
.
select timecard_id
into l_num1
from HXC.HXC_TIMECARD_SUMMARY
where resource_id = ('&&2')
and trunc(start_time) = to_date('&&3');
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD''
and time_building_block_id = ('||l_num1||')';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))) order by time
_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DAY'' and
parent_building_block_id in (select time_building_block_id from HXC.HXC_time_bui
lding_blocks where scope = ''TIMECARD'' and time_building_block_id = ('||l_num1|
|'))';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DAY'' and parent_building_block_id in (select time_building_block_id fro
m HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_bloc
k_id = ('||l_num1||')))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DAY'' and parent_building_block_id in (select time_building_block_id f
rom HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_bl
ock_id = ('||l_num1||')))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' a
nd parent_building_block_id in (select time_building_block_id from HXC.HXC_time_
building_blocks where scope = ''DAY'' and parent_building_block_id in (select ti
me_building_block_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'
' and time_building_block_id = ('||l_num1||'))) order by time_building_block_id,
object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DETAIL'' and parent_building_block_id in (select time_building_block_id
from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bloc
k_id in (select time_building_block_id from HXC.HXC_time_building_blocks where s
cope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DETAIL'' and parent_building_block_id in (select time_building_block_i
d from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bl
ock_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))) order by t
ime_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope not in (''TIME
CARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and trunc(start_time) = t
o_date(''&&3'')';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and tru
nc(start_time) = to_date(''&&3''))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope not in (''TIMECARD'',''DAY'',''DETAIL'') and resource_id = (''&&2'') and t
runc(start_time) = to_date(''&&3''))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Other', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TC_AUDIT_SUMMARY where timecard_id in (select
time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECA
RD'' and time_building_block_id = ('||l_num1||'))';
--run_sql('HXC.HXC_TC_AUDIT_SUMMARY', sqltxt);
--sqlTxt := 'select * from HXC.HXC_TIMECARD_AUDIT_SUMMARY where timecard_id in (
select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''
TIMECARD'' and time_building_block_id = ('||l_num1||'))';
--run_sql('HXC.HXC_TIMECARD_AUDIT_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIMECARD_SUMMARY where timecard_id in (select t
ime_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD
'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_TIMECARD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_TC_AP_LINKS where timecard_id in (select time_b
uilding_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD'' an
d time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_TC_AP_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_APP_PERIOD_SUMMARY where application_period_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''APPLICATION_PERIOD'' and resource_id = (''&&2'') and trunc(start_time) = to_
date(''&&3''))';
run_sql('HXC.HXC_APP_PERIOD_SUMMARY', sqltxt);
sqlTxt := 'select * from HXC.HXC_AP_DETAIL_LINKS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from H
XC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id i
n (select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and time_building_block_id = ('||l_num1||'))))';
run_sql('HXC.HXC_AP_DETAIL_LINKS', sqltxt);
sqlTxt := 'select * from HXC.HXC_LATEST_DETAILS where time_building_block_id in
(select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = '
'DETAIL'' and parent_building_block_id in (select time_building_block_id from HX
C.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in
(select time_building_block_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and time_building_block_id = ('||l_num1||'))))';
run_sql('HXC.HXC_LATEST_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTION_DETAILS where time_building_block_i
d in (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scop
e = ''DETAIL'' and parent_building_block_id in (select time_building_block_id fr
om HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))';
run_sql('HXC.HXC_TRANSACTION_DETAILS', sqltxt);
sqlTxt := 'select * from HXC.HXC_TRANSACTIONS where transaction_id in (select tr
ansaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id in (s
elect time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''D
ETAIL'' and parent_building_block_id in (select time_building_block_id from HXC.
HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id in (
select time_building_block_id from HXC.HXC_time_building_blocks where scope = ''
TIMECARD'' and time_building_block_id = ('||l_num1||')))))';
run_sql('HXC.HXC_TRANSACTIONS', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGES where transaction_id in (selec
t transaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_block_id i
n (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope =
''DETAIL'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_block_id
in (select time_building_block_id from HXC.HXC_time_building_blocks where scope
= ''TIMECARD'' and time_building_block_id = ('||l_num1||')))))';
run_sql('HXC.HXC_RETRIEVAL_RANGES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_RANGE_RESOURCES where resource_id = (
''&&2'') and retrieval_range_id in (select retrieval_range_id from HXC.HXC_retri
eval_ranges where transaction_id in (select transaction_id from HXC.HXC_TRANSACT
ION_DETAILS where time_building_block_id in (select time_building_block_id from
HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' and parent_building_block_
id in (select time_building_block_id from HXC.HXC_time_building_blocks where sco
pe = ''DAY'' and parent_building_block_id in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_block
_id = ('||l_num1||'))))))';
run_sql('HXC.HXC_RETRIEVAL_RANGE_RESOURCES', sqltxt);
sqlTxt := 'select * from HXC.HXC_DEPOSIT_PROCESSES where deposit_process_id in (
select transaction_process_id from HXC.HXC_transactions where transaction_id in
(select transaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_bloc
k_id in (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where s
cope = ''DETAIL'' and parent_building_block_id in (select time_building_block_id
from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))))';
run_sql('HXC.HXC_DEPOSIT_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_RETRIEVAL_PROCESSES where retrieval_process_id
in (select transaction_process_id from HXC.HXC_transactions where transaction_id
in (select transaction_id from HXC.HXC_TRANSACTION_DETAILS where time_building_
block_id in (select time_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS whe
re scope = ''DETAIL'' and parent_building_block_id in (select time_building_bloc
k_id from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building
_block_id in (select time_building_block_id from HXC.HXC_time_building_blocks wh
ere scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))))';
run_sql('HXC.HXC_RETRIEVAL_PROCESSES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPLICATION_SET_COMPS_V where application_set_i
d in (select application_set_id from HXC.HXC_time_building_blocks where scope =
''TIMECARD'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_APPLICATION_SET_COMPS_V', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_STYLES where approval_style_id in (sel
ect approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD
'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_APPROVAL_STYLES', sqltxt);
sqlTxt := 'select * from HXC.HXC_APPROVAL_COMPS where approval_style_id in (sele
ct approval_style_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'
' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_APPROVAL_COMPS', sqltxt);
sqlTxt := 'select * from WF_ITEM_ATTRIBUTE_VALUES where item_type = ''HXC.HXCEMP
'' and name = ''TC_BLD_BLK_ID'' and number_value in (select time_building_block_
id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_buildin
g_block_id = ('||l_num1||'))';
run_sql('WF_ITEM_ATTRIBUTE_VALUES', sqltxt);
sqlTxt := 'select * from WF_ITEMS where (item_type, item_key) in (select item_ty
pe, item_key from WF_ITEM_ATTRIBUTE_VALUES where item_type = ''HXC.HXCEMP'' and
name = ''TC_BLD_BLK_ID'' and number_value in (select time_building_block_id from
HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_block
_id = ('||l_num1||')))';
run_sql('WF_ITEMS', sqltxt);
--sqlTxt := 'select * from wf_item_activity_statuses where (item_type, item_key)
in (select item_type, item_key from WF_ITEM_ATTRIBUTE_VALUES where item_type =
''HXC.HXCEMP'' and name = ''TC_BLD_BLK_ID'' and number_value in (select time_bui
lding_block_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and
time_building_block_id = ('||l_num1||')))';
--run_sql('WF_ITEM_ACTIVITY_STATUSES', sqltxt);
sqlTxt := 'select * from nuan_per_people_f_mv where person_id = (''&&2'') order
by effective_start_date';
run_sql('nuan_per_people_f_mv', sqltxt);
sqlTxt := 'select * from PER_ALL_ASSIGNMENTS_F where person_id = (''&&2'') order
by effective_start_date';
run_sql('PER_ALL_ASSIGNMENTS_F', sqltxt);
sqlTxt := 'select resource_id, to_char(start_time, ''DD-MON-YYYY'') start_date f
rom HXC.HXC_TIMECARD_SUMMARY where resource_id = (''&&2'') and start_time > sysd
ate - 180 order by start_time';
run_sql('Timecards In Last 6 Months', sqltxt);
end if;

if upper('&&1') = 'HXT_TC' then


-- ************************
-- *** HXT_TC.. Syntax: Parameter1: HXT_TC Parameter2: <ID> Parameter3: 0
-- ************************
Display_Table('HXT_TIMECARDS_F', null, 'where id = (''&&2'')', null,
'Y');
Display_Table('HXT_SUM_HOURS_WORKED_F', null, 'where tim_id = (''&&2'')', '
order by tim_id, date_worked, effective_end_date', 'Y');
Display_Table('HXT_DET_HOURS_WORKED_F', null, 'where tim_id = (''&&2'')', '
order by tim_id, date_worked, effective_end_date', 'Y');
Display_Table('HXT_ERRORS_F', null, 'where tim_id = (''&&2'')', '
order by tim_id', 'Y');
Display_Table('HXT_BATCH_STATES', null, 'where batch_id in (select ba
tch_id from HXT_TIMECARDS_F where id in (''&&2'') union select retro_batch_id fr
om HXT_DET_HOURS_WORKED_F where tim_id = (''&&2''))', 'order by batch_id', 'Y');
Display_Table('PAY_BATCH_HEADERS', null, 'where batch_id in (select ba
tch_id from HXT_TIMECARDS_F where id in (''&&2'') union select retro_batch_id fr
om HXT_DET_HOURS_WORKED_F where tim_id = (''&&2''))', 'order by batch_id', 'Y');
Display_Table('PAY_BATCH_LINES', null, 'where batch_id in (select ba
tch_id from HXT_TIMECARDS_F where id in (''&&2'') union select retro_batch_id fr
om HXT_DET_HOURS_WORKED_F where tim_id = (''&&2'')) and (assignment_id, element_
type_id, date_earned) in (select assignment_id, element_type_id, date_worked fro
m HXT_DET_HOURS_WORKED_F where tim_id = (''&&2''))', 'order by batch_id', 'Y');
Display_Table('PAY_ELEMENT_ENTRIES_F', null, 'where (assignment_id, elemen
t_type_id, date_earned) in (select assignment_id, element_type_id, date_worked f
rom HXT_DET_HOURS_WORKED_F where tim_id = (''&&2''))', 'order by assignment_id,
date_earned, object_version_number', 'Y');

Display_Table('nuan_per_people_f_mv', null, 'where person_id in (sele


ct for_person_id from HXT_TIMECARDS_F where id = (''&&2''))', null, 'Y');
Display_Table('PER_ALL_ASSIGNMENTS_F', null, 'where person_id in (select f
or_person_id from HXT_TIMECARDS_F where id = (''&&2''))', null, 'Y');
Display_Table('HXT_ADD_ASSIGN_INFO_F', null, 'where assignment_id in (sele
ct assignment_id from PER_ALL_ASSIGNMENTS_F where person_id in (select for_perso
n_id from HXT_TIMECARDS_F where id = (''&&2'')))', 'order by assignment_id, effe
ctive_start_date', 'Y');
Display_Table('PER_TIME_PERIODS', null, 'where time_period_id in (sel
ect time_period_id from HXT_TIMECARDS_F where id = (''&&2''))', null, 'Y');
Display_Table('PAY_ALL_PAYROLLS_F', null, 'where payroll_id in (select
payroll_id from HXT_TIMECARDS_F where id = (''&&2''))', null, 'Y');
Display_Table('PAY_COST_ALLOCATION_KEYFLEX', null, 'where cost_allocation_keyfle
x_id in (select ffv_cost_center_id from HXT_DET_HOURS_WORKED_F where tim_id = ('
'&&2''))', null, 'Y');
Display_Table('HXT_ADD_ELEM_INFO_F', null, 'where element_type_i
d in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2''
) and element_type_id is not null union select element_type_id from hxt_det_hour
s_worked_f where tim_id = (''&&2''))', 'order by id', 'Y');
Display_Table('PAY_ELEMENT_TYPES_F', null, 'where element_type_i
d in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2''
) and element_type_id is not null union select element_type_id from hxt_det_hour
s_worked_f where tim_id = (''&&2''))', 'order by element_type_id, effective_star
t_date', 'Y');
Display_Table('PAY_ELEMENT_TYPES_F_TL', null, 'where element_type_i
d in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2''
) and element_type_id is not null union select element_type_id from hxt_det_hour
s_worked_f where tim_id = (''&&2''))', 'order by element_type_id, language', 'Y'
);
Display_Table('PAY_ELEMENT_CLASSIFICATIONS', null, 'where classification
_id in (select classification_id from PAY_ELEMENT_TYPES_F where element_type_id
in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2'')
and element_type_id is not null union select element_type_id from hxt_det_hours_
worked_f where tim_id = (''&&2'')))', 'order by classification_id', 'Y');
Display_Table('PAY_ELEMENT_CLASSIFICATIONS_TL', null, 'where classification
_id in (select classification_id from PAY_ELEMENT_TYPES_F where element_type_id
in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2'')
and element_type_id is not null union select element_type_id from hxt_det_hours_
worked_f where tim_id = (''&&2'')))', 'order by classification_id, language', 'Y
');
Display_Table('PAY_INPUT_VALUES_F', null, 'where element_type_i
d in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2''
) and element_type_id is not null union select element_type_id from hxt_det_hour
s_worked_f where tim_id = (''&&2''))', 'order by element_type_id, display_sequen
ce, input_value_id, effective_start_date', 'Y');
Display_Table('PAY_INPUT_VALUES_F_TL', null, 'where input_value_id
in (select input_value_id from PAY_INPUT_VALUES_F where element_type_id in (sel
ect element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2'') and ele
ment_type_id is not null union select element_type_id from hxt_det_hours_worked_
f where tim_id = (''&&2'')))', 'order by input_value_id, language', 'Y');
Display_Table('PAY_ELEMENT_LINKS_F', null, 'where element_type_i
d in (select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2''
) and element_type_id is not null union select element_type_id from hxt_det_hour
s_worked_f where tim_id = (''&&2''))', 'order by element_type_id, element_link_i
d, effective_start_date', 'Y');
Display_Table('PAY_LINK_INPUT_VALUES_F', null, 'where element_link_i
d in (select element_link_id from PAY_ELEMENT_LINKS_F where element_type_id in (
select element_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2'') and
element_type_id is not null union select element_type_id from hxt_det_hours_work
ed_f where tim_id = (''&&2'')))', 'order by element_link_id, effective_start_dat
e', 'Y');
Display_Table('PER_ABSENCE_ATTENDANCE_TYPES', null, 'where name in (selec
t element_name from PAY_ELEMENT_TYPES_F where element_type_id in (select element
_type_id from hxt_sum_hours_worked_f where tim_id = (''&&2'') and element_type_i
d is not null union select element_type_id from hxt_det_hours_worked_f where tim
_id = (''&&2'')))', 'order by name', 'Y');
Display_Table('PA_TRANSACTION_INTERFACE_ALL',null, 'where transaction_source = '
'Time Management'' and substr(orig_transaction_reference,23,length(orig_transact
ion_reference)) in (select id from hxt_det_hours_worked_f where tim_id = (''&&2'
'))', 'order by substr(orig_transaction_reference,23,length(orig_transaction_ref
erence))', 'Y');
Display_Table('PA_TXN_INTERFACE_AUDIT_ALL', null, 'where transaction_source = '
'Time Management'' and substr(orig_transaction_reference,23,length(orig_transact
ion_reference)) in (select id from hxt_det_hours_worked_f where tim_id = (''&&2'
'))', 'order by substr(orig_transaction_reference,23,length(orig_transaction_ref
erence))', 'Y');
Display_Table('PA_EXPENDITURES_ALL', null, 'where expenditure_id in (sel
ect expenditure_id from PA_EXPENDITURE_ITEMS_ALL where transaction_source = ''Ti
me Management'' and substr(orig_transaction_reference,23,length(orig_transaction
_reference)) in (select id from hxt_det_hours_worked_f where tim_id = (''&&2''))
)', null, 'Y');
Display_Table('PA_EXPENDITURE_ITEMS_ALL', null, 'where transaction_source = '
'Time Management'' and substr(orig_transaction_reference,23,length(orig_transact
ion_reference)) in (select id from hxt_det_hours_worked_f where tim_id = (''&&2'
'))', 'order by substr(orig_transaction_reference,23,length(orig_transaction_ref
erence))', 'Y');
end if;

if upper('&&1') = 'HXT_BATCH' then


-- ************************
-- *** HXT_BATCH.. Syntax: Parameter1: HXT_BATCH Parameter2: <batch_id> Param
eter3: 0
-- ************************
sqlTxt := 'select count(1) from HXT_TIMECARDS_F where batch_id in (''&&2'')';
run_sql('HXT_TIMECARDS_F', sqltxt);
sqlTxt := 'select count(1) from HXT_SUM_HOURS_WORKED_F where tim_id in (select i
d from HXT_TIMECARDS_F where batch_id in (''&&2''))';
run_sql('HXT_SUM_HOURS_WORKED_F', sqltxt);
sqlTxt := 'select count(1) from HXT_DET_HOURS_WORKED_F where tim_id in (select i
d from HXT_TIMECARDS_F where batch_id in (''&&2'')) or retro_batch_id in (''&&2'
')';
run_sql('HXT_DET_HOURS_WORKED_F', sqltxt);
Display_Table('HXT_ERRORS_F', null, 'where tim_id in (select id f
rom HXT_TIMECARDS_F where batch_id in (''&&2''))', 'order by error_msg', 'Y');
Display_Table('HXT_BATCH_STATES', null, 'where batch_id in (''&&2'')'
, null, 'Y');
Display_Table('PAY_BATCH_HEADERS', null, 'where batch_id in (''&&2'')'
, null, 'Y');
--Display_Table('PAY_BATCH_LINES', null, 'where batch_id in (''&&2''
)', null, 'Y');
sqlTxt := 'select batch_id, batch_line_status, count(1) from pay_batch_lines whe
re batch_id in (''&&2'') group by batch_id, batch_line_status order by batch_id,
batch_line_status';
run_sql('PAY_BATCH_LINES', sqltxt);
--Display_Table('PAY_ELEMENT_ENTRIES_F', null, 'where (assignment_id, elem
ent_type_id, date_earned) in (select assignment_id, element_type_id, date_worked
from HXT_DET_HOURS_WORKED_F where tim_id in (select id from HXT_TIMECARDS_F whe
re batch_id in (''&&2'')))', 'order by assignment_id, date_earned, element_type_
id, object_version_number', 'Y');
sqlTxt := 'select count(1) from PAY_ELEMENT_ENTRIES_F where (assignment_id, elem
ent_type_id, date_earned) in (select assignment_id, element_type_id, date_worked
from HXT_DET_HOURS_WORKED_F where tim_id in (select id from HXT_TIMECARDS_F whe
re batch_id in (''&&2'')))';
run_sql('PAY_ELEMENT_ENTRIES_F', sqltxt);
Display_Table('PER_TIME_PERIODS', null, 'where time_period_id in (sel
ect time_period_id from HXT_TIMECARDS_F where batch_id in (''&&2''))', null, 'Y'
);
end if;

if upper('&&1') = 'PAY_BATCH' then


-- ************************
-- *** PAY_BATCH.. Syntax: Parameter1: PAY_BATCH Parameter2: <batch_id> Param
eter3: 0
-- ************************
Display_Table('PAY_BATCH_HEADERS', null, 'where batch_id = (''&&2'')',
null, 'Y');
Display_Table('PAY_BATCH_LINES', null, 'where batch_id = (''&&2'')',
null, 'Y');
end if;

if upper('&&1') = 'HXC.HXC_APPROVAL_STYLE'
or upper('&&1') = 'HXC.HXC_APPROVAL_STYLES'
then
-- ************************
-- *** HXC.HXC_APPROVAL_STYLE.. Syntax: Parameter1: HXC.HXC_APPROVAL_STYLE Par
ameter2: <approval_style_id> Parameter3: 0
-- ************************
Display_Table('HXC.HXC_APPROVAL_STYLES', null, 'where approval_style_id
= (''&&2'')', null, 'Y');
select count(1)
into l_num1
from HXC.HXC_DATA_APP_RULE_USAGES
where approval_style_id = '&&2';
if l_num1 > 0 then
new_section('Approval Rules');
Display_Table('HXC.HXC_DATA_APP_RULE_USAGES', null, 'where approval_style_i
d = (''&&2'')', 'order by time_recipient_id, object_version_number', 'Y');
Display_Table('HXC.HXC_TIME_RECIPIENTS', null, 'where time_recipient_i
d in (select time_recipient_id from HXC.HXC_DATA_APP_RULE_USAGES where approval_
style_id = (''&&2''))', 'order by time_recipient_id, object_version_number', 'Y'
);
end if;

new_section('Approval Style Components');


Display_Table('HXC.HXC_APPROVAL_COMPS', null, 'where approval_style_id
= (''&&2'') and time_recipient_id >= 0', 'order by approval_comp_id, parent_comp
_id, parent_comp_ovn', 'Y');
Display_Table('HXC.HXC_TIME_RECIPIENTS', null, 'where time_recipient_id
in (select time_recipient_id from HXC.HXC_APPROVAL_COMPS where approval_style_id
= (''&&2''))', 'order by time_recipient_id', 'Y');

select count(1)
into l_num1
from HXC.HXC_APPROVAL_COMPS
where approval_style_id = '&&2'
and time_recipient_id = -1;
if l_num1 > 0 then
new_section('Entry Level Approval Components');
Display_Table('HXC.HXC_APPROVAL_COMPS', 'HXC.HXC_APPROVAL_COMPS - Def
ault Entry Level Approval Style', 'where approval_style_id = (''&&2'') and time_
recipient_id = -1 and time_category_id = 0', 'order by approval_comp_id, parent_
comp_id, parent_comp_ovn', 'Y');
Display_Table('HXC.HXC_APPROVAL_COMPS', 'HXC.HXC_APPROVAL_COMPS - Ent
ry Level Components', 'where approval_style_id = (''&&2'') and time_recipient_id
= -1 and time_category_id <> 0', 'order by approval_comp_id, parent_comp_id, pa
rent_comp_ovn', 'Y');
Display_Table('HXC.HXC_TIME_CATEGORIES', null, 'where time_category_id
in (select time_category_id from HXC.HXC_APPROVAL_COMPS where approval_style_id
= (''&&2''))', 'order by time_category_id', 'Y');
Display_Table('HXC.HXC_TIME_CATEGORY_COMPS', null, 'where time_category_id
in (select time_category_id from HXC.HXC_APPROVAL_COMPS where approval_style_id
= (''&&2''))', 'order by time_category_id, time_category_comp_id', 'Y');
Display_Table('HXC.HXC_TIME_CATEGORY_COMPS_V', null, 'where time_category_id
in (select time_category_id from HXC.HXC_APPROVAL_COMPS where approval_style_id
= (''&&2''))', 'order by time_category_id, time_category_comp_id', 'Y');
Display_Table('HXC.HXC_TIME_CATEGORY_COMP_SQL', null, 'where time_category_co
mp_id in (select time_category_comp_id from HXC.HXC_time_category_comps where ti
me_category_id in (select time_category_id from HXC.HXC_APPROVAL_COMPS where app
roval_style_id = (''&&2'')))', null, 'Y');
Display_Table('HXC.HXC_MAPPING_COMPONENTS', null, 'where mapping_componen
t_id in (select mapping_component_id from HXC.HXC_time_category_comps where time
_category_id in (select time_category_id from HXC.HXC_APPROVAL_COMPS where appro
val_style_id = (''&&2'')))', 'order by mapping_component_id', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id in
(select flex_value_set_id from HXC.HXC_TIME_CATEGORY_COMPS where time_category_
id in (select time_category_id from HXC.HXC_APPROVAL_COMPS where approval_style_
id = (''&&2'')))', 'order by flex_value_set_id', 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id in
(select flex_value_set_id from HXC.HXC_TIME_CATEGORY_COMPS where time_category_
id in (select time_category_id from HXC.HXC_APPROVAL_COMPS where approval_style_
id = (''&&2'')))', 'order by flex_value_set_id', 'Y');
end if;
new_section('Other Attributes');
Display_Table('HXC.HXC_APP_COMP_NOTIF_USAGES', null, 'where approval_comp_id i
n (select approval_comp_id from HXC.HXC_APPROVAL_COMPS where approval_style_id =
(''&&2''))', 'order by approval_comp_id, approval_comp_ovn, comp_notification_i
d', 'Y');
Display_Table('HXC.HXC_APP_COMP_NOTIFICATIONS', null, 'where (comp_notification
_id, object_version_number) in (select comp_notification_id, comp_notification_o
vn from HXC.HXC_APP_COMP_NOTIF_USAGES where approval_comp_id in (select approval
_comp_id from HXC.HXC_APPROVAL_COMPS where approval_style_id = (''&&2'')))', 'or
der by comp_notification_id, object_version_number', 'Y');
sqlTxt := '
select approval_comp_id, object_version_number
from HXC.HXC_approval_comps
where approval_style_id = (''&&2'')
and (approval_comp_id, object_version_number) not in
(select approval_comp_id, approval_comp_ovn
from HXC.HXC_app_comp_notif_usages)
order by approval_comp_id
';
run_sql('HXC.HXC_APPROVAL_COMPS Without Other Attributes', sqltxt);
-- Still need to output Time Entry Rules for Approval Rules and preference usage
s.
end if;
if upper('&&1') = 'HXC.HXC_TO_BEE' then
-- ************************
-- *** HXC.HXC_TO_BEE................ Syntax: Parameter1: HXC.HXC_TO_BEE , Para
meter2: <request_id>, Parameter3:
-- ************************
Display_Table('FND_CONCURRENT_REQUESTS', null, 'where request_id in (''&&2'')',
'order by request_id', 'Y');
Display_Table('HXC.HXC_RETRIEVAL_RANGES', null, 'where conc_request_id in ('
'&&2'')', 'order by conc_request_id', 'Y');
Display_Table('HXC.HXC_TRANSACTIONS', null, 'where transaction_id in (se
lect distinct transaction_id from HXC.HXC_RETRIEVAL_RANGES where conc_request_id
in (''&&2''))', null, 'Y');
sqlTxt := 'select transaction_id, status, exception_description, count(1)
from HXC.HXC_TRANSACTION_DETAILS
where transaction_id in (select distinct transaction_id
from HXC.HXC_RETRIEVAL_RANGES
where conc_request_id in (''&&2''))
group by transaction_id, status, exception_description';
run_sql('HXC.HXC_TRANSACTION_DETAILS - Count', sqltxt);
Display_Table('PAY_BATCH_HEADERS', 'PAY_BATCH_HEADERS - Time Store', 'wh
ere batch_source in (''Time Store'') and trunc(creation_date) in (select trunc(c
reation_date) from HXC.HXC_RETRIEVAL_RANGES where conc_request_id in (''&&2''))'
, null, 'Y');
Display_Table('PAY_BATCH_HEADERS', 'PAY_BATCH_HEADERS - OTM', 'wh
ere batch_source in (''OTM'') and trunc(creation_date) in (select trunc(creation
_date) from HXC.HXC_RETRIEVAL_RANGES where conc_request_id in (''&&2''))', null,
'Y');
Display_Table('HXC.HXC_DEBUG_TEXT', null, null, null, 'N');
Display_Profiles(808,null);
Display_Profiles(809,null);
end if;

if upper('&&1') = 'OTL_WF'
then
-- ************************
-- *** OTL_WF.. Syntax: Parameter1: OTL_WF Parameter2: <item_key> Parameter3:
0
-- ************************
Display_Table('WF_ITEMS', null, 'where item_key in (''&&2'')
', null, 'Y');
Display_Table('WF_ITEM_INFO', null, 'where item_key in (''&&2'')
', null, 'Y');
sqlTxt := 'select
ITEM_TYPE
, ITEM_KEY
, NAME
, TEXT_VALUE
, NUMBER_VALUE
, DATE_VALUE
--, EVENT_VALUE
,SECURITY_GROUP_ID
from WF_ITEM_ATTRIBUTE_VALUES where item_key = (''&&2'')
order by NAME';
run_sql('WF_ITEM_ATTRIBUTE_VALUES', sqltxt);
sqlTxt := 'select
ITEM_TYPE
, ITEM_KEY
, PROCESS_ACTIVITY
, ACTIVITY_STATUS
, ACTIVITY_RESULT_CODE
, ASSIGNED_USER
, NOTIFICATION_ID
, BEGIN_DATE
, END_DATE
, EXECUTION_TIME
, ERROR_NAME
, ERROR_MESSAGE
, ERROR_STACK
--, OUTBOUND_QUEUE_ID
, DUE_DATE
, SECURITY_GROUP_ID
, ACTION
, PERFORMED_BY
from WF_ITEM_ACTIVITY_STATUSES where item_key = (''&&2'')
order by PROCESS_ACTIVITY';
run_sql('WF_ITEM_ACTIVITY_STATUSES', sqltxt);
sqlTxt := 'select
ITEM_TYPE
, ITEM_KEY
, PROCESS_ACTIVITY
, ACTIVITY_STATUS
, ACTIVITY_RESULT_CODE
, ASSIGNED_USER
, NOTIFICATION_ID
, BEGIN_DATE
, END_DATE
, EXECUTION_TIME
, ERROR_NAME
, ERROR_MESSAGE
, ERROR_STACK
--, OUTBOUND_QUEUE_ID
, DUE_DATE
, SECURITY_GROUP_ID
, ACTION
, PERFORMED_BY
from WF_ITEM_ACTIVITY_STATUSES_H where item_key = (''&&2'')
order by PROCESS_ACTIVITY';
run_sql('WF_ITEM_ACTIVITY_STATUSES_H', sqltxt);
Display_Table('WF_NOTIFICATIONS', null, 'where item_key in (''&&2'')
', null, 'Y');
end if;

if upper('&&1') = 'TEST' then


-- ************************
-- *** TEST................ Syntax: Parameter1: , Parameter2: , Parameter3:
-- ************************
sqlTxt := 'select 12345 from dual';
run_sql('TEST', sqltxt);
end if;
if upper('&&1') = 'OTL11I'
or upper('&&1') = 'OTL_VERSIONS'
then
-- ************************
-- *** OTL11i.. Syntax: Parameter1: OTL11i Parameter2: 0 Parameter3: 0
-- *** OTL_Versions.. Syntax: Parameter1: OTL_Versions Parameter2: 0 Paramete
r3: 0
-- ************************
if check_version('fnd', '12') = 'lesser' then
sqlTxt := 'select * from FND_PRODUCT_INSTALLATIONS where application_id in (''0'
', ''50'', ''178'', ''275'', ''426'', ''453'', ''800'', ''801'', ''802'', ''803'
', ''804'', ''805'', ''808'', ''809'', ''810'', ''8301'', ''8302'', ''8303'') or
der by application_id';
run_sql('FND_PRODUCT_INSTALLATIONS', sqltxt);
else
sqlTxt := 'select * from FND_PRODUCT_INSTALLATIONS where application_id in (''0'
', ''50'', ''178'', ''275'', ''426'', ''453'', ''800'', ''801'', ''802'', ''803'
', ''804'', ''805'', ''808'', ''810'', ''8301'', ''8302'', ''8303'') order by ap
plication_id';
run_sql('FND_PRODUCT_INSTALLATIONS', sqltxt);
end if;
if check_version('fnd', '12') = 'lesser' then
sqlTxt :=
'SELECT bug_number patchNumber
, decode(bug_number
,''2398780'', ''HXT.D''
,''2821443'', ''HXT.D.3''
,''2716711'', ''HXT.E''
,''3042947'', ''HXT.F''
,''3056938'', ''HXT.F Cons#1''
,''3939443'', ''HXT.F Rollup 12''
,''3285055'', ''HXT.G''
,''4298433'', ''HXT.G Rollup 13''
,''3530830'', ''HXT.H''
,''4057588'', ''HXT.H Rollup 1''
,''4045358'', ''HXT.H Rollup 2''
,''4373214'', ''HXT.H Rollup 3''
,''4544887'', ''HXT.H Rollup 4''
,''4653019'', ''HXT.H Rollup 5''
,''4773290'', ''HXT.H Rollup 6''
,''4188854'', ''HXT.I''
,''4228080'', ''HXT.I Rollup 1''
,''4373296'', ''HXT.I Rollup 2''
,''4544911'', ''HXT.I Rollup 3''
,''4653027'', ''HXT.I Rollup 4''
,''4773293'', ''HXT.I Rollup 5''
,''5066353'', ''HXT.I Rollup 6''
,''4428056'', ''HXT.J''
,''4634379'', ''HXT.J Rollup 1''
,''4544879'', ''HXT11i Rollup''
,''5066320'', ''HXT11i Rollup 2''
,''7226660'', ''HXT11i Rollup 3''
,''8888888'', ''HXT11i Rollup 4''
,''9062727'', ''HRMS Family Pack K Rollup 5''
) patchName
, last_update_date appliedDate
FROM ad_bugs
WHERE bug_number in
(''2398780''
,''2821443''
,''2716711''
,''3042947''
,''3056938''
,''3939443''
,''3285055''
,''4298433''
,''3530830''
,''4057588''
,''4045358''
,''4373214''
,''4544887''
,''4653019''
,''4773290''
,''4188854''
,''4228080''
,''4373296''
,''4544911''
,''4653027''
,''4773293''
,''5066353''
,''4428056''
,''4634379''
,''4544879''
,''5066320''
,''7226660''
,''8888888''
,''9062727''
)
ORDER BY last_update_date, patchName';
run_sql('OTL Patch List', sqltxt);
end if;
sqlTxt :=
'SELECT ap.patch_name patchNumber
, ''hrglobal.drv'' patchName
, pr.end_date appliedDate
FROM ad_applied_patches ap
, ad_patch_drivers pd
, ad_patch_runs pr
, ad_patch_run_bugs prb
, ad_patch_run_bug_actions prba
, ad_files f
WHERE f.file_id = prba.file_id
AND prba.executed_flag = ''Y''
AND prba.patch_run_bug_id = prb.patch_run_bug_id
AND prb.patch_run_id = pr.patch_run_id
AND pr.patch_driver_id = pd.patch_driver_id
AND pd.applied_patch_id = ap.applied_patch_id
AND f.filename = ''hrglobal.drv''
AND pr.end_date = (SELECT max(pr.end_date)
FROM ad_applied_patches ap
, ad_patch_drivers pd
, ad_patch_runs pr
, ad_patch_run_bugs prb
, ad_patch_run_bug_actions prba
, ad_files f
WHERE f.file_id = prba.file_id
AND prba.executed_flag = ''Y''
AND prba.patch_run_bug_id = prb.patch_run_bug_id
AND prb.patch_run_id = pr.patch_run_id
AND pr.patch_driver_id = pd.patch_driver_id
AND pd.applied_patch_id = ap.applied_patch_id
AND f.filename = ''hrglobal.drv'')';
run_sql('hrglobal.drv', sqltxt);
NoticePrint('Please remember hrglobal is a progressive patch. Review Metalink No
te:145837.1 to verify that the latest hrglobal is applied.');
Display_Profiles(808,null);
Display_Profiles(809,null);
--Display_Profiles(null, 'FND_DIAGNOSTICS');
--Display_Profiles_Like('AFLOG_%');
sqlTxt :=
'select owner, name, type, text
from all_source
where (name like ''HXC.HXC%''
or name like ''HXT%''
or name like ''PA%OTC%''
or name in (''PAGTCX'', ''PA_TIME_CLIENT_EXTN'')
)
and type in (''PACKAGE'', ''PACKAGE BODY'')
and line = 2
order by 1,2,3';
run_sql('ALL_SOURCE', sqltxt);
sqlTxt :=
'SELECT *
FROM dba_objects
WHERE status != ''VALID''
AND object_type != ''UNDEFINED''
ORDER BY owner, object_name, object_type';
run_sql('Invalid Objects', sqltxt);
sqlTxt := 'SELECT *
FROM dba_errors
ORDER BY owner, type, name, line';
run_sql('Errors', sqltxt);
Display_Table('HXC.HXC_DEBUG_TEXT', null, null, null, 'N');
end if;
if upper('&&1') = 'ELEMENT' then
-- ************************
-- *** ELEMENT........... Syntax: Parameter1: ELEMENT Parameter2: <Element_Typ
e_Id> Parameter3: 0
-- ************************
Display_Table('PAY_ELEMENT_TYPES_F', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id, effective_start_date', 'Y');
Display_Table('PAY_ELEMENT_TYPES_F_TL', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id, language', 'Y');
Display_Table('PAY_ELEMENT_CLASSIFICATIONS', null, 'where classification
_id in (select classification_id from PAY_ELEMENT_TYPES_F where element_type_id
in (''&&2''))', 'order by classification_id', 'Y');
Display_Table('PAY_ELEMENT_CLASSIFICATIONS_TL', null, 'where classification
_id in (select classification_id from PAY_ELEMENT_TYPES_F where element_type_id
in (''&&2''))', 'order by classification_id, language', 'Y');
Display_Table('PAY_INPUT_VALUES_F', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id, display_sequence, input_value_id, ef
fective_start_date', 'Y');
Display_Table('PAY_INPUT_VALUES_F_TL', null, 'where input_value_id
in (select input_value_id from PAY_INPUT_VALUES_F where element_type_id in (''&
&2''))', 'order by input_value_id, language', 'Y');
Display_Table('PAY_ELEMENT_LINKS_F', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id, element_link_id, effective_start_dat
e', 'Y');
Display_Table('PAY_LINK_INPUT_VALUES_F', null, 'where element_link_i
d in (select element_link_id from PAY_ELEMENT_LINKS_F where element_type_id in (
''&&2''))', 'order by element_link_id, effective_start_date', 'Y');
Display_Table('PER_ABSENCE_ATTENDANCE_TYPES', null, 'where name in (selec
t element_name from PAY_ELEMENT_TYPES_F where element_type_id in (''&&2''))', 'o
rder by name', 'Y');
Display_Table('PAY_ELEMENT_SETS', null, 'where element_set_id
in (select element_set_id from PAY_ELEMENT_TYPE_RULES where element_type_id in
(''&&2''))', null, 'N');
Display_Table('PAY_ELEMENT_SETS_TL', null, 'where element_set_id
in (select element_set_id from PAY_ELEMENT_TYPE_RULES where element_type_id in
(''&&2''))', null, 'N');
Display_Table('PAY_ELEMENT_TYPE_RULES', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id, element_set_id', 'Y');
Display_Table('HXT_ADD_ELEM_INFO_F', null, 'where element_type_i
d in (''&&2'')', 'order by element_type_id', 'Y');
Display_Table('HXC.HXC_ALIAS_DEFINITIONS', null, 'where alias_defi
nition_id in (select alias_definition_id from HXC.HXC_ALIAS_VALUES where (attrib
ute_category = ''PAYROLL_ELEMENTS'' and attribute1 = (''&&2'')) or (attribute_ca
tegory = ''ELEMENTS_EXPENDITURE_SLF'' and attribute1 = (''&&2'')) or (attribute_
category = ''EXPENDITURE_ELEMENTS'' and attribute2 = (''&&2'')))', 'order by ali
as_definition_id', 'Y');
Display_Table('HXC.HXC_ALIAS_DEFINITIONS_TL', null, 'where alias_defi
nition_id in (select alias_definition_id from HXC.HXC_ALIAS_VALUES where (attrib
ute_category = ''PAYROLL_ELEMENTS'' and attribute1 = (''&&2'')) or (attribute_ca
tegory = ''ELEMENTS_EXPENDITURE_SLF'' and attribute1 = (''&&2'')) or (attribute_
category = ''EXPENDITURE_ELEMENTS'' and attribute2 = (''&&2'')))', 'order by ali
as_definition_id', 'Y');
Display_Table('HXC.HXC_ALIAS_VALUES', null, 'where (attribute
_category = ''PAYROLL_ELEMENTS'' and attribute1 = (''&&2'')) or (attribute_categ
ory = ''ELEMENTS_EXPENDITURE_SLF'' and attribute1 = (''&&2'')) or (attribute_cat
egory = ''EXPENDITURE_ELEMENTS'' and attribute2 = (''&&2''))', 'order by alias_d
efinition_id, alias_value_id', 'Y');
Display_Table('HXC.HXC_ALIAS_VALUES_TL', null, 'where alias_valu
e_id in (select alias_value_id from HXC.HXC_ALIAS_VALUES where (attribute_catego
ry = ''PAYROLL_ELEMENTS'' and attribute1 = (''&&2'')) or (attribute_category = '
'ELEMENTS_EXPENDITURE_SLF'' and attribute1 = (''&&2'')) or (attribute_category =
''EXPENDITURE_ELEMENTS'' and attribute2 = (''&&2'')))', 'order by alias_value_i
d', 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_TABLES', null, 'where (table_name, applic
ation_id) in (select application_table_name, application_id from FND_DESCRIPTIVE
_FLEXS where DESCRIPTIVE_FLEXFIELD_NAME = ''OTC Information Types'')', null, 'Y'
);
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', 'order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_COLUMN_USAGES', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(
substr(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(
substr(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e ''ELEMENT - ''||''&&2''', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(
substr(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CO
DE) like ''ELEMENT - ''||''&&2'')', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CO
DE) like ''ELEMENT - ''||''&&2'')', null, 'Y');
Display_Table('FND_COLUMNS', null, 'where (column_name, table
_id) in (select a.application_column_name, b.table_id from FND_DESCR_FLEX_COL_US
AGE_VL A, FND_TABLES B, FND_DESCRIPTIVE_FLEXS C where C.DESCRIPTIVE_FLEXFIELD_NA
ME = ''OTC Information Types'' and a.descriptive_flexfield_name = c.descriptive_
flexfield_name and c.application_table_name = b.table_name and c.application_id
= b.application_id)', null, 'Y');
Display_Table('FND_DEFAULT_CONTEXT_FIELDS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');

end if;
if upper('&&1') = 'OTC_INFO_TYPES' then
-- ************************
-- *** OTC_INFO_TYPES........... Syntax: Parameter1: OTC_INFO_TYPES Parameter2
: <context> Parameter3: 0
-- ************************
Display_Table('FND_DESCRIPTIVE_FLEXS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
Display_Table('FND_TABLES', null, 'where (table_name, applic
ation_id) in (select application_table_name, application_id from FND_DESCRIPTIVE
_FLEXS where DESCRIPTIVE_FLEXFIELD_NAME = ''OTC Information Types'')', null, 'Y'
);
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', 'order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_COLUMN_USAGES', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr(AP
PLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr(AP
PLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper(''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr(AP
PLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CO
DE) like upper(''&&2''))', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTC Information Types'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CO
DE) like upper(''&&2''))', null, 'Y');
Display_Table('FND_COLUMNS', null, 'where (column_name, table
_id) in (select a.application_column_name, b.table_id from FND_DESCR_FLEX_COL_US
AGE_VL A, FND_TABLES B, FND_DESCRIPTIVE_FLEXS C where C.DESCRIPTIVE_FLEXFIELD_NA
ME = ''OTC Information Types'' and a.descriptive_flexfield_name = c.descriptive_
flexfield_name and c.application_table_name = b.table_name and c.application_id
= b.application_id)', null, 'Y');
Display_Table('FND_DEFAULT_CONTEXT_FIELDS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = ''OTC Information Types'' ', null, 'Y');
end if;
if upper('&&1') = 'FND_DESC_FLEX' then
-- ************************
-- *** FND_DESC_FLEX........... Syntax: Parameter1: FND_DESC_FLEX Parameter2:
<descriptive_flexfield_name> Parameter3: 0
-- ************************
Display_Table('FND_DESCRIPTIVE_FLEXS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'') ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'') ', null, 'Y');
Display_Table('FND_DESCRIPTIVE_FLEXS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'') ', null, 'Y');
Display_Table('FND_TABLES', null, 'where (table_name, applic
ation_id) in (select application_table_name, application_id from FND_DESCRIPTIVE
_FLEXS where DESCRIPTIVE_FLEXFIELD_NAME = (''&&2''))', null, 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', 'order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_COLUMN_USAGES', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr
(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_VL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr
(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_DESCR_FLEX_COL_USAGE_TL', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(substr
(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = (''&&2''))', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id i
n (select flex_value_set_id from fnd_descr_flex_column_usages where DESCRIPTIVE_
FLEXFIELD_NAME = (''&&2''))', null, 'Y');
Display_Table('FND_COLUMNS', null, 'where (column_name, table
_id) in (select a.application_column_name, b.table_id from FND_DESCR_FLEX_COL_US
AGE_VL A, FND_TABLES B, FND_DESCRIPTIVE_FLEXS C where C.DESCRIPTIVE_FLEXFIELD_NA
ME = (''&&2'') and a.descriptive_flexfield_name = c.descriptive_flexfield_name a
nd c.application_table_name = b.table_name and c.application_id = b.application_
id)', null, 'Y');
Display_Table('FND_DEFAULT_CONTEXT_FIELDS', null, 'where DESCRIPTIVE_FLEXFIE
LD_NAME = (''&&2'') ', null, 'Y');
end if;
if upper('&&1') = 'PA_NOT_XFR' then
-- ************************
-- *** PA_NOT_XFR........... Syntax: Parameter1: PA_NOT_XFR Parameter2: <since
date formatted 01-Jan-2008> Parameter3: 0
-- ************************
sqlTxt := 'select * from HXC.HXC_TIMECARD_SUMMARY where timecard_id in (
select sum.timecard_id
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_application_set_comps_v app
where sum.approval_status = ''APPROVED''
and sum.timecard_id = tim.time_building_block_id
and sum.timecard_ovn = tim.object_version_number
and tim.application_set_id = app.application_set_id
and upper(app.time_recipient_name) in (''PROJECTS'')
and not exists ( select 1
from HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_transaction_details trx_det
, HXC.HXC_transactions trx
where sum.timecard_id = day.parent_building_block_id
and sum.timecard_ovn = day.parent_building_block_ovn
and day.time_building_block_id = det.parent_building_block
_id
and day.object_version_number = det.parent_building_block_
ovn
and det.time_building_block_id = trx_det.time_building_blo
ck_id
and det.object_version_number = trx_det.time_building_bloc
k_ovn
and trx_det.transaction_id = trx.transaction_id
and trx.status = ''SUCCESS''
and trx.type = ''RETRIEVAL''
and trx.transaction_process_id = 1 )
and sum.start_time > to_date(''&&2'')
)
order by start_time, resource_id';
run_sql('HXC.HXC_TIMECARD_SUMMARY', sqltxt);
end if;
if upper('&&1') = 'PROJECT_USAGE' then
-- ************************
-- *** PROJECT_USAGE........... Syntax: Parameter1: PROJECT_USAGE Parameter2:
<Project_Id> Parameter3: 0
-- ************************
Display_Table('PA_PROJECTS_ALL', null, 'where project_id in (''&
&2'')', null, 'Y');
sqlTxt := 'select count(1) count
from HXC.HXC_time_attributes
where attribute_category = ''PROJECTS''
and attribute1 in (''&&2'')';
run_sql('Number Of Lines In OTL', sqltxt);
sqlTxt := 'select count(1) count
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages tau
, HXC.HXC_time_attributes ta
where sum.timecard_id = tim.time_building_block_id
and sum.timecard_ovn = tim.object_version_number
and tim.time_building_block_id = day.parent_building_block_id
and tim.object_version_number = day.parent_building_block_ovn
and day.time_building_block_id = det.parent_building_block_id
and day.object_version_number = det.parent_building_block_ovn
and det.time_building_block_id = tau.time_building_block_id
and det.object_version_number = tau.time_building_block_ovn
and tau.time_attribute_id = ta.time_attribute_id
and ta.attribute_category = ''PROJECTS''
and ta.attribute1 in (''&&2'')
and not exists
( select 1
from HXC.HXC_transaction_details trx_det
, HXC.HXC_transactions trx
where det.time_building_block_id = trx_det.time_building_block_id
and det.object_version_number = trx_det.time_building_block_ovn
and trx_det.transaction_id = trx.transaction_id
and trx.status = ''SUCCESS''
and trx.type = ''RETRIEVAL''
and trx.transaction_process_id = 1 )';
run_sql('Number Of Lines Not Transferred to Projects', sqltxt);
sqlTxt := 'select approval_status, count(1) count
from HXC.HXC_timecard_summary
where timecard_id in (
select distinct sum.timecard_id
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages tau
, HXC.HXC_time_attributes ta
where sum.timecard_id = tim.time_building_block_id
and sum.timecard_ovn = tim.object_version_number
and tim.time_building_block_id = day.parent_building_block_id
and tim.object_version_number = day.parent_building_block_ovn
and day.time_building_block_id = det.parent_building_block_id
and day.object_version_number = det.parent_building_block_ovn
and det.time_building_block_id = tau.time_building_block_id
and det.object_version_number = tau.time_building_block_ovn
and tau.time_attribute_id = ta.time_attribute_id
and ta.attribute_category = ''PROJECTS''
and ta.attribute1 in (''&&2'')
and not exists
( select 1
from HXC.HXC_transaction_details trx_det
, HXC.HXC_transactions trx
where det.time_building_block_id = trx_det.time_building_block_id
and det.object_version_number = trx_det.time_building_block_ovn
and trx_det.transaction_id = trx.transaction_id
and trx.status = ''SUCCESS''
and trx.type = ''RETRIEVAL''
and trx.transaction_process_id = 1 ))
group by approval_status
order by decode(approval_status, ''APPROVED'', 1, ''SUBMITTED'', 2, ''WORKING'',
3, ''ERROR'', 4, 0.5)';
run_sql('Number Of Timecards Not Transferred By Approval_Status', sqltxt);
SectionPrint('Parameters To Output The Top 10 Timecards Not Transferred By Appro
val_Status');
for l_num1 in 1..4 loop
select decode(l_num1, 1, 'APPROVED', 2, 'SUBMITTED', 3, 'WORKING', 4, 'ERROR') i
nto l_var1 from dual;
sqlTxt := 'select ''OTL_Diag'' Script, ''HXC.HXC_TC'' Parameter1, resource_id Pa
rameter2, to_char(start_time, ''DD-MON-YYYY'') Parameter3
from HXC.HXC_timecard_summary
where timecard_id in (
select distinct sum.timecard_id
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages tau
, HXC.HXC_time_attributes ta
where sum.timecard_id = tim.time_building_block_id
and sum.timecard_ovn = tim.object_version_number
and tim.time_building_block_id = day.parent_building_block_id
and tim.object_version_number = day.parent_building_block_ovn
and day.time_building_block_id = det.parent_building_block_id
and day.object_version_number = det.parent_building_block_ovn
and det.time_building_block_id = tau.time_building_block_id
and det.object_version_number = tau.time_building_block_ovn
and tau.time_attribute_id = ta.time_attribute_id
and ta.attribute_category = ''PROJECTS''
and ta.attribute1 in (''&&2'')
and not exists
( select 1
from HXC.HXC_transaction_details trx_det
, HXC.HXC_transactions trx
where det.time_building_block_id = trx_det.time_building_block_id
and det.object_version_number = trx_det.time_building_block_ovn
and trx_det.transaction_id = trx.transaction_id
and trx.status = ''SUCCESS''
and trx.type = ''RETRIEVAL''
and trx.transaction_process_id = 1 ))
and approval_status = '''||l_var1||'''
and rownum < 11
order by timecard_id desc, approval_status, resource_id, start_time';
run_sql(l_var1, sqltxt);
end loop;
end if;
if upper('&&1') = 'TABLES' then
-- ************************
-- *** Tables........... Syntax: Parameter1: Tables Parameter2: <table_name>
Parameter3: 0
-- ************************
sqlTxt := 'select * from ALL_TABLES where table_name in upper(''&&2'') ord
er by owner';
run_sql('ALL_TABLES', sqltxt);
sqlTxt := 'select * from DBA_TAB_PRIVS where (owner, table_name) in (select o
wner, table_name from all_tables where table_name in upper(''&&2'')) order by ow
ner';
run_sql('DBA_TAB_PRIVS', sqltxt);
sqlTxt := 'select * from DBA_COL_PRIVS where (owner, table_name) in (select o
wner, table_name from all_tables where table_name in upper(''&&2'')) order by ow
ner';
run_sql('DBA_COL_PRIVS', sqltxt);
sqlTxt := 'select * from DBA_EXTENTS where (owner, segment_name) in (select
owner, table_name from all_tables where table_name in upper(''&&2'')) order by
extent_id';
run_sql('DBA_EXTENTS', sqltxt);
sqlTxt := 'select * from ALL_TAB_COLUMNS where (owner, table_name) in (select o
wner, table_name from all_tables where table_name in upper(''&&2'')) order by ow
ner, column_id';
run_sql('ALL_TAB_COLUMNS', sqltxt);
sqlTxt := 'select * from ALL_TRIGGERS where (table_owner, table_name) in (se
lect owner, table_name from all_tables where table_name in upper(''&&2'')) order
by table_owner, trigger_name';
run_sql('ALL_TRIGGERS', sqltxt);
sqlTxt := 'select * from ALL_SYNONYMS where (table_owner, table_name) in (se
lect owner, table_name from all_tables where table_name in upper(''&&2'')) order
by table_owner';
run_sql('ALL_SYNONYMS', sqltxt);
sqlTxt := 'select * from ALL_INDEXES where (table_owner, table_name) in (se
lect owner, table_name from all_tables where table_name in upper(''&&2'')) order
by table_owner, index_name';
run_sql('ALL_INDEXES', sqltxt);
sqlTxt := 'select * from ALL_IND_COLUMNS where (table_owner, table_name) in (se
lect owner, table_name from all_tables where table_name in upper(''&&2'')) order
by table_owner, index_owner, index_name, column_position';
run_sql('ALL_IND_COLUMNS', sqltxt);
sqlTxt := 'select * from ALL_CONSTRAINTS where table_name in upper(''&&2'') ord
er by owner,table_name,constraint_name';
run_sql('ALL_CONSTRAINTS', sqltxt);
sqlTxt := 'select * from ALL_CONS_COLUMNS where table_name in upper(''&&2'') ord
er by owner,table_name,constraint_name';
run_sql('ALL_CONS_COLUMNS', sqltxt);
sqlTxt := 'select * from ALL_POLICIES where object_name in upper(''&&2'')';
run_sql('ALL_POLICIES', sqltxt);
sqlTxt := 'select * from DBA_TABLESPACES where tablespace_name in (select table
space_name from all_tables where table_name in upper(''&&2''))';
run_sql('DBA_TABLESPACES', sqltxt);
sqlTxt := 'select * from DBA_FREE_SPACE where tablespace_name in (select table
space_name from all_tables where table_name in upper(''&&2'')) order by tablespa
ce_name, bytes desc';
run_sql('DBA_FREE_SPACE', sqltxt);
end if;
if upper('&&1') = 'FND_CONC_REQ' then
-- ************************
-- *** FND_Conc_Req..... Syntax: Parameter1: FND_Conc_Req Parameter2: <request
_id> Parameter3: 0
-- ************************
sqlTxt := 'select * from FND_CONCURRENT_REQUESTS where request_id in (''&&2'')
order by request_id';
run_sql('FND_CONCURRENT_REQUESTS', sqltxt);
--Display_Table('FND_CONCURRENT_REQUESTS', null, 'where request_id in
(''&&2'')', null, 'Y');
--Display_Table('FND_CONCURRENT_REQUESTS', null, 'where request_id in
(select parent_request_id from fnd_concurrent_requests where parent_request_id
!= -1 and request_id in (''&&2'') UNION select priority_request_id from fnd_conc
urrent_requests where request_id in (''&&2''))', null, 'Y');
--Display_Table('FND_CONCURRENT_PROGRAMS', null, 'where (application_
id, concurrent_program_id) in (select program_application_id, concurrent_program
_id from fnd_concurrent_requests where request_id in (select request_id from fnd
_concurrent_requests where request_id in (''&&2'') UNION select parent_request_i
d from fnd_concurrent_requests where parent_request_id != -1 and request_id in (
''&&2'') UNION select priority_request_id from fnd_concurrent_requests where req
uest_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_CONC_REQUEST_ARGUMENTS', null, 'where request_id in
(''&&2'')', null, 'Y');
--Display_Table('FND_CONCURRENT_PROCESSES', null, 'where concurrent_pr
ocess_id in (select controlling_manager from fnd_concurrent_requests where reque
st_id in (''&&2''))', null, 'Y');
--Display_Table('FND_CONCURRENT_QUEUES', null, 'where CONCURRENT_QU
EUE_ID in (select CONCURRENT_QUEUE_ID from fnd_concurrent_processes where concur
rent_process_id in (select controlling_manager from fnd_concurrent_requests wher
e request_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_CONCURRENT_QUEUES_TL', null, 'where CONCURRENT_QU
EUE_ID in (select CONCURRENT_QUEUE_ID from fnd_concurrent_processes where concur
rent_process_id in (select controlling_manager from fnd_concurrent_requests wher
e request_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_CONCURRENT_QUEUE_CONTENT', null, 'where CONCURRENT_QU
EUE_ID in (select CONCURRENT_QUEUE_ID from fnd_concurrent_processes where concur
rent_process_id in (select controlling_manager from fnd_concurrent_requests wher
e request_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_USER', null, 'where user_id in (s
elect requested_by from fnd_concurrent_requests where request_id in (select requ
est_id from fnd_concurrent_requests where request_id in (''&&2'') UNION select p
arent_request_id from fnd_concurrent_requests where parent_request_id != -1 and
request_id in (''&&2'') UNION select priority_request_id from fnd_concurrent_req
uests where request_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_LOGINS', null, 'where login_id in (
select conc_login_id from fnd_concurrent_requests where request_id in (select re
quest_id from fnd_concurrent_requests where request_id in (''&&2'') UNION select
parent_request_id from fnd_concurrent_requests where parent_request_id != -1 an
d request_id in (''&&2'') UNION select priority_request_id from fnd_concurrent_r
equests where request_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_RESPONSIBILITY', null, 'where (application_
id, responsibility_id) in (select responsibility_application_id, responsibility_
id from fnd_concurrent_requests where request_id in (select request_id from fnd_
concurrent_requests where request_id in (''&&2'') UNION select parent_request_id
from fnd_concurrent_requests where parent_request_id != -1 and request_id in ('
'&&2'') UNION select priority_request_id from fnd_concurrent_requests where requ
est_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_RESPONSIBILITY_TL', null, 'where (application_
id, responsibility_id) in (select responsibility_application_id, responsibility_
id from fnd_concurrent_requests where request_id in (select request_id from fnd_
concurrent_requests where request_id in (''&&2'') UNION select parent_request_id
from fnd_concurrent_requests where parent_request_id != -1 and request_id in ('
'&&2'') UNION select priority_request_id from fnd_concurrent_requests where requ
est_id in (''&&2'')))', null, 'Y');
--Display_Table('FND_ORACLE_USERID', null, 'where oracle_id in
(select oracle_id from fnd_concurrent_requests where request_id in (select reque
st_id from fnd_concurrent_requests where request_id in (''&&2'') UNION select pa
rent_request_id from fnd_concurrent_requests where parent_request_id != -1 and r
equest_id in (''&&2'') UNION select priority_request_id from fnd_concurrent_requ
ests where request_id in (''&&2'')))', null, 'Y');
end if;
if upper('&&1') = 'PROGRAM' then
-- ************************
-- *** Program.......... Syntax: Parameter1: Program Parameter2: <concurrent_p
rogram_name> Parameter3: 0
-- ************************
Display_Table('FND_APPLICATION', null, 'where app
lication_id in (select application_id from FND_CONCURRENT_PROGRAMS where concurr
ent_program_name = (''&&2''))', null, 'Y');
Display_Table('FND_CONCURRENT_PROGRAMS', null, 'where con
current_program_name = (''&&2'')', null, 'Y');
Display_Table('FND_CONCURRENT_PROGRAMS_TL', null, 'where con
current_program_id in (select concurrent_program_id from fnd_concurrent_programs
where concurrent_program_name = (''&&2''))', null, 'Y');
Display_Table('FND_EXECUTABLES', null, 'where (EX
ECUTABLE_ID, APPLICATION_ID) in (select executable_id, application_id from FND_C
ONCURRENT_PROGRAMS where concurrent_program_name = (''&&2''))', null, 'Y');
Display_Table('FND_EXECUTABLES_TL', null, 'where (EX
ECUTABLE_ID, APPLICATION_ID) in (select executable_id, application_id from FND_C
ONCURRENT_PROGRAMS where concurrent_program_name = (''&&2''))', null, 'Y');
Display_Table('FND_DESCR_FLEX_COLUMN_USAGES', null, 'where des
criptive_flexfield_name = ''$SRS$.&&2''', 'order by column_seq_num', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where fle
x_value_set_id in (select flex_value_set_id from fnd_descr_flex_column_usages wh
ere descriptive_flexfield_name = ''$SRS$.&&2'')', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where fle
x_value_set_id in (select flex_value_set_id from fnd_descr_flex_column_usages wh
ere descriptive_flexfield_name = ''$SRS$.&&2'')', null, 'Y');
Display_Table('FND_CONCURRENT_PROGRAM_SERIAL', null, 'where (ru
nning_application_id, running_concurrent_program_id) in (select application_id,
concurrent_program_id from fnd_concurrent_programs where concurrent_program_name
in (''&&2''))', null, 'Y');
Display_Table('FND_CONCURRENT_PROGRAMS', 'Incompatibles', 'where (ap
plication_id, concurrent_program_id) in (select to_run_application_id, to_run_co
ncurrent_program_id from fnd_concurrent_program_serial where (running_applicatio
n_id, running_concurrent_program_id) in (select application_id, concurrent_progr
am_id from fnd_concurrent_programs where concurrent_program_name in (''&&2'')))'
, null, 'Y');
select upper(substr(execution_file_name, 1, instr(execution_file_name,'.')-1))
into l_var1
from FND_EXECUTABLES
where(EXECUTABLE_ID, APPLICATION_ID) in (select executable_id, application_id fr
om FND_CONCURRENT_PROGRAMS where concurrent_program_name = ('&&2'));
Display_Table('ALL_OBJECTS', null, 'where obj
ect_name = '''||l_var1||'''', null, 'Y');
Display_Table('ALL_SOURCE', null, 'where nam
e = '''||l_var1||''' and line = 2', null, 'Y');
Display_Table('ALL_ERRORS', null, 'where nam
e = '''||l_var1||''' and line = 2', null, 'Y');
end if;
if upper('&&1') = 'FND_MESSAGES' then
-- ************************
-- *** FND_MESSAGES..... Syntax: Parameter1: FND_MESSAGES Parameter2: <applica
tion_id> Parameter3: 0
-- ************************
Display_Table('FND_NEW_MESSAGES', null, 'where application_id in (''&
&2'')', null, 'Y');
end if;
if upper('&&1') = 'PROFILES' then
-- ************************
-- *** PROFILES..... Syntax: Parameter1: PROFILES Parameter2: <application_id>
Parameter3: <profile short name>
-- ************************
if l_param3 <> '0' then
Display_Profiles(null, l_param3);
else
Display_Profiles(l_param2,null);
end if;
end if;
if upper('&&1') = 'HR_FORMULAS' then
-- ************************
-- *** HR_Formulas...... Syntax: Parameter1: HR_FORMULAS Parameter2: 0 Parame
ter3: 0
-- ************************
Display_Table('FF_FORMULAS_F', null, 'where 1=1', 'orde
r by formula_id', 'N');
end if;
if upper('&&1') = 'OTL_FORMULAS' then
-- ************************
-- *** OTL_Formulas...... Syntax: Parameter1: OTL_FORMULAS Parameter2: 0 Para
meter3: 0
-- ************************
Display_Table('FF_FORMULAS_F', null, 'where Formula_Nam
e like (''HXC.HXC%'')', 'order by formula_id', 'N');
end if;
if upper('&&1') = 'OTL_FORMULA' then
-- ************************
-- *** OTL_Formula....... Syntax: Parameter1: OTL_FORMULA Parameter2: <formula
_name> Parameter3: <formula_id>
-- ************************
if l_param3 <> 0 then
l_num1 := l_param3;
else
select min(formula_id)
into l_num1
from FF_FORMULAS_F
where formula_name = '&&2';
end if;
select min(formula_name)
into l_var1
from FF_FORMULAS_F
where formula_id = l_num1;
new_section('Formula Definition');
Display_Table('FF_FORMULAS_F', null, 'where formula_id
= ('||l_num1||')', null, 'Y');
Display_Table('FF_FORMULA_TYPES', null, 'where formula_typ
e_id in (select formula_type_id from ff_formulas_f where formula_id = ('||l_num1
||'))', null, 'Y');
Display_Table('FF_COMPILED_INFO_F', null, 'where formula_id
= ('||l_num1||')', null, 'Y');
new_section('Database Object');
Display_Table('ALL_OBJECTS', null, 'where object_name
like (''FFP''||'||l_num1||'||''%'')', 'order by object_type', 'Y');
select min(object_name)
into l_var2
from all_objects
where object_name like ('FFP'||l_num1||'%');
Display_Table('ALL_SOURCE', 'ALL_SOURCE - Package', 'where owner = ''AP
PS'' and name = ('''||l_var2||''') and type = ''PACKAGE'' ', 'order by line', 'Y
');
Display_Table('ALL_SOURCE', 'ALL_SOURCE - Package Body', 'where owner = ''AP
PS'' and name = ('''||l_var2||''') and type = ''PACKAGE BODY'' ', 'order by line
', 'Y');
Display_Table('ALL_ERRORS', null, 'where name = ('''|
|l_var2||''')', 'order by type, line', 'Y');
new_section('OTL Formulas DFF');
Display_Table('FND_DESCRIPTIVE_FLEXS', null, 'where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTL Formulas'' ', null, 'Y');
--Display_Table('FND_DESCRIPTIVE_FLEXS_VL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' ', null, 'Y');
--Display_Table('FND_DESCRIPTIVE_FLEXS_TL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' ', null, 'Y');
Display_Table('FND_TABLES', null, 'where (table_name,
application_id) in (select application_table_name, application_id from FND_DESC
RIPTIVE_FLEXS where DESCRIPTIVE_FLEXFIELD_NAME = ''OTL Formulas'')', null, 'Y');
Display_Table('FND_DESCR_FLEX_CONTEXTS', null, 'where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) like
upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
--Display_Table('FND_DESCR_FLEX_CONTEXTS_VL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
--Display_Table('FND_DESCR_FLEX_CONTEXTS_TL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE', 'Y');
Display_Table('FND_DESCR_FLEX_COLUMN_USAGES', null, 'where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) like
upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(su
bstr(APPLICATION_COLUMN_NAME,10))', 'Y');
--Display_Table('FND_DESCR_FLEX_COL_USAGE_VL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(
substr(APPLICATION_COLUMN_NAME,10))', 'Y');
--Display_Table('FND_DESCR_FLEX_COL_USAGE_TL', null, 'where DESCRIPTIV
E_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE) lik
e upper('''||l_var1||''')', ' order by DESCRIPTIVE_FLEX_CONTEXT_CODE, to_number(
substr(APPLICATION_COLUMN_NAME,10))', 'Y');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_s
et_id in (select flex_value_set_id from fnd_descr_flex_column_usages where DESCR
IPTIVE_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE
) like upper('''||l_var1||'''))', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_s
et_id in (select flex_value_set_id from fnd_descr_flex_column_usages where DESCR
IPTIVE_FLEXFIELD_NAME = ''OTL Formulas'' and upper(DESCRIPTIVE_FLEX_CONTEXT_CODE
) like upper('''||l_var1||'''))', null, 'Y');
Display_Table('FND_COLUMNS', null, 'where (column_name
, table_id) in (select a.application_column_name, b.table_id from FND_DESCR_FLEX
_COL_USAGE_VL A, FND_TABLES B, FND_DESCRIPTIVE_FLEXS C where C.DESCRIPTIVE_FLEXF
IELD_NAME = ''OTL Formulas'' and a.descriptive_flexfield_name = c.descriptive_fl
exfield_name and c.application_table_name = b.table_name and c.application_id =
b.application_id)', null, 'Y');
Display_Table('FND_DEFAULT_CONTEXT_FIELDS', null, 'where DESCRIPTIVE_
FLEXFIELD_NAME = ''OTL Formulas'' ', null, 'Y');
new_section('Time Entry Rules');
Display_Table('HXC.HXC_TIME_ENTRY_RULES', null, 'where formula_
id = ('||l_num1||')', ' order by time_entry_rule_id', 'Y');
end if;

if upper('&&1') = 'PACKAGE' then


-- ************************
-- *** PACKAGE..... Syntax: Parameter1: PACKAGE Parameter2: <package_name> Pa
rameter3: <owner>
-- ************************
Display_Table('ALL_SOURCE', 'ALL_SOURCE - Spec', 'where (owner
= (''&&3'') or 1=1) and name = (''&&2'') and type = ''PACKAGE'' ', 'order by lin
e', 'Y');
Display_Table('ALL_SOURCE', 'ALL_SOURCE - Body', 'where (owner
= (''&&3'') or 1=1) and name = (''&&2'') and type = ''PACKAGE BODY'' ', 'order b
y line', 'Y');
end if;
if upper('&&1') = 'VIEWS' then
-- ************************
-- *** Views............ Syntax: Parameter1: Views Parameter2: <view_name> Pa
rameter3: 0
-- ************************
sqlTxt := 'select * from DBA_VIEWS where view_name in upper(''&&2'')';
run_sql('DBA_TABLESPACES', sqltxt);
--Display_Table('ALL_VIEWS', Null, 'where view_name in upper(''&&2
'')', null, 'N');
--Display_Table('ALL_OBJECTS', Null, 'where object_name in upper(''&
&2'')', null, 'Y');
--Display_Table('ALL_ERRORS', Null, 'where name in upper(''&&2'')',
null, 'Y');
end if;
if upper('&&1') = 'ANYTABLE' then
-- ************************
-- *** AnyTable........... Syntax: Parameter1: ANYTABLE Parameter2: table_name
Parameter3: <# of rows or 0 for all>
-- ************************
Display_Table('&&2', Null, 'where ''&&3'' = 0 or rownum <= ''&&3''', null, 'Y');
end if;
if upper('&&1') = 'KEY_FLEX' then
-- ************************
-- *** KEY_FLEX........... Syntax: Parameter1: KEY_FLEX Parameter2: <Key Flex
Code> Parameter3: <Flex Structure ID>
-- ************************
CheckKeyFlexfield('SCL',null,true);
end if;
if upper('&&1') = 'LOOKUP' then
-- ************************
-- *** LOOKUP.............. Syntax: Parameter1: LOOKUP Parameter2: <lookup_typ
e> Parameter3: <lookup_code>
-- ************************
Display_Table('FND_LOOKUP_TYPES', null, 'where lookup_type = up
per((''&&2''))', 'order by lookup_type, security_group_id', 'Y');
Display_Table('FND_LOOKUP_TYPES_TL', null, 'where lookup_type = up
per((''&&2''))', 'order by lookup_type, security_group_id', 'Y');
if l_param3 = '0' then
Display_Table('FND_LOOKUP_VALUES', null, 'where lookup_type = up
per((''&&2''))', 'order by lookup_type, lookup_code, security_group_id, language
', 'Y');
else
Display_Table('FND_LOOKUP_VALUES', null, 'where lookup_type = up
per((''&&2'')) and lookup_code = upper((''&&3''))', 'order by lookup_type, looku
p_code, security_group_id, language', 'Y');
end if;
end if;
if upper('&&1') = '5932916' then
-- ************************
-- *** 5932916........... Syntax: Parameter1: 5932916 Parameter2: 0 Parameter
3: 0
-- ************************
sqlTxt :=
'select count(1)
--distinct paf.full_name,
--htb3.start_time Date_worked,
--DECODE( htb1.type, ''RANGE'',
-- ((htb1.stop_time-htb1.start_time)*24), htb1.measure) Hours_worked,
-- htb1.time_building_block_id,
--htb1.object_version_number
from HXC.HXC_time_building_blocks htb1
, HXC.HXC_time_building_blocks htb3
, HXC.HXC_timecard_summary hts
, nuan_per_people_f_mv paf
where htb1.scope = ''DETAIL''
and htb1.approval_status = ''WORKING''
and htb1.object_version_number = (select max(object_version_number)
from HXC.HXC_time_building_blocks htb2
where htb2.time_building_block_id = htb1.t
ime_building_block_id )
and htb1.date_to <> hr_general.end_of_time
and htb3.time_building_block_id = htb1.parent_building_block_id
and htb3.object_version_number = htb1.parent_building_block_ovn
and hts.timecard_id = htb3.parent_building_block_id
and hts.approval_status <> ''WORKING''
and htb1.resource_id = paf.person_id
and exists (select ''Y''
from HXC.HXC_transaction_details htd
, HXC.HXC_transactions ht
where htd.time_building_block_id = htb1.time_building_block_id
and ht.transaction_id = htd.TRANSACTION_ID
and ht.type = ''RETRIEVAL''
and htd.time_building_block_ovn = (select max(htd2.time_buildi
ng_block_ovn)
from HXC.HXC_transaction_
details htd2
, HXC.HXC_transactions
ht2
where htd2.time_building_b
lock_id = htb1.time_building_block_id
and ht2.transaction_id =
htd2.TRANSACTION_ID
and ht2.type = ''RETRIEV
AL'')
and htd.status = ''SUCCESS'')
and not exists (select ''Y''
from HXC.HXC_transaction_details htd
, HXC.HXC_transactions ht
where htd.time_building_block_id = htb1.time_building_block_
id
and htd.time_building_block_ovn = htb1.object_version_numb
er
and ht.transaction_id = htd.TRANSACTION_ID
and ht.type = ''RETRIEVAL'')
order by htb1.time_building_block_id desc';
run_sql('Bug:5932916 Check', sqltxt);
show_code(sqltxt);
end if;
if upper('&&1') = '8334957' then
-- ************************
-- *** 8334957........... Syntax: Parameter1: 8334957 Parameter2: 0 Parameter
3: 0
-- ************************
sqlTxt :=
'select distinct paf.full_name
, htb3.start_time Date_worked
, DECODE( htb1.type, ''RANGE'',((htb1.stop_time-htb1.start_time)*24), htb1.
measure) Hours_worked
, htb1.time_building_block_id
, htb1.object_version_number
from HXC.HXC_time_building_blocks htb1
, HXC.HXC_time_building_blocks htb3
, HXC.HXC_timecard_summary hts
, nuan_per_people_f_mv paf
where htb1.scope = ''DETAIL''
and htb1.approval_status = ''WORKING''
and htb1.object_version_number = (select max(object_version_number)
from HXC.HXC_time_building_blocks htb2
where htb2.time_building_block_id = htb1.t
ime_building_block_id )
and htb1.date_to <> hr_general.end_of_time
and htb3.time_building_block_id = htb1.parent_building_block_id
and htb3.object_version_number = htb1.PARENT_BUILDING_BLOCK_OVN
and hts.timecard_id = htb3.parent_building_block_id
and htb1.resource_id = paf.person_id
and exists (select ''Y''
from HXC.HXC_transaction_details htd
, HXC.HXC_transactions ht
where htd.time_building_block_id = htb1.time_building_block_id
and ht.transaction_id = htd.TRANSACTION_ID
and ht.type = ''RETRIEVAL''
and htd.time_building_block_ovn = (select max(htd2.time_buildi
ng_block_ovn)
from HXC.HXC_transaction_
details htd2
, HXC.HXC_transactions
ht2
where htd2.time_building_b
lock_id = htb1.time_building_block_id
and ht2.transaction_id =
htd2.TRANSACTION_ID
and ht2.type = ''RETRIEV
AL'')
and htd.status = ''SUCCESS'')
and not exists (select ''Y''
from HXC.HXC_transaction_details htd
, HXC.HXC_transactions ht
where htd.time_building_block_id = htb1.time_building_block_
id
and htd.time_building_block_ovn = htb1.object_version_numb
er
and ht.transaction_id = htd.TRANSACTION_ID
and ht.type = ''RETRIEVAL'' )
order by htb1.time_building_block_id desc';
run_sql('Bug:8334957 Check', sqltxt);
show_code(sqltxt);
end if;
if upper('&&1') = 'MINI' then
-- ************************
-- *** MINI.. Syntax: Parameter1: MINI, Parameter2: <person_id>, Parameter3: <s
tart date>
-- ************************
select timecard_id
into l_num1
from HXC.HXC_TIMECARD_SUMMARY
where resource_id = ('&&2')
and trunc(start_time) = to_date('&&3');
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD''
and time_building_block_id = ('||l_num1||')';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))) order by time
_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Timecard', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DAY'' and
parent_building_block_id in (select time_building_block_id from HXC.HXC_time_bui
lding_blocks where scope = ''TIMECARD'' and time_building_block_id = ('||l_num1|
|'))';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DAY'' and parent_building_block_id in (select time_building_block_id fro
m HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_bloc
k_id = ('||l_num1||')))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DAY'' and parent_building_block_id in (select time_building_block_id f
rom HXC.HXC_time_building_blocks where scope = ''TIMECARD'' and time_building_bl
ock_id = ('||l_num1||')))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Day', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''DETAIL'' a
nd parent_building_block_id in (select time_building_block_id from HXC.HXC_time_
building_blocks where scope = ''DAY'' and parent_building_block_id in (select ti
me_building_block_id from HXC.HXC_time_building_blocks where scope = ''TIMECARD'
' and time_building_block_id = ('||l_num1||'))) order by time_building_block_id,
object_version_number';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope = ''DETAIL'' and parent_building_block_id in (select time_building_block_id
from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bloc
k_id in (select time_building_block_id from HXC.HXC_time_building_blocks where s
cope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''DETAIL'' and parent_building_block_id in (select time_building_block_i
d from HXC.HXC_time_building_blocks where scope = ''DAY'' and parent_building_bl
ock_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope = ''TIMECARD'' and time_building_block_id = ('||l_num1||'))))) order by t
ime_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Detail', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_BUILDING_BLOCKS where scope not in (''TIME
CARD'',''DAY'',''DETAIL'') and time_building_block_id = ('||l_num1||')';
run_sql('HXC.HXC_TIME_BUILDING_BLOCKS - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTE_USAGES where time_building_block
_id in (select time_building_block_id from HXC.HXC_time_building_blocks where sc
ope not in (''TIMECARD'',''DAY'',''DETAIL'') and time_building_block_id = ('||l_
num1||'))';
run_sql('HXC.HXC_TIME_ATTRIBUTE_USAGES - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIME_ATTRIBUTES where time_attribute_id in (sel
ect time_attribute_id from HXC.HXC_time_attribute_usages where time_building_blo
ck_id in (select time_building_block_id from HXC.HXC_time_building_blocks where
scope not in (''TIMECARD'',''DAY'',''DETAIL'') and time_building_block_id = ('||
l_num1||'))) order by time_attribute_id';
run_sql('HXC.HXC_TIME_ATTRIBUTES - Other', sqltxt);
sqlTxt := 'select * from HXC.HXC_TIMECARD_SUMMARY where timecard_id in (select t
ime_building_block_id from HXC.HXC_TIME_BUILDING_BLOCKS where scope = ''TIMECARD
'' and time_building_block_id = ('||l_num1||'))';
run_sql('HXC.HXC_TIMECARD_SUMMARY', sqltxt);
end if;
if upper('&&1') = 'VALUE_SET' then
-- ************************
-- *** VALUE_SET........... Syntax: Parameter1: VALUE_SET Parameter2: <flex_va
lue_set_id> Parameter3: 0
-- *** VALUE_SET........... Syntax: Parameter1: VALUE_SET Parameter2: 0
Parameter3: <flex_value_set_name>
-- ************************
if l_param2 = '0' then
select flex_value_set_id
into l_param2
from FND_FLEX_VALUE_SETS
where flex_value_set_name like '%'||l_param3||'%';
end if;
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id
= '||l_param2||'', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id
= '||l_param2||'', null, 'Y');
end if;
if upper('&&1') = 'HXC.HXC_PERSON' then
-- ************************
-- *** HXC.HXC_Person.. Syntax: Parameter1: HXC.HXC_Person Parameter2: <Person
_ID> Parameter3: 0
-- ************************
Display_Table('nuan_per_people_f_mv', Null, 'where person_id = (''
&&2'')', null, 'Y');
Display_Table('PER_PERSON_TYPES', Null, 'where person_type_id in (
select person_type_id from nuan_per_people_f_mv where person_id = (''&&2''))', n
ull, 'Y');
Display_Table('PER_PERSON_TYPE_USAGES_F', Null, 'where person_id = (''&&2'
')', null, 'Y');
--Display_Table('PER_PERIODS_OF_SERVICE', Null, 'where person_id = (''&&
2'')', null, 'N');
Display_Table('PER_ALL_ASSIGNMENTS_F', Null, 'where person_id = (''&&2'
')', null, 'Y');
Display_Table('PER_ASSIGNMENT_STATUS_TYPES', Null, 'where assignment_status_t
ype_id in (select assignment_status_type_id from PER_ALL_ASSIGNMENTS_F where per
son_id = (''&&2''))', null, 'Y');
Display_Table('HR_SOFT_CODING_KEYFLEX', Null, 'where soft_coding_keyflex
_id in (select soft_coding_keyflex_id from PER_ALL_ASSIGNMENTS_F where person_id
= (''&&2''))', null, 'Y');
sqlTxt:='select USER_ID
, USER_NAME
, LAST_UPDATE_DATE
, LAST_UPDATED_BY
, CREATION_DATE
, CREATED_BY
, LAST_UPDATE_LOGIN
--, ENCRYPTED_FOUNDATION_PASSWORD
--, ENCRYPTED_USER_PASSWORD
, SESSION_NUMBER
, START_DATE
, END_DATE
, DESCRIPTION
, LAST_LOGON_DATE
, PASSWORD_DATE
, PASSWORD_ACCESSES_LEFT
, PASSWORD_LIFESPAN_ACCESSES
, PASSWORD_LIFESPAN_DAYS
, EMPLOYEE_ID
, EMAIL_ADDRESS
, FAX
, CUSTOMER_ID
, SUPPLIER_ID
, WEB_PASSWORD
, SECURITY_GROUP_ID
--, USER_GUID
, GCN_CODE_COMBINATION_ID
, PERSON_PARTY_ID
from FND_USER
where employee_id = (''&&2'')';
run_sql('FND_USER', sqltxt);
Display_Table('WF_ROLES', Null, 'where orig_system = ''PER
'' and orig_system_id = (''&&2'')', null, 'Y');
Display_Table('HXT_ADD_ASSIGN_INFO_F', Null, 'where assignment_id in (s
elect assignment_id from PER_ALL_ASSIGNMENTS_F where person_id = (''&&2''))', 'o
rder by id, effective_start_date', 'Y');

end if;

if upper('&&1') = 'TDK' then


-- ************************
-- *** TDK.............. Syntax: Parameter1: TDK Parameter2: 0 Parameter3: 0
-- ************************
begin
declare
TimecardUpdate_fv varchar2(30);
TimecardUpdate_op varchar2(30);
TimecardUpdate_ps varchar2(30);
TimecardUtilities_fv varchar2(30);
TimecardUtilities_op varchar2(30);
TimecardUtilities_ps varchar2(30);
HXC.HXCDataTranslator_fv varchar2(30);
HXC.HXCDataTranslator_op varchar2(30);
HXC.HXCDataTranslator_ps varchar2(30);
begin

--Tab0Print(get_fnd_version);
--Tab0Print(check_version('fnd','12.1'));
if check_version('fnd','12.1') = 'greater' and check_version('fnd','12.2') = 'le
sser' then
-- Tab0Print('12.1');
TimecardUpdate_fv := '';
TimecardUpdate_op := '';
TimecardUpdate_ps := '';
TimecardUtilities_fv := '';
TimecardUtilities_op := '';
TimecardUtilities_ps := '';
HXC.HXCDataTranslator_fv := '';
HXC.HXCDataTranslator_op := '';
HXC.HXCDataTranslator_ps := '';
elsif check_version('fnd','12.0') = 'greater' and check_version('fnd','12.1') =
'lesser' then
-- Tab0Print('12.0');
TimecardUpdate_fv := '120.30.12000000.11';
TimecardUpdate_op := '7554354:R12.HXT.A';
TimecardUpdate_ps := 'unknown';
TimecardUtilities_fv := '120.20.12000000.5';
TimecardUtilities_op := '8434432:R12.HXT.A';
TimecardUtilities_ps := 'unknown';
HXC.HXCDataTranslator_fv := '120.22.12000000.5';
HXC.HXCDataTranslator_op := '6686029:R12.HXT.A';
HXC.HXCDataTranslator_ps := '6610000:R12.HR_PF.A.DELTA.5';

elsif check_version('fnd','11.5') = 'greater' and check_version('fnd','12.0') =


'lesser' then
-- Tab0Print('11.5');
TimecardUpdate_fv := '';
TimecardUpdate_op := '';
TimecardUpdate_ps := '';
TimecardUtilities_fv := '';
TimecardUtilities_op := '';
TimecardUtilities_ps := '';
HXC.HXCDataTranslator_fv := '';
HXC.HXCDataTranslator_op := '';
HXC.HXCDataTranslator_ps := '';
end if;

sqlTxt := '
select f.app_short_name, f.subdir, f.filename, max(v.version) version
--, decode(f.filename
--, ''TimecardUpdate.class'', '''||TimecardUpdate_fv ||'''
--, ''TimecardUtilities.class'', '''||TimecardUtilities_fv||'''
--, ''HXC.HXCDataTranslator.class'', '''||HXC.HXCDataTranslator_fv||'''
--) fixed_version
--, decode(f.filename
--, ''TimecardUpdate.class'', '''||TimecardUpdate_op ||'''
--, ''TimecardUtilities.class'', '''||TimecardUtilities_op||'''
--, ''HXC.HXCDataTranslator.class'', '''||HXC.HXCDataTranslator_op||'''
--) patch_fix
--, decode(f.filename
--, ''TimecardUpdate.class'', '''||TimecardUpdate_ps ||'''
--, ''TimecardUtilities.class'', '''||TimecardUtilities_ps||'''
--, ''HXC.HXCDataTranslator.class'', '''||HXC.HXCDataTranslator_ps||'''
--) patchset_fix
from AD_FILES f
, AD_FILE_VERSIONS v
where f.app_short_name = ''HXC.HXC''
and f.filename in
( ''TimecardUpdate.class''
, ''TimecardUtilities.class''
, ''HXC.HXCDataTranslator.class''
)
and f.file_id = v.file_id
group by f.file_id, f.app_short_name, f.subdir, f.filename
';
run_sql('File Versions', sqltxt);

--new_section('Duplicates');
sqlTxt := '
select tc1.time_building_block_id timecard_id
, tc1.resource_id resource_id
, tc1.start_time start_time
, det1.time_building_block_id time_building_block_id
, det1.date_to date_to
, det1.translation_display_key translation_display_key
from HXC.HXC_time_building_blocks tc1
, HXC.HXC_time_building_blocks day1
, HXC.HXC_time_building_blocks det1
, HXC.HXC_time_building_blocks tc2
, HXC.HXC_time_building_blocks day2
, HXC.HXC_time_building_blocks det2
where tc1.scope in (''TIMECARD'', ''TIMECARD_TEMPLATE'')';
if l_param2 <> '0' then
sqlTxt := sqlTxt ||'
and tc1.resource_id = '||l_param2;
end if;
if l_param3 <> '0' then
sqlTxt := sqlTxt ||'
and trunc(tc1.start_time) >= to_date('''||l_param3||''')';
end if;
sqlTxt := sqlTxt ||'
and tc1.date_to = to_date(''31-Dec-4712'')
and tc2.time_building_block_id = tc1.time_building_block_id
and tc2.object_version_number = tc1.object_version_number
and day1.parent_building_block_id = tc1.time_building_block_id
and day1.parent_building_block_ovn = tc1.object_version_number
and day2.parent_building_block_id = tc2.time_building_block_id
and day2.parent_building_block_ovn = tc2.object_version_number
and det1.parent_building_block_id = day1.time_building_block_id
and det1.parent_building_block_ovn = day1.object_version_number
and det2.parent_building_block_id = day2.time_building_block_id
and det2.parent_building_block_ovn = day2.object_version_number
and det1.date_to = to_date(''31-Dec-4712'')
and det2.date_to = det1.date_to
and det1.translation_display_key = det2.translation_display_key
and det1.time_building_block_id <> det2.time_building_block_id
order by tc1.time_building_block_id, det1.translation_display_key, det1.time_
building_block_id
';
--Tab0Print(replace(sqlTxt, chr(10),'<br>'));
run_sql('Duplicates', sqltxt);
--new_section('Wrong Line');
sqlTxt := '
with tab as (
select sum.timecard_id, sum.resource_id, sum.start_time, sum.stop_time, sum.appr
oval_status
, det.time_building_block_id, det.object_version_number, day.start_time day
, det.measure otl_hours, det.comment_text, det.translation_display_key
, substr(det.translation_display_key,instr(det.translation_display_key,''|'
',1,1)+1,instr(det.translation_display_key,''|'',1,2)-(instr(det.translation_dis
play_key,''|'',1,1)+1)) det_row
, att.attribute_category
, att.attribute1, att.attribute2, att.attribute3, att.attribute4, att.attri
bute5, att.attribute6, att.attribute7, att.attribute8, att.attribute9, att.attri
bute10
, att.attribute11, att.attribute12, att.attribute13, att.attribute14, att.a
ttribute15, att.attribute16, att.attribute17, att.attribute18, att.attribute19,
att.attribute20
, att.attribute21, att.attribute22, att.attribute23, att.attribute24, att.a
ttribute25, att.attribute26, att.attribute27, att.attribute28, att.attribute29,
att.attribute30
from HXC.HXC_timecard_summary sum
, HXC.HXC_time_building_blocks tim
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
, HXC.HXC_time_attribute_usages use
, HXC.HXC_time_attributes att
where 1=1';
if l_param2 <> '0' then
sqlTxt := sqlTxt ||'
and sum.resource_id = '||l_param2;
end if;
if l_param3 <> '0' then
sqlTxt := sqlTxt ||'
and trunc(sum.start_time) >= to_date('''||l_param3||''')';
end if;
sqlTxt := sqlTxt ||'
and tim.time_building_block_id = sum.timecard_id
and tim.object_version_number = sum.timecard_ovn
and day.parent_building_block_id = tim.time_building_block_id
and day.parent_building_block_ovn = tim.object_version_number
and det.parent_building_block_id = day.time_building_block_id
and det.parent_building_block_ovn = day.object_version_number
and det.date_to = to_date(''31-Dec-4712'')
and use.time_building_block_id = det.time_building_block_id
and use.time_building_block_ovn = det.object_version_number
and att.time_attribute_id = use.time_attribute_id
and (att.attribute_category = ''PROJECTS''
or att.attribute_category like ''ELEMENT%''))
select a.timecard_id, a.resource_id, a.start_time, a.stop_time
, a.time_building_block_id
, a.translation_display_key
, a.det_row detail_row
, a.attribute_category
, a.attribute1, a.attribute2, a.attribute3, a.attribute4, a.attribute5, a.a
ttribute6, a.attribute7, a.attribute8, a.attribute9, a.attribute10
, a.attribute11, a.attribute12, a.attribute13, a.attribute14, a.attribute15
, a.attribute16, a.attribute17, a.attribute18, a.attribute19, a.attribute20
, a.attribute21, a.attribute22, a.attribute23, a.attribute24, a.attribute25
, a.attribute26, a.attribute27, a.attribute28, a.attribute29, a.attribute30
from tab a
where exists (select 1
from tab b
where a.timecard_id = b.timecard_id
and a.time_building_block_id <> b.time_building_block_id
and a.det_row = b.det_row
and substr(a.attribute_category,1,8) = substr(b.attribute_cate
gory,1,8)
and (a.attribute_category = b.attribute_category
and (nvl(a.attribute1,''.'') <> nvl(b.attribute1,''.'')
or nvl(a.attribute2,''.'') <> nvl(b.attribute2,''.'')
or nvl(a.attribute3,''.'') <> nvl(b.attribute3,''.'')
or nvl(a.attribute4,''.'') <> nvl(b.attribute4,''.'')
or nvl(a.attribute5,''.'') <> nvl(b.attribute5,''.'')
or nvl(a.attribute6,''.'') <> nvl(b.attribute6,''.'')
or nvl(a.attribute7,''.'') <> nvl(b.attribute7,''.'')
or nvl(a.attribute8,''.'') <> nvl(b.attribute8,''.'')
or nvl(a.attribute9,''.'') <> nvl(b.attribute9,''.'')
or nvl(a.attribute10,''.'') <> nvl(b.attribute10,''.'')
or nvl(a.attribute11,''.'') <> nvl(b.attribute11,''.'')
or nvl(a.attribute12,''.'') <> nvl(b.attribute12,''.'')
or nvl(a.attribute13,''.'') <> nvl(b.attribute13,''.'')
or nvl(a.attribute14,''.'') <> nvl(b.attribute14,''.'')
or nvl(a.attribute15,''.'') <> nvl(b.attribute15,''.'')
or nvl(a.attribute16,''.'') <> nvl(b.attribute16,''.'')
or nvl(a.attribute17,''.'') <> nvl(b.attribute17,''.'')
or nvl(a.attribute18,''.'') <> nvl(b.attribute18,''.'')
or nvl(a.attribute19,''.'') <> nvl(b.attribute19,''.'')
or nvl(a.attribute20,''.'') <> nvl(b.attribute20,''.'')
or nvl(a.attribute21,''.'') <> nvl(b.attribute21,''.'')
or nvl(a.attribute22,''.'') <> nvl(b.attribute22,''.'')
or nvl(a.attribute23,''.'') <> nvl(b.attribute23,''.'')
or nvl(a.attribute24,''.'') <> nvl(b.attribute24,''.'')
or nvl(a.attribute25,''.'') <> nvl(b.attribute25,''.'')
or nvl(a.attribute26,''.'') <> nvl(b.attribute26,''.'')
or nvl(a.attribute27,''.'') <> nvl(b.attribute27,''.'')
or nvl(a.attribute28,''.'') <> nvl(b.attribute28,''.'')
or nvl(a.attribute29,''.'') <> nvl(b.attribute29,''.'')
or nvl(a.attribute30,''.'') <> nvl(b.attribute30,''.'')
)))
order by a.timecard_id, a.det_row, a.attribute_category, a.attribute1, a.attribu
te2, a.attribute3
';
--Tab0Print(replace(sqlTxt, chr(10),'<br>'));
run_sql('Wrong Line', sqltxt);

--new_section('Wrong Day');
sqlTxt := '
select tc.time_building_block_id timecard_id
, tc.resource_id
, tc.start_time
, det.time_building_block_id time_building_block_id
, day.start_time day
, day.translation_display_key day_tdk
, det.translation_display_key det_tdk
, to_number(day.start_time-tc.start_time) correct_segment3
from HXC.HXC_time_building_blocks tc
, HXC.HXC_time_building_blocks day
, HXC.HXC_time_building_blocks det
where tc.date_to = to_date(''31-DEC-4712'', ''DD-MON-YYYY'')';
if l_param2 <> '0' then
sqlTxt := sqlTxt ||'
and tc.resource_id = '||l_param2;
end if;
if l_param3 <> '0' then
sqlTxt := sqlTxt ||'
and trunc(tc.start_time) >= to_date('''||l_param3||''')';
end if;
sqlTxt := sqlTxt ||'
and day.parent_building_block_id = tc.time_building_block_id
and day.parent_building_block_ovn = tc.object_version_number
and day.date_to = tc.date_to
and det.parent_building_block_id = day.time_building_block_id
and det.parent_building_block_ovn = day.object_version_number
and det.date_to = day.date_to
and substr(det.translation_display_key,instr(det.translation_display_key,''|'
',1,2)+1,length(det.translation_display_key))
<> to_number(day.start_time-tc.start_time)
';
--Tab0Print(replace(sqlTxt, chr(10),'<br>'));
run_sql('Wrong Day', sqltxt);

end;
end;
end if;

if upper('&&1') = 'HXC.HXC_TIME_CATEGORY'
or upper('&&1') = 'HXC.HXC_TIME_CATEGORIES'
then
-- ************************
-- *** HXC.HXC_TIME_CATEGORY.. Syntax: Parameter1: HXC.HXC_TIME_CATEGORY Param
eter2: <time_category_id> Parameter3: 0
-- ************************
if upper(l_param2) = 'PTO' then
Display_Table('HXC.HXC_TIME_CATEGORIES', null, 'where time_category_
id in (select time_category_id from HXC.HXC_time_categories where time_category_
name like ''%OTL_DEC%'' or time_category_name like ''%OTL_INC%'')', 'order by ti
me_category_id', 'Y');
else
Display_Table('HXC.HXC_TIME_CATEGORIES', null, 'where time_category_
id in (''&&2'')', null, 'Y');
Display_Table('HXC.HXC_TIME_CATEGORY_COMPS', null, 'where time_category_
id in (''&&2'')', null, 'Y');
Display_Table('HXC.HXC_TIME_CATEGORY_COMP_SQL', null, 'where time_category_
comp_id in (select time_category_comp_id from HXC.HXC_time_category_comps where
time_category_id in (''&&2''))', null, 'Y');
new_section('Mapping Components');
Display_Table('HXC.HXC_MAPPING_COMPONENTS', null, 'where mapping_compon
ent_id in (select mapping_component_id from HXC.HXC_time_category_comps where ti
me_category_id in (''&&2''))', null, 'Y');
new_section('Value Sets');
Display_Table('FND_FLEX_VALUE_SETS', null, 'where flex_value_set_id
in (select flex_value_set_id from HXC.HXC_time_category_comps where time_categor
y_id in (''&&2''))', null, 'Y');
Display_Table('FND_FLEX_VALIDATION_TABLES', null, 'where flex_value_set_id
in (select flex_value_set_id from HXC.HXC_time_category_comps where time_categor
y_id in (''&&2''))', null, 'Y');
sqlTxt := '
select display_column, expenditure_type, system_linkage_m
from pa_online_expenditure_types_v
where expenditure_type = ''Administrative Staff''
';
run_sql('PA_ONLINE_EXPENDITURE_TYPES_V', sqltxt);

end if;
end if;

if upper('&&1') = 'PREFS' then


-- ************************
-- *** PREFS.............. Syntax: Parameter1: PREFS Parameter2: 0 Parameter3
: 0
-- ************************
sqlTxt := '
select *
from HXC.HXC_PREF_HIERARCHIES
connect by parent_pref_hierarchy_id = pref_hierarchy_id
order by nvl(business_group_id,-1), pref_hierarchy_id
';
run_sql('HXT_EARNING_RULES', sqltxt);

end if;

if upper('&&1') = 'HXT_EP' then


-- ************************
-- *** HXT_EP.............. Syntax: Parameter1: HXT_EP Parameter2: <id> Param
eter3: 0
-- ************************
new_section('EARNING POLICY');
sqlTxt := 'select * from HXT_EARNING_POLICIES where id = ('||l_param2||')';
run_sql('HXT_EARNING_POLICIES', sqltxt);
sqlTxt := 'select * from HXT_EARNING_RULES where egp_id in
(select id from HXT_EARNING_POLICIES where id = ('||l_param2||'))
order by seq_no';
run_sql('HXT_EARNING_RULES', sqltxt);

new_section('EARNING GROUP');
sqlTxt := 'select * from HXT_EARN_GROUP_TYPES where id in
(select egt_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_EARN_GROUP_TYPES', sqltxt);
sqlTxt := 'select * from HXT_EARN_GROUPS where egt_id in
(select egt_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))
order by element_type_id';
run_sql('HXT_EARN_GROUPS', sqltxt);

new_section('HOLIDAY CALENDAR');
sqlTxt := 'select * from HXT_HOLIDAY_CALENDARS where id in
(select Hcl_Id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_HOLIDAY_CALENDARS', sqltxt);
sqlTxt := 'select * from HXT_HOLIDAY_DAYS where hcl_id in
(select Hcl_Id from HXT_EARNING_POLICIES where id = ('||l_param2||'))
order by holiday_date';
run_sql('HXT_HOLIDAY_DAYS', sqltxt);

new_section('PREMIUM ELIGIBILITY POLICY');


sqlTxt := 'select * from HXT_PREM_ELIGBLTY_POLICIES where id in
(select pep_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_ELIGBLTY_POLICIES - Premium Eligibility Policy', sqltxt);
sqlTxt := 'select * from HXT_PREM_ELIGBLTY_POL_RULES where pep_id in
(select pep_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_ELIGBLTY_POL_RULES - Premium Eligibility Rules', sqltxt);
sqlTxt := 'select * from HXT_PREM_ELIGBLTY_RULES where pep_id in
(select pep_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_ELIGBLTY_RULES - Premiums', sqltxt);

new_section('PREMIUM INTERACTION POLICY');


sqlTxt := 'select * from HXT_PREM_INTERACT_POLICIES where id in
(select pip_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_INTERACT_POLICIES - Premium Interaction Policy', sqltxt);
sqlTxt := 'select * from HXT_PREM_INTERACT_POL_RULES where pip_id in
(select pip_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_INTERACT_POL_RULES - Premium Interaction Rules', sqltxt);
sqlTxt := 'select * from HXT_PREM_INTERACT_RULES where pip_id in
(select pip_id from HXT_EARNING_POLICIES where id = ('||l_param2||'))'
;
run_sql('HXT_PREM_INTERACT_RULES - Premiums', sqltxt);

new_section('ELEMENTS');
sqlTxt := 'select * from HXT_ADD_ELEM_INFO_F where element_type_id in
(select element_type_id from HXT_EARNING_RULES where egp_id in
(select id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id
in
(select element_type_id from HXT_EARN_GROUPS where egt_id in
(select egt_id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
))
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select Element_Type_Id from HXT_HOLIDAY_CALENDARS where id in
(select Hcl_Id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
)
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select Elt_Base_Id from HXT_PREM_ELIGBLTY_POL_RULES where Pep_Id in
(select Pep_Id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
)
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select Elt_Premium_Id from HXT_PREM_ELIGBLTY_RULES where Pep_Id in
(select Pep_Id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
)
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select Elt_Earned_Prem_Id from HXT_PREM_INTERACT_POL_RULES where Pip_
Id in
(select Pip_Id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
)
or element_type_id in
(select element_type_id from HXT_ADD_ELEM_INFO_F where element_type_id in
(select Elt_Prior_Prem_Id from HXT_PREM_INTERACT_RULES where Pip_Id in
(select Pip_Id from HXT_EARNING_POLICIES where id = ('||l_param2||')))
)
order by element_type_id';
run_sql('HXT_ADD_ELEM_INFO_F - Element Time Information', sqltxt);
end if;

-- Show_Footer('&v_scriptlongname', '&v_headerinfo');
EXCEPTION
when others then
BRPrint;
ErrorPrint(sqlerrm ||' occurred in test');
ActionErrorPrint('Please report the above error to Oracle Support Services.');
BRPrint;
Show_Footer('&v_scriptlongname', '&v_headerinfo');
BRPrint;
end;
end;
/
REM ==============SQL PLUS Environment setup===================
Spool off
set termout on
PROMPT
prompt Output spooled to filename &outputfilename
prompt

You might also like