The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT fnd_profile.value('BIX_DM_CURR_CONVERSION_TYPE')
INTO l_conv_type
FROM dual;
SELECT fnd_profile.value('BIX_DM_RPT_TIME_RANGE')
INTO l_time_range
FROM dual;
/* Form the SQL string to insert the rows into the temp table.
For null classifications, 'z99' was chosen as the default classifcation
id so that it always appears as the last row in the report */
g_sqlstmt := 'INSERT /*+ PARALLEL(tr,2) */ INTO BIX_DM_REPORT tr
( session_id, report_code, col1, col2, col3, col4, col6, col8,
col10, col12, col14, col16, col18, col20, col22, col24,
col26, col28, col30 )
(SELECT /*+ PARALLEL(a,2) */ :session_id, ''BIX_KPI_CLS_RPT'' ,
nvl(to_char(a.classification_id), ''z99'') || ''y'' ';
/* If total row then insert classification description */
/* if not then insert the time range */
IF (p_total_row_ind = FALSE)
THEN
g_sqlstmt := g_sqlstmt || ', null ';
, SUM(a.leads_updated)
, to_char(SUM(DECODE(:user_currency, a.currency_code, a.leads_amount_txn,
((a.leads_amount / :denom_rate) * :num_rate ))), :format_mask)
, SUM(a.opportunities_created)
, SUM(a.opportunities_updated)
, SUM(a.opportunities_won)
, to_char(SUM(DECODE(:user_currency, a.currency_code,
a.opportunities_won_amount_txn,
((a.opportunities_won_amount / :denom_rate) * :num_rate ))), :format_mask) ';
/* This procedure inserts data into the temp table.
*/
PROCEDURE insert_temp_table(p_total_row_ind IN BOOLEAN,
p_session_id IN NUMBER,
p_classification_id IN NUMBER,
p_site_id IN NUMBER,
p_start_date IN DATE,
p_end_date In DATE,
p_user_currency IN VARCHAR2,
p_denom_rate IN NUMBER,
p_num_rate In NUMBER )
IS
l_format_mask VARCHAR2(50);
/* Form and execute the SQL statement to insert into the temp table */
/* all the rows coreesponding to the classifications user has chosen */
form_sqlstmt(p_total_row_ind, p_classification_id, p_site_id);
END insert_temp_table;
SELECT sysdate
INTO l_sysdate
FROM dual;
SELECT MAX(period_start_date)
INTO v_temp_date
FROM bix_dm_agent_call_sum;
/* Delete the table for the current icx session and report */
DELETE from bix_dm_report
WHERE report_code = 'BIX_KPI_CLS_RPT'
AND session_id = l_session_id;
SELECT fnd_profile.value('BIX_DM_PREFERRED_CURRENCY')
INTO l_global_currency
FROM dual;
SELECT fnd_profile.value('JTF_PROFILE_DEFAULT_CURRENCY')
INTO l_user_currency
FROM dual;
/* Insert the total rows corresponding to the classification */
insert_temp_table(l_total_row_ind, l_session_id, l_classification_id,
l_site_id, l_start_date, l_end_date, l_user_currency,
l_denom_rate, l_num_rate );
UPDATE bix_dm_report
SET col1 = 'z99n'
WHERE col1 = 'z99y'
AND report_code = 'BIX_KPI_CLS_RPT'
AND session_id = l_session_id;
UPDATE bix_dm_report
SET col1 = to_char(l_classification_id) || 'n'
WHERE col1 = to_char(l_classification_id) || 'y'
AND report_code = 'BIX_KPI_CLS_RPT'
AND session_id = l_session_id;
/* summary table and insert them into bix temp table */
l_total_row_ind := FALSE;
insert_temp_table( l_total_row_ind, l_session_id,
l_classification_id, l_site_id, l_start_date, l_end_date,
l_user_currency,l_denom_rate, l_num_rate );