The following lines contain the word 'select', 'insert', 'update' or 'delete':
v_select_statement VARCHAR2(6000) ;
v_base_select_statement VARCHAR2(4000);
SELECT language_code INTO l_base_lang FROM fnd_languages
WHERE installed_flag = 'B';
v_select_statement1 :=
'select DISTINCT loc.language from oe_order_headers_all h, oe_order_lines_all l, hz_cust_accounts bill_cust, hz_cust_accounts ship_cust, hz_cust_accounts del_cust, hz_cust_site_uses bill_su, hz_parties bill_p, hz_parties ship_p, hz_parties del_p,';
v_select_statement2 := ' hz_cust_site_uses ship_su, hz_cust_site_uses del_su,hz_cust_acct_sites a, hz_cust_acct_sites bill_addr, hz_cust_acct_sites ship_addr, hz_cust_acct_sites del_addr, ra_salesreps sr, fnd_user u, hz_party_sites ps, hz_locations loc';
v_select_statement3 :=
' where h.header_id = l.header_id(+) and h.salesrep_id = sr.salesrep_id (+) and u.user_id = h.created_by';*/
v_select_statement4 :=
' and h.ship_to_org_id = ship_su.site_use_id(+) and ship_su.cust_acct_site_id = ship_addr.cust_acct_site_id(+) and ship_addr.cust_account_id = ship_cust.cust_account_id(+) ';
v_select_statement5 :=
'and h.invoice_to_org_id = bill_su.site_use_id(+) and bill_su.cust_acct_site_id = bill_addr.cust_acct_site_id(+) and bill_addr.cust_account_id = bill_cust.cust_account_id(+) and h.deliver_to_org_id = del_su.site_use_id(+) and ';
v_select_statement6 := ' del_su.cust_acct_site_id = del_addr.cust_acct_site_id(+) and del_addr.cust_account_id = del_cust.cust_account_id(+) and (h.invoice_to_org_id is not null or h.ship_to_org_id is not null) and a.cust_account_id = h.sold_to_org_id';
v_select_statement6 := v_select_statement6 || ' and bill_cust.party_id = bill_p.party_id(+) and ship_cust.party_id = ship_p.party_id(+) and del_cust.party_id = del_p.party_id(+)';
v_select_statement6 := v_select_statement6||' and a.party_site_id = ps.party_site_id and ps.location_id = loc.location_id';
v_select_statement := v_select_statement1 || v_select_statement2 || v_select_statement3 || v_select_statement4 || v_select_statement5 || v_select_statement6;
v_base_select_statement := 'select DISTINCT loc.language from oe_order_headers_all h, oe_order_lines_all l, hz_locations loc, '||
' ra_salesreps sr,fnd_user u , hz_party_sites ps , hz_cust_acct_sites a';
v_select_statement := v_select_statement||' AND h.order_number <= :p_order_number_hi';
v_select_statement := v_select_statement||' AND h.order_number >= :p_order_number_lo';
v_select_statement := v_select_statement||' AND h.order_number BETWEEN :p_order_number_lo AND :p_order_number_hi';
v_select_statement := v_select_statement||' AND h.ordered_date <= :p_order_date_hi';
v_select_statement := v_select_statement||' AND h.ordered_date >= :p_order_date_lo';
v_select_statement := v_select_statement||' AND h.ordered_date BETWEEN :p_order_date_lo AND :p_order_date_hi';
v_select_statement := v_select_statement||' AND l.schedule_ship_date <= :p_schedule_date_hi';
v_select_statement := v_select_statement||' AND l.schedule_ship_date >= :p_schedule_date_lo';
v_select_statement := v_select_statement||' AND l.schedule_ship_date BETWEEN :p_schedule_date_lo AND :p_schedule_date_hi';
v_select_statement := v_select_statement||' AND l.promise_date <= :p_promise_date_hi';
v_select_statement := v_select_statement||' AND l.promise_date >= :p_promise_date_lo';
v_select_statement := v_select_statement||' AND l.promise_date BETWEEN :p_promise_date_lo AND :p_promise_date_hi';
v_select_statement := v_select_statement||' AND l.request_date <= :p_request_date_hi';
v_select_statement := v_select_statement||' AND l.request_date >= :p_request_date_lo';
v_select_statement := v_select_statement||' AND l.request_date BETWEEN :p_request_date_lo AND :p_request_date_hi';
v_base_select_statement := v_base_select_statement || ' , hz_cust_accounts bill_cust , hz_cust_site_uses bill_su , hz_parties bill_p, hz_cust_acct_sites bill_addr ';
v_select_statement := v_select_statement||' AND bill_p.party_name <= :p_bill_to_customer_name_hi';
v_select_statement := v_select_statement||' AND bill_p.party_name >= :p_bill_to_customer_name_lo';
v_select_statement := v_select_statement||' AND bill_p.party_name BETWEEN :p_bill_to_customer_name_lo AND :p_bill_to_customer_name_hi';
v_base_select_statement := v_base_select_statement || ' , hz_cust_accounts ship_cust, hz_cust_site_uses ship_su, hz_parties ship_p, hz_cust_acct_sites ship_addr ';
v_select_statement := v_select_statement||' AND ship_p.party_name <= :p_ship_to_customer_name_hi';
v_select_statement := v_select_statement||' AND ship_p.party_name >= :p_ship_to_customer_name_lo';
v_select_statement := v_select_statement||' AND ship_p.party_name BETWEEN :p_ship_to_customer_name_lo AND :p_ship_to_customer_name_hi';
v_base_select_statement := v_base_select_statement || ' , hz_cust_accounts del_cust, hz_cust_site_uses del_su, hz_parties del_p, hz_cust_acct_sites del_addr ';
v_select_statement := v_select_statement||' AND del_p.party_name <= :p_del_to_customer_name_hi';
v_select_statement := v_select_statement||' AND del_p.party_name >= :p_del_to_customer_name_lo';
v_select_statement := v_select_statement||' AND del_p.party_name BETWEEN :p_del_to_customer_name_lo AND :p_del_to_customer_name_hi';
v_select_statement := v_select_statement||' AND h.order_type_id = :p_order_type';
v_select_statement := v_select_statement || ' AND h.booked_flag = ''Y'''; ELSE
v_select_statement := v_select_statement || ' AND h.booked_flag = ''N''';
v_select_statement := v_select_statement || ' AND h.open_flag = ''Y''';
-- v_select_statement := v_select_statement || ' AND h.open_flag = ''N''';
v_select_statement := v_select_statement||' AND sr.name = :p_salesrep';
v_select_statement := v_select_statement||' AND u.user_name = :p_created_by';
v_where_clause1 := v_select_statement;
v_select_statement := v_base_select_statement ||v_base_where_clause ||v_where_clause1;
DBMS_SQL.PARSE(l_cursor_id, v_select_statement, DBMS_SQL.V7);