Spliting One row into Multi rows
Spliting One row into Multi rows
select * from (
with t as (select 'A-INSTALL,6-FOLLOWUP' str from dual)
SELECT trim(REGEXP_SUBSTR (str,'[^,]+' ,1,level))
FROM t
connect by instr(str, ',', 1, level - 1) > 0
and connect_by_root str = str)
select * from (
with t as (select 'A-INSTALL,6-FOLLOWUP' str from dual)
SELECT trim(REGEXP_SUBSTR (str,'[^,]+' ,1,level))
FROM t
connect by instr(str, ',', 1, level - 1) > 0
and connect_by_root str = str)
==========================================================
Set Profile Option Value using PL/SQL
On request here is how to set the profile option value using PL/SQL
Function FND_PROFILE.SAVE can be used to set the value of any profile option at any level i.e. Site, Application, Responsibility, User etc.
Below is a sample code of how to use this function
DECLARE
a BOOLEAN;
BEGIN
a := fnd_profile.SAVE ('CONC_REPORT_ACCESS_LEVEL'
, 'R'
, 'USER'
, '22746'
, NULL
, NULL
);
IF a
THEN
DBMS_OUTPUT.put_line ('Success');
COMMIT;
ELSE
DBMS_OUTPUT.put_line ('Error');
END IF;
END;
=============================================================Function FND_PROFILE.SAVE can be used to set the value of any profile option at any level i.e. Site, Application, Responsibility, User etc.
Below is a sample code of how to use this function
DECLARE
a BOOLEAN;
BEGIN
a := fnd_profile.SAVE ('CONC_REPORT_ACCESS_LEVEL'
, 'R'
, 'USER'
, '22746'
, NULL
, NULL
);
IF a
THEN
DBMS_OUTPUT.put_line ('Success');
COMMIT;
ELSE
DBMS_OUTPUT.put_line ('Error');
END IF;
END;
Sales order headers and lines information queries
Query to retrive the header information of the Sales Order Form is:
SELECT ooha.header_id, ooha.order_number, ott.NAME "ORDER TYPE",
hp.party_name "CUSTOMER", hca.account_number "CUSTOMER NUMBER",
ooha.ordered_date "DATE ORDERED", qh.NAME "PRICE LIST",
ooha.transactional_curr_code "CURRENCY",
ooha.cust_po_number "CUSTOMER PO",
ooha.freight_carrier_code "SHIPPING METHOD",
ooha.flow_status_code "STATUS", rtt.NAME "PAYMENT TERMS",
mp.organization_code "WARE HOUSE", ol.meaning "FREIGHT TERMS",
ol1.meaning "SHIPMENT PRIORITY", al.meaning "FOB",
rsa.NAME "SALESPERSON",
hcsua.LOCATION
','
hl.address2
','
hl.city
','
hl.state
','
hl.postal_code
','
hl.county "BILL TO LOCATION",
hcsua1.LOCATION
','
hl1.address2
','
hl1.city
','
hl1.state
','
hl1.postal_code
','
hl1.county "SHIP TO LOCATION"
FROM oe_order_headers_all ooha,
oe_transaction_types_tl ott,
qp_list_headers qh,
ra_terms_tl rtt,
mtl_parameters mp,
ra_salesreps_all rsa,
hz_cust_accounts hca,
hz_parties hp,
hz_parties hp1,
hz_locations hl,
hz_locations hl1,
hz_cust_acct_sites_all hcasa,
hz_cust_acct_sites_all hcasa1,
hz_cust_site_uses_all hcsua,
hz_cust_site_uses_all hcsua1,
hz_party_sites hps,
hz_party_sites hps1,
oe_lookups ol,
oe_lookups ol1,
ar_lookups al
WHERE 1 = 1
AND ooha.order_number = 10265
AND ooha.sold_to_org_id = hca.cust_account_id
AND ooha.order_type_id = ott.transaction_type_id
AND ott.LANGUAGE = USERENV ('LANG')
AND rtt.LANGUAGE = USERENV ('LANG')
AND rtt.term_id = ooha.payment_term_id
AND qh.list_header_id = ooha.price_list_id
AND mp.organization_id = ooha.ship_from_org_id
AND ooha.salesrep_id = rsa.salesrep_id
AND hca.party_id = hp.party_id
AND hca.party_id = hp1.party_id
AND ooha.invoice_to_org_id = hcsua.site_use_id(+)
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id(+)
AND hcasa.party_site_id = hps.party_site_id(+)
AND hl.location_id(+) = hps.location_id
AND ooha.ship_to_org_id = hcsua1.site_use_id(+)
AND hcsua1.cust_acct_site_id = hcasa1.cust_acct_site_id(+)
AND hcasa1.party_site_id = hps1.party_site_id(+)
AND hl1.location_id(+) = hps1.location_id
AND ooha.freight_terms_code = ol.lookup_code
AND ooha.shipment_priority_code = ol1.lookup_code
AND al.lookup_code = ooha.fob_point_code;
Query to retrieve the line information of the Sales Order Form is:
SELECT oola.line_number "LINE NUMBER", oola.ordered_item "ORDERED ITEM",
oola.ordered_quantity "QTY", oola.order_quantity_uom "UOM",
oola.unit_selling_price "UNIT SELLING PRICE",
oola.cancelled_quantity "QTY CANCELLED",
oola.shipped_quantity "QTY SHIPPED", oola.tax_code "TAX CODE",
ott.NAME "LINE TYPE",
DECODE (opa.line_id,
NULL, DECODE (opa.credit_or_charge_flag,
'C', (-1) * opa.operand,
opa.operand
),
DECODE (opa.credit_or_charge_flag,
'C', DECODE (opa.arithmetic_operator,
'LUMPSUM', (-1) * (opa.operand),
(-1)
* ( oola.ordered_quantity
* opa.adjusted_amount
)
),
DECODE (opa.arithmetic_operator,
'LUMPSUM', opa.operand,
(oola.ordered_quantity * opa.adjusted_amount
)
)
)
) "LINE_CHARGES",
ol.meaning "CALCULATE PRICE FLAG", oola.pricing_quantity,
oola.unit_selling_price, oola.unit_list_price, oola.tax_value,
(oola.shipped_quantity) * (oola.unit_selling_price) "LINE TOTAL"
((oola.shipped_quantity) * (oola.unit_selling_price)
)
+ (DECODE (opa.line_id,
NULL, DECODE (opa.credit_or_charge_flag,
'C', (-1) * opa.operand,
opa.operand
),
DECODE (opa.credit_or_charge_flag,
'C', DECODE (opa.arithmetic_operator,
'LUMPSUM', (-1) * (opa.operand),
(-1)
* ( oola.ordered_quantity
* opa.adjusted_amount
)
),
DECODE (opa.arithmetic_operator,
'LUMPSUM', opa.operand,
(oola.ordered_quantity * opa.adjusted_amount
)
)
)
)
) "ORDER TOTAL"
FROM oe_order_lines_all oola,
oe_transaction_types_tl ott,
oe_price_adjustments opa,
oe_order_headers_all ooha,
oe_lookups ol
WHERE 1 = 1
AND oola.line_type_id = ott.transaction_type_id
AND opa.header_id = ooha.header_id
AND opa.line_id = oola.line_id(+)
AND opa.list_line_type_code = 'FREIGHT_CHARGE'
AND opa.applied_flag = 'Y'
AND ott.LANGUAGE = USERENV ('LANG')
AND oola.header_id = 1547
AND ol.lookup_type = 'CALCULATE_PRICE_FLAG'
AND oola.calculate_price_flag = ol.lookup_code;
SELECT ooha.header_id, ooha.order_number, ott.NAME "ORDER TYPE",
hp.party_name "CUSTOMER", hca.account_number "CUSTOMER NUMBER",
ooha.ordered_date "DATE ORDERED", qh.NAME "PRICE LIST",
ooha.transactional_curr_code "CURRENCY",
ooha.cust_po_number "CUSTOMER PO",
ooha.freight_carrier_code "SHIPPING METHOD",
ooha.flow_status_code "STATUS", rtt.NAME "PAYMENT TERMS",
mp.organization_code "WARE HOUSE", ol.meaning "FREIGHT TERMS",
ol1.meaning "SHIPMENT PRIORITY", al.meaning "FOB",
rsa.NAME "SALESPERSON",
hcsua.LOCATION
','
hl.address2
','
hl.city
','
hl.state
','
hl.postal_code
','
hl.county "BILL TO LOCATION",
hcsua1.LOCATION
','
hl1.address2
','
hl1.city
','
hl1.state
','
hl1.postal_code
','
hl1.county "SHIP TO LOCATION"
FROM oe_order_headers_all ooha,
oe_transaction_types_tl ott,
qp_list_headers qh,
ra_terms_tl rtt,
mtl_parameters mp,
ra_salesreps_all rsa,
hz_cust_accounts hca,
hz_parties hp,
hz_parties hp1,
hz_locations hl,
hz_locations hl1,
hz_cust_acct_sites_all hcasa,
hz_cust_acct_sites_all hcasa1,
hz_cust_site_uses_all hcsua,
hz_cust_site_uses_all hcsua1,
hz_party_sites hps,
hz_party_sites hps1,
oe_lookups ol,
oe_lookups ol1,
ar_lookups al
WHERE 1 = 1
AND ooha.order_number = 10265
AND ooha.sold_to_org_id = hca.cust_account_id
AND ooha.order_type_id = ott.transaction_type_id
AND ott.LANGUAGE = USERENV ('LANG')
AND rtt.LANGUAGE = USERENV ('LANG')
AND rtt.term_id = ooha.payment_term_id
AND qh.list_header_id = ooha.price_list_id
AND mp.organization_id = ooha.ship_from_org_id
AND ooha.salesrep_id = rsa.salesrep_id
AND hca.party_id = hp.party_id
AND hca.party_id = hp1.party_id
AND ooha.invoice_to_org_id = hcsua.site_use_id(+)
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id(+)
AND hcasa.party_site_id = hps.party_site_id(+)
AND hl.location_id(+) = hps.location_id
AND ooha.ship_to_org_id = hcsua1.site_use_id(+)
AND hcsua1.cust_acct_site_id = hcasa1.cust_acct_site_id(+)
AND hcasa1.party_site_id = hps1.party_site_id(+)
AND hl1.location_id(+) = hps1.location_id
AND ooha.freight_terms_code = ol.lookup_code
AND ooha.shipment_priority_code = ol1.lookup_code
AND al.lookup_code = ooha.fob_point_code;
Query to retrieve the line information of the Sales Order Form is:
SELECT oola.line_number "LINE NUMBER", oola.ordered_item "ORDERED ITEM",
oola.ordered_quantity "QTY", oola.order_quantity_uom "UOM",
oola.unit_selling_price "UNIT SELLING PRICE",
oola.cancelled_quantity "QTY CANCELLED",
oola.shipped_quantity "QTY SHIPPED", oola.tax_code "TAX CODE",
ott.NAME "LINE TYPE",
DECODE (opa.line_id,
NULL, DECODE (opa.credit_or_charge_flag,
'C', (-1) * opa.operand,
opa.operand
),
DECODE (opa.credit_or_charge_flag,
'C', DECODE (opa.arithmetic_operator,
'LUMPSUM', (-1) * (opa.operand),
(-1)
* ( oola.ordered_quantity
* opa.adjusted_amount
)
),
DECODE (opa.arithmetic_operator,
'LUMPSUM', opa.operand,
(oola.ordered_quantity * opa.adjusted_amount
)
)
)
) "LINE_CHARGES",
ol.meaning "CALCULATE PRICE FLAG", oola.pricing_quantity,
oola.unit_selling_price, oola.unit_list_price, oola.tax_value,
(oola.shipped_quantity) * (oola.unit_selling_price) "LINE TOTAL"
((oola.shipped_quantity) * (oola.unit_selling_price)
)
+ (DECODE (opa.line_id,
NULL, DECODE (opa.credit_or_charge_flag,
'C', (-1) * opa.operand,
opa.operand
),
DECODE (opa.credit_or_charge_flag,
'C', DECODE (opa.arithmetic_operator,
'LUMPSUM', (-1) * (opa.operand),
(-1)
* ( oola.ordered_quantity
* opa.adjusted_amount
)
),
DECODE (opa.arithmetic_operator,
'LUMPSUM', opa.operand,
(oola.ordered_quantity * opa.adjusted_amount
)
)
)
)
) "ORDER TOTAL"
FROM oe_order_lines_all oola,
oe_transaction_types_tl ott,
oe_price_adjustments opa,
oe_order_headers_all ooha,
oe_lookups ol
WHERE 1 = 1
AND oola.line_type_id = ott.transaction_type_id
AND opa.header_id = ooha.header_id
AND opa.line_id = oola.line_id(+)
AND opa.list_line_type_code = 'FREIGHT_CHARGE'
AND opa.applied_flag = 'Y'
AND ott.LANGUAGE = USERENV ('LANG')
AND oola.header_id = 1547
AND ol.lookup_type = 'CALCULATE_PRICE_FLAG'
AND oola.calculate_price_flag = ol.lookup_code;
=====================================
SUPPLIER QUERY
SELECT aps.segment1 SUPPLIER_NUMBER, aps.vendor_name SUPPLIER_NAME, apss.city,apsc.first_name||' '||apsc.last_name AS "ContactName", apsc.PHONE, apsc.FAX_AREA_CODE||'-'||apsc.FAX as "FAX NUMBER", APSC.EMAIL_ADDRESS EMAIL_ID FROM ap_suppliers aps, ap_supplier_sites_all apss, ap_supplier_contacts apsc WHERE 1 = 1 AND aps.vendor_id = apss.vendor_id AND apss.vendor_site_id = apsc.vendor_site_id ********************************************************* select pov.vendor_id, pov.vendor_name supplier, pov.vendor_type_lookup_code, sl.location_code shipto_location, bl.location_code billto_location, pov.customer_num, pov.ship_via_lookup_code, pov.fob_lookup_code, rt.name terms, pov.set_of_books_id, pov.credit_status_lookup_code, pov.credit_limit from ra_terms rt, hr_locations bl, hr_locations sl, po_vendors pov where pov.vendor_name like ‘Abb%’ and pov.ship_to_location_id=sl.location_id(+) and pov.bill_to_location_id=bl.location_id(+) and pov.terms_id=rt.term_id(+) order by 1 / select pov.vendor_name Supplier, povs.vendor_site_id, povs.vendor_site_code Site, povs.address_line1 A1ddress, povs.address_line2 A2ddress, povs.address_line3 A3ddress, povs.city||’, ‘|| povs.state||’ ‘|| povs.zip A4ddress, povs.ship_to_location_id, povs.bill_to_location_id, povs.ship_via_lookup_code, povs.freight_terms_lookup_code, povs.fob_lookup_code from po_vendors pov, po_vendor_sites povs where pov.vendor_id=601 and pov.vendor_id=povs.vendor_id order by 1 / Query to find Supplier contacts : select vc.vendor_contact_id, vc.vendor_site_id, vc.first_name, vc.middle_name, vc.last_name, vc.prefix, vc.title, vc.mail_stop, vc.area_code, vc.phone, vc.department, vc.email_address, vc.url, vc.alt_area_code, vc.alt_phone, vc.fax_area_code, vc.inactive_date, vc.fax from po_vendor_contacts vc where vc.vendor_site_id=4556 order by 1
===========================================================
SQL Query to get Oracle HR Organization Hierarchy
SELECT
LPAD(' ',10*(LEVEL-1)) || org.name hierarchy,
org.organization_id
FROM
hr_all_organization_units org,
per_org_structure_elements pose
WHERE 1=1
AND porg.organization_id = pose.organization_id_child
AND pose.org_structure_version_id = 61
--and org.name like '201.Financiale Services'
START WITH
pose.organization_id_parent = 115 -- Orgnization of parent id -- provide the id from which level the downward hierarchy should be displaed
CONNECT BY PRIOR
pose.organization_id_child = pose.organization_id_parent
ORDER SIBLINGS BY
org.location_id,
pose.organization_id_child
LPAD(' ',10*(LEVEL-1)) || org.name hierarchy,
org.organization_id
FROM
hr_all_organization_units org,
per_org_structure_elements pose
WHERE 1=1
AND porg.organization_id = pose.organization_id_child
AND pose.org_structure_version_id = 61
--and org.name like '201.Financiale Services'
START WITH
pose.organization_id_parent = 115 -- Orgnization of parent id -- provide the id from which level the downward hierarchy should be displaed
CONNECT BY PRIOR
pose.organization_id_child = pose.organization_id_parent
ORDER SIBLINGS BY
org.location_id,
pose.organization_id_child
=================================================
No comments:
Post a Comment