根据不同的条件,拼接所需要的sql语句,然后调用
populate_group_with_query 动态替换记录组中的sql语句,
然后调用set_lov_property,将记录组绑定到特定的ITEM上
示例:
DECLARE
err_code NUMBER;
sql_str VARCHAR2(2000);
l_shipment_type_id NUMBER;
l_count NUMBER := 0;
BEGIN
l_shipment_type_id := :gss_folder.shipment_type_id;
SELECT COUNT(1)
INTO l_count
FROM gm_shipment_bill_actions t
WHERE t.shipment_type_id = l_shipment_type_id
AND t.bill_source = 'ERP';
IF l_count = 0 THEN
sql_str := 'SELECT DISTINCT t.customer_id,
t.account_number,
t.customer_name,
t.address1
FROM gm_ship_to_v t
WHERE t.org_id IN
(SELECT arm.organization_id
FROM cux_authority_rspb_mapping arm
WHERE arm.responsibility_id = fnd_global.RESP_ID
AND arm.organization_flag = ''Y'')
ORDER BY t.customer_id';
ELSE
sql_str := 'SELECT DISTINCT t.customer_id,
t.account_number,
t.customer_name,
t.address1
FROM gm_ship_to_v t
WHERE t.org_id IN (SELECT arm.organization_id
FROM cux_authority_rspb_mapping arm
WHERE arm.responsibility_id = fnd_global.resp_id
AND arm.organization_flag = ''Y'')
AND t.org_id IN
(SELECT sba.org_id
FROM gm_shipment_bill_actions sba
WHERE sba.shipment_type_id = ' || l_shipment_type_id ||
') ——引用block.item
ORDER BY t.customer_id';
END IF;
err_code := populate_group_with_query('CUSTOMER_NAME', sql_str); --用sql动态替换记录组
set_lov_property('CUSTOMER_NAME', group_name, 'CUSTOMER_NAME'); --替换记录组
END;