Using profile option ‘Initialization SQL Statement -Custom’

Posted by Jiltin     17 February, 2009    4,937 views   

How to set ‘Initialization SQL Statement – Custom’ (FND_INIT_SQL) profile option?

This is used to get trace files for the concurrent Programs you run through oracle applications. User mainly by technical persons who are trying to solve an issue where manipulating some database session level parameter can help to gather more information.

Using the profile option ‘Initialization SQL Statement – Custom’, you can add site-specific initialization code, such as optimizer settings. This profile value must be a valid SQL statement, or a PL/SQL block for more than one statement, that is to be executed once at the startup of every database session.

The code is executed by FND_GLOBAL.INITIALIZE and APPS_INITIALIZE immediately after initializing global variables, profiles, and the contents of client_info on session startup.

The order of execution is:

FND_GLOBAL values initialized Profiles initialized

CLIENT_INFO contents initialized

FND_APPS_INIT_SQL initialization code called (if a value is defined)

FND_INIT_SQL initialization code called (if a value is defined)

This means that in most cases (eg. tracing a form) the profile option setting will be effective after signing-on again. You can set this profile option at different levels like user/responsibility/ /application or site.

You can specify any valid SQL statement or a PL/SQL block for this profile value, but the best way is using the fnd_sess_ctl procedure of fnd_ctl package.

The value of this profile option can be set using fnd_sess_ctl as follows:
BEGIN
FND_CTL.FND_SESS_CTL(
,
,
,
,
,
);
END;

The different parameters are (all within single quotes) :

-> This sets the Optimizer_mode for online users. The valid values are RULE/CHOOSE/FIRST_ROWS/ALL_ROWS.
It is recommended for CBO you set it to FIRST_ROWS.

-> This sets the Optimizer_mode for conc. jobs. The valid values are RULE/CHOOSE/FIRST_ROWS/ALL_ROWS .

It is recommeneded for CBO you set it to ALL_ROWS.

-> This sets the trace option to true or false. Valid values are TRUE/FALSE. If set to true then you will be able to generate the trace files for the session.

-> This sets the times_statistics for tracing to true or false. Valid values are TRUE/FALSE.

-> Reserved for logging. Logs session information in FND_TRACE_LOG. Recommended value is ”, other possible value is LOG.

-> This can be set for different events. An example could be to set an event point in order to get the values of the bind values in the trace file. In that case the example setting is as follows.

‘ALTER SESSION SET EVENTS = ””””” 10046 TRACE NAME CONTEXT FOREVER, LEVEL 4 ”””’ .

Please make sure you have all the quotes correct.

Examples:
———
1) To enable SQL trace for the session, you should set the profile option as follows:

BEGIN FND_CTL.FND_SESS_CTL(”,”,’TRUE’,'TRUE’,”,”); END;

Result of the above setting will be the execution of the following two alter session commands at database session startup:

ALTER SESSION SET SQL_TRACE = ‘TRUE’
ALTER SESSION SET TIMED_STATISTICS = ‘TRUE’

2) To put an event statement for getting bind variables in the trace file set the profile option as follows

BEGIN FND_CTL.FND_SESS_CTL(”,”,”,”,”,’ALTER SESSION SET EVENTS =””””” 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12 ”””’); END;

3) To set the logging on,

set the profile options (Initialization SQL statement – custom) as follows:
BEGIN FND_CTL.FND_SESS_CTL(”,”,”,”,’LOG’,”); END;

begin fnd_ctl.fnd_sess_ctl(,,‘TRUE’,‘TRUE’,, ‘ALTER SESSION SET EVENTS=’‘10046 TRACE NAME CONTEXT FOREVER, LEVEL 12′‘TRACEFILE_IDENTIFIER=’‘JIL’);end;

begin fnd_ctl.fnd_sess_ctl(”,”,’TRUE’,'TRUE’,”, ‘ALTER SESSION SET EVENTS=”””””10046 TRACE NAME CONTEXT FOREVER, LEVEL 12”””””TRACEFILE_IDENTIFIER=”””””JIL”””’);end;

For this option the log table is FND_TRACE_LOG, This table should be purged periodically.
If this LOG mode is set then then following information will be inserted in FND_TRACE_LOG table (every time when fnd_global.initialize procedure is called):
user_name,
sysdate,
conc_request_id,
oltp_opt_mode, (optimizer mode for online transactions)
conc_opt_mode, (optimizer mode for concurrent programs)
conc_program_name,
user_conc_program_name,
resp_name,
application_short_name

Here I am setting the custom sql for sysadmin for test purposes.


WARNINGS

——–
1) Do not ever set profile option ‘Initialization SQL Statement – Oracle’ instead of ‘Initialization SQL Statement – Custom’.
‘Initialization SQL Statement – Oracle’ (FND_APPS_INIT_SQL) profile option is used by Oracle Applications to add application-specific initialization code.

This profile option is set at the application level only, and will only be executed for responsibilities owned by that application. This profile option and its value settings are delivered as seed data, and must not be modified.

2) Setting of profile option ‘Initialization SQL Statement – Custom’ can effect on the operation of the whole Applications. As far as possible set this profile option only on USER level. Syntax error can cause that users can not login to the Applications or cannot run any concurrent programs. Please make sure syntax is correct. If you set this profile option on site level and a syntax error is in the profile value then it would cause that nobody can login to the applications.

In this situation the error message is something similar: ORA-20001: Oracle error -20001: ORA-20001: -: While executing SQL in profile FND_INIT_SQL:BEGIN FND_CTL.FND_SESS_CTL(’RUL’,”,”,”,’LOG’,”)has been detected in FND_GLOBAL.INITIALIZE.

If you cannot login to Applications with any apps user then you can correct this in SQL*Plus by selecting and updating the profile_option_value:

SELECT val.level_id, val.level_value, val.profile_option_id, val.profile_option_value
FROM fnd_profile_options opt, fnd_profile_option_values val
WHERE opt.profile_option_name = ‘FND_INIT_SQL’ AND opt.profile_option_id = val.profile_option_id;

You can correct the syntax error or can set profile_option_value to NULL and then define it in the Applications again (preferred way):

UPDATE fnd_profile_option_values SET profile_option_value = NULL WHERE profile_option_id =
AND level_id =  AND level_value = ;

How to check the existing values of ‘Initialization SQL Statement -Custom’?

SELECT
val.level_id,
val.level_value,
val.profile_option_id,
val.profile_option_value
FROM
fnd_profile_options opt,
fnd_profile_option_values val
WHERE
opt.profile_option_name = ‘FND_INIT_SQL’ AND
opt.profile_option_id = val.profile_option_id;

Following script used to set the values using sqlplus instead of sys.adm -> profile value.
The script can be downloaded here

var v_mdfs varchar2(30);
var v_ts   varchar2(30);

BEGIN
SELECT value
INTO   :v_mdfs
FROM   v$parameter
WHERE  name = ‘max_dump_file_size’;

SELECT value
INTO   :v_ts
FROM   v$parameter
WHERE  name = ‘timed_statistics’;
END;
/

SET term ON;

PROMPT
PROMPT
PROMPT You are about TO turn SQL Trace ON FOR ALL new sessions, Forms OR
PROMPT Concurrent Program FOR SINGLE Applications User BY USING
PROMPT EVENT 10046 WITH LEVEL 12 (WAITS plus BIND VARIABLES)
PROMPT
PROMPT IN Applications do NOT SET Trace through Help>Diagnostics>Trace.
PROMPT NEITHER should your Concurrent Program have Trace Enabled USING the Form
PROMPT Concurrent Program Define.  NOR a Profile turning Trace ON should be
PROMPT used.
PROMPT
PAUSE  Press ENTER TO continue…
PROMPT
PROMPT Choose applicable Responsibility, AND just before opening Form, press ENTER
PROMPT IN this SQL*Plus session.  FOR Concurrent Requests navigate TO the Form that
PROMPT submits your Concurrent Program, AND just before clicking the SUBMIT button,
PROMPT press ENTER IN this SQL*Plus session.
PROMPT
PROMPT Once you press ENTER IN this SQL*Plus session, applicable Applications
PROMPT Username AND SR (TAR) Number are TO be enteredand
PROMPT Profile ‘Initialization SQL Statement – Custom’ gets its value. ALL new
PROMPT sessions, Forms AND Concurrent Requests, will be affected.
PROMPT
PROMPT TO minimize the number of sessions being traced, turn OFF this
PROMPT EVENT 10046 AS soon AS possible (after reproduction IN Form OR start of
PROMPT Concurrent Request). You just need TO press ENTER again.
PROMPT

PROMPT
PROMPT Applications User FOR which tracing of new sessions IS TO be started
ACCEPT username PROMPT ‘Username        : ‘
ACCEPT tar      PROMPT ‘SR (TAR) Number : ‘
PROMPT

SET heading     off
SET feedback    0
SET echo        off
SET verify      off

SELECT TO_CHAR(sysdate,‘DD-MON-YY HH24:MI:SS’) "Start" FROM dual;
ALTER SYSTEM SET max_dump_file_size = unlimited;
ALTER SYSTEM SET timed_statistics = true;

DEFINE deftrace=‘begin fnd_ctl.fnd_sess_ctl(’‘,’‘,’‘TRUE’‘,’‘TRUE’‘,’‘, ‘‘ALTER SESSION SET EVENTS=’‘10046 TRACE NAME CONTEXT FOREVER, LEVEL 12′‘TRACEFILE_IDENTIFIER=’‘SR&tar’‘); end;’

INSERT INTO fnd_profile_option_values
(application_id,profile_option_id,level_id,level_value,
last_update_date,last_updated_by,creation_date,created_by,
last_update_login,profile_option_value,level_value_application_id)
SELECT 0,profile_option_id, 10004, user_id,
sysdate,0,sysdate,0,0,
‘&deftrace’, NULL
FROM   fnd_profile_options, fnd_user
WHERE  profile_option_name = ‘FND_INIT_SQL’
AND    user_name = upper(‘&username’);

COMMIT;

PROMPT
PROMPT Inserted Profile value
PROMPT
PROMPT Start reproduction of your issue…
PROMPT
PROMPT
PAUSE Afterwards press ENTER TO disable tracing FOR new sessions
PROMPT

DELETE fnd_profile_option_values
WHERE  application_id=0
AND    level_id=10004
AND    level_value =
(SELECT user_id
FROM    fnd_user
WHERE   user_name = upper(‘&&username’))
AND    profile_option_id =
(SELECT profile_option_id
FROM    fnd_profile_options
WHERE   profile_option_name = ‘FND_INIT_SQL’);

COMMIT;

DECLARE
v_sql        VARCHAR2(1000);
BEGIN
v_sql:=‘ALTER SYSTEM SET timed_statistics = ‘:v_ts;
EXECUTE IMMEDIATE v_sql;
v_sql:=‘ALTER SYSTEM SET max_dump_file_size = ‘:v_mdfs;
EXECUTE IMMEDIATE v_sql;
END;
/

PROMPT New sessions will NOT have EVENT 10046 turned ON.  Be aware that ALL
PROMPT sessions that started BETWEEN the time the EVENT 10046 was turned ON
PROMPT AND the time it was turned OFF, will continue TO be traced until
PROMPT they complete.
PROMPT

PROMPT
PROMPT CHECK FOR trace file:
SELECT ‘   ‘p1.value‘/ora_*_’‘SR&tar’‘.trc’
FROM   v$parameter p1
,      v$instance i
WHERE  p1.name = ‘user_dump_dest’;

PROMPT
PROMPT
PAUSE Press ENTER TO exit

SELECT TO_CHAR(sysdate,‘DD-MON-YY HH24:MI:SS’) "End" FROM dual;

PROMPT
PROMPT

EXIT

Following Google Searches Lead To This Post: BEGIN FND_CTL.FND_SESS_CTL(
insert into fnd_profile_option_values user level
initialize v$parameter
Initialization SQL Statement – Custom + Discoverer
27. How do you set profile options from PL/SQL procedure? oracle
CONC_REQUEST_ID PROFILE VALUE
initializing responsibility in PL/SQL Code + Oracle Apps
“Initialization SQL Statement – Custom”
“Initialization SQL Statement – Custom”+trace file location
fnd_global.initialize
Initialization SQL Statement – Custom profile option
APPLICATION_ID PROFILE_OPTION_ID LEVEL_ID LEVEL VALUE LAST_UPDATE_DATE LAST_UPDATED_BY CREATION_DATE CREATED_BY
fnd_ctl.fnd_sess_ctl with binds
sql statement fnd_global.initialize fnd_init_sql
update profile option through concurrent program
in the program how to check profile option is set or not
set profile option through concurrent program
update profile option in oracle apps through concurrent program
apps initialize in r12
fnd_user v session
Initialization sql statement
does fnd_global.initialize work with forms
apps.FND_PRODUCT_INITIALIZATION_PKG
profile option for trace oracle apps
how to find how change profile option value in Apps 11
Initialization SQL Statement – Custom in Oracle apps
BEGIN FND_CTL.FND_SESS_CTL level 4 trace
initialization sql statement custom
Initialization SQL Statement – Custom
cannot initialize concurrent request
how to initialize in sql
ORA “update * SET ”
Initialisation+sql+statement+oracle apps
PROFILE OPTION +INSERT VALUE+SITE
profile option changed in last 24 hours
How to enable trace with BIND variables and WAITs for a form in apps 11i
begin fnd_ctl.fnd_sess_ctl(”,”,’TRUE
“Initialization SQL Statement – Custom” and “security”
How do you set the profile option from a PL/SQL procedure
“While executing SQL in profile”
oracle how to tell what profile an SQL statement is using
concurrent request alter session
alter session set sql_trace = true options
How do you set the profile option in PL/SQL Procedure?
How do you get profile option value in PL/SQL
how to submit concurrent request through sql plus
profile option value level_id
cannot enable trace for concurrent program
oracle apps concurrent program lost initialize
could not execute alter in BEGIN END pl statement
concurrent request trace bind
oracle alter session profile option
FND_CTL.FND_SESS_CTL
how to enable profile options using sqlplus in Orcale Applications R12
sql initialize in oracle apps
begin fnd_ctl.fnd_sess_ctl
profile options call in pl/sql
initialize system profile program free
‘Initialization SQL Statement – Custom’
initialize sql
oracle applications user initialization
is commit required while running plsql program from oracle apps11i
SQL initialize
while executing SQL in profile FND_INIT_SQL:Yes
‘Initialization SQL Statement – Custom’
How to Trace the Concurrent program using Alter Command
sql intialize
How to set session trace without apps password
Initialization SQL Statement – Oracle
what are the instance specific profiles options in R12?
ORA-20001 While executing SQL in profile FND_INIT_SQL
fnd_init_sql
while executing sql in profile FND_INIT_SQL
FND_APPS_INIT_SQL
apps “change organization” sql
“Initialization SQL Statement – Custom”
optimizer_mode R12
oracle concurrent program trace profile option
profile option in where condition+oracle apps
“Press ENTER to continue…” while running an sql in oracle
hidden parameters Initialization SQL Statement – Custom
Initialization SQL Statement – Custom rule
how to change the profile option from sql prompt + oracle apps dba
how to find the profile option value form database
sql script to find the profile option value form database
Oracle Error – 20001: While executing SQL in profile FND_INIT_SQL
Oracle application custom sql trace
package apps fnd_global initialize
sqlplus use bind variable in shell script
Initialization SQL Statement – Custom’ system profile
custom log table details for oracle errors procedures
alter session responsibility
define custom profile option in oracle

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Oracle AOL Tags : , , , ,

Comments
April 29, 2009

Hi,

This is a very informative blog. I want to run some PL/SQL code at the time when user logs in and i was using FND_PRODUCT_INITIALIZATION_PKG.REGISTER package for that with which i can call same PL/SQL code again and again based on init condition which can be based on responsibility change, organization change, application change etc but could not get enough details regarding that. Then i found your blog which talks about running PL/SQL code at the time of user session initialization. I was wondering, can we use same procedure for rest of the init conditions as well which i mentioned earlier or would you be able to give me some details about FND_PRODUCT_INITIALIZATION_PKG.REGISTER package.

Thanks in advance.

Kind regards
Ankit

Posted by Ankit Kaushik
Leave a comment

(required)

(required)