The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT start_date, period_name
INTO start_period_date,l_period_name
FROM gl_period_statuses gps
WHERE gps.application_id = 101
AND gps.ledger_id = x_ledger_id
AND x_start_date between gps.START_DATE and gps.END_DATE
AND gps.adjustment_period_flag <> 'Y';
SELECT p1.start_date, p1.period_name
INTO start_period_date, l_period_name
FROM gl_period_statuses p1
WHERE p1.application_id = 101
AND p1.ledger_id = x_ledger_id
AND p1.adjustment_period_flag <> 'Y'
AND p1.start_date =
(SELECT MIN(p2.start_date)
FROM gl_period_statuses p2
WHERE p2.application_id = 101
AND p2.ledger_id = x_ledger_id
AND p2.adjustment_period_flag <> 'Y');
l_Sql_Stmt := ' SELECT
(SUM(nvl(accounted_dr, 0)) - SUM(nvl(accounted_cr, 0)))
FROM
GL_JE_HEADERS HED,
GL_JE_LINES LINE,
GL_CODE_COMBINATIONS CC
WHERE '''||l_STATUS||''' = ''P'''||
P_ACCT_SEG_WHERE||
' AND CC.code_combination_id = line.code_combination_id
AND HED.je_header_id = line.je_header_id
AND trunc(line.effective_date) >= :START_PRD_DATE
AND trunc(line.effective_date) < :START_DATE
AND hed.period_name = :period_name '||
' AND hed.actual_flag = ''A'''||
l_sql_stmt1||
' AND hed.ledger_id = :LED_ID
AND '||p_bal_seg_name|| ' = :bal_Seg_Val
AND '|| p_acct_seg_name||' = :acct_seg_val '||l_stmt2||
' AND LINE.STATUS = ''P''';
l_stmt := 'SELECT
(SUM(decode(cc.summary_flag, ''N'', nvl(gb.begin_balance_dr, 0), 0)) -
SUM(decode(cc.summary_flag, ''N'', nvl(gb.begin_balance_cr, 0),0)))
FROM GL_CODE_COMBINATIONS CC,
GL_BALANCES GB
WHERE '''||l_status ||''' = ''P''
AND CC.code_combination_id = GB.code_combination_id '
||P_ACCT_SEG_WHERE ||
' AND GB.currency_code = '''||P_CURRENCY||'''
AND GB.ledger_id = :LGR_ID '
||l_stmt1||
' AND GB.actual_flag = ''A''
AND GB.period_name = '''||l_prd_start_name||'''
AND '||P_BAL_SEG_NAME ||' = '''||P_Bal_Seg_Val||'''
AND '||P_ACCT_SEG_NAME || ' = '''||P_ACCT_SEG_VAL||'''';
FUNCTION Get_Contra_Account(P_Account_Select VARCHAR2,
p_Header_id NUMBER,
P_Sub_Doc_Seq_Id NUMBER,
P_Sub_Doc_SEq_Val VARCHAR2,
p_Accounted_Dr NUMBER,
P_Accounted_Cr NUMBER) RETURN VARCHAR2 IS
contra_account_name varchar2(240);
CONTRA_ACCT_SEGMENT := 'G'||P_Account_select;
v_sql_stmt := 'select distinct '||
contra_acct_segment ||
' from gl_je_lines gjl, gl_code_combinations gcc ' ||
'where gjl.je_header_id = :header_id and '||
'gjl.accounted_cr IS NOT NULL and gjl.accounted_cr <> 0 and ' ||
'gjl.code_combination_id = gcc.code_combination_id and '||
'((gjl.subledger_doc_sequence_id = :sub_doc_sequence_id and '||
'gjl.subledger_doc_sequence_value = :sub_doc_sequence_value) or '||
'(:sub_doc_sequence_id is null and gjl.subledger_doc_sequence_id is null and '||
'gjl.subledger_doc_sequence_value is null))';
v_sql_stmt := 'select distinct ' ||
contra_acct_segment ||
' from gl_je_lines gjl, gl_code_combinations gcc '||
'where gjl.je_header_id = :header_id and '||
'gjl.accounted_dr IS NOT NULL and gjl.accounted_dr <> 0 and ' ||
'gjl.code_combination_id = gcc.code_combination_id and '||
'((gjl.subledger_doc_sequence_id = :sub_doc_sequence_id and '||
'gjl.subledger_doc_sequence_value = :sub_doc_sequence_value) or '||
'(:sub_doc_sequence_id is null and gjl.subledger_doc_sequence_id is null and '||
'gjl.subledger_doc_sequence_value is null))';