The following lines contain the word 'select', 'insert', 'update' or 'delete':
IF upper(p_Line_adj_rec.updated_flag) ='Y' and
p_Line_adj_rec.change_reason_code is null THEN
l_return_status := FND_API.G_RET_STS_ERROR;
SELECT soagr.agreement_type_code
INTO l_agr_type_code
FROM oe_agreements soagr,
oe_order_lines oeordl
WHERE soarg.agreement_id = oeordl.agreement_id
AND oeordl.line_id = p_line_adj_rec.line_id;
SELECT 'IMP_DISCOUNT'
INTO l_price_adj_error
FROM DUAL
WHERE NOT EXISTS
(SELECT NULL
FROM oe_discounts sodsc,
oe_discount_lines sodls,
oe_price_break_lines sopbl,
oe_order_lines oeordl,
o_order_header oeordh
WHERE NVL(decode(sign(p_line_adj_rec.discount_line_id), -1, null,
p_line_adj_rec.discount_line_id), -99)=
NVL(sodls.discount_line_id(+),-99)
AND p_line_adj_rec.discount_id = sodsc.discount_id
AND ((p_percent =
nvl(sodsc.amount / oeordl.unit_list_price * 100,
nvl(sodsc.percent,
nvl((oeordl.unit_list_price - sodls.price ) /
oeordl.unit_list_price * 100,
nvl(sodls.amount / oeordl.unit_list_price * 100,
nvl(sodls.percent,
nvl((oeordl.unit_list_price - sopbl.price ) /
oeordl.unit_list_price * 100,
nvl(sopbl.amount / oeordl.unit_list_price
* 100,
nvl( sopbl.percent, 0 )))))))))
OR
(sodsc.override_allowed_flag = 'Y'))
AND oeordl.line_id = p_line_adj_rec.line_id
AND oeordl.header_id = oeordh.header_id
AND sodsc.price_list_id = oeordl.price_list_id
AND sodsc.discount_type_code = 'LINE_ITEM'
AND sodls.discount_id(+) = sodsc.discount_id
AND NVL(sodls.entity_value, 'X' ) =
DECODE(sodls.entity_id,
1007, TO_CHAR(oeordh.order_type_id),
1001, TO_CHAR(oeordl.inventory_item_id),
1005, l_agr_type_code,
1006, TO_CHAR(oeordl.agreement_id),
1010, oeordl.pricing_attribute1,
1011, oeordl.pricing_attribute2,
1012, oeordl.pricing_attribute3,
1013, oeordl.pricing_attribute4,
1014, oeordl.pricing_attribute5,
1015, oeordl.pricing_attribute6,
1016, oeordl.pricing_attribute7,
1017, oeordl.pricing_attribute8,
1018, oeordl.pricing_attribute9,
1019, oeordl.pricing_attribute10,
1020, oeordl.pricing_attribute11,
1021, oeordl.pricing_attribute12,
1022, oeordl.pricing_attribute13,
1023, oeordl.pricing_attribute14,
1024, oeordl.pricing_attribute15,
1045, sodls.entity_value,
'X' )
AND decode (sodls.ENTITY_ID,
1045, oe_adj_privilege.check_item_category
(oeordl.inventory_item_id,
SODLS.ENTITY_VALUE,
l_organization_id)
,'Y') = 'Y'
AND sopbl.discount_line_id(+) = sodls.discount_line_id
AND DECODE( sopbl.method_type_code,
'UNITS', oeordl.quantity_ordered,
'DOLLARS', oeordl.quantity_ordered *
oeordl.unit_list_price, 0 )
BETWEEN NVL( sopbl.price_break_lines_low_range,
DECODE( sopbl.method_type_code,
'UNITS', oeordl.quantity_ordered,
'DOLLARS', oeordl.quantity_ordered *
oeordl.unit_list_price, 0 ))
AND NVL( sopbl.price_break_lines_high_range,
DECODE( sopbl.method_type_code,
'UNITS', oeordl.quantity_ordered,
'DOLLARS', oeordl.quantity_ordered *
oeordl.unit_list_price, 0 ))
AND (NOT EXISTS
(SELECT NULL
FROM oe_discount_customers sodcs
WHERE sodcs.discount_id = sodsc.discount_id )
OR
(EXISTS
(SELECT NULL
FROM oe_discount_customers sodcs
WHERE sodcs.discount_id = sodsc.discount_id
AND (sodcs.sold_to_org_id = oeordh.sold_to_org_id
OR
(sodcs.sold_to_org_id IS NULL
AND
sodcs.customer_class_code IS NULL))
AND (Nvl(sodcs.site_use_id, oeordh.ship_to_org_id)=
oeordh.ship_to_org_id
OR
NVL(sodcs.site_use_id, oeordh.invoice_to_org_id)=
oeordh.invoice_to_org_id )
)
OR
EXISTS (SELECT NULL
FROM oe_discount_customers oecst,
HZ_CUST_ACCOUNTS CUST_ACCT
-- Replaced ra_customers with hz_cust_accounts to fix the bug 1888440
WHERE oecst.discount_id = sodsc.discount_id
AND CUST_ACCT.CUST_ACCOUNT_ID = oeordh.sold_to_org_id
AND CUST_ACCT.CUSTOMER_CLASS_CODE =
oecst.customer_class_code
AND oecst.sold_to_org_id IS NULL
AND oecst.site_use_id IS NULL
)
)
);
SELECT 'VALID'
INTO l_tmp_string
FROM QP_LOOKUPS
WHERE LOOKUP_TYPE = p_Line_Adj_rec.charge_type_code
AND LOOKUP_CODE = p_Line_Adj_rec.charge_subtype_code
--AND ENABLED_FLAG = 'Y'
AND ROWNUM =1;
IF p_Line_Adj_rec.last_update_date IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.Last_Update_Date(p_Line_Adj_rec.last_update_date) THEN
x_return_status := FND_API.G_RET_STS_ERROR;
IF p_Line_Adj_rec.last_updated_by IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.Last_Updated_By(p_Line_Adj_rec.last_updated_by) THEN
x_return_status := FND_API.G_RET_STS_ERROR;
IF p_Line_Adj_rec.last_update_login IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.Last_Update_Login(p_Line_Adj_rec.last_update_login) THEN
x_return_status := FND_API.G_RET_STS_ERROR;
IF p_Line_Adj_rec.program_update_date IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.Program_Update_Date(p_Line_Adj_rec.program_update_date) THEN
x_return_status := FND_API.G_RET_STS_ERROR;
IF p_Line_Adj_rec.updated_flag IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.updated_flag(p_Line_Adj_rec.updated_flag) THEN
x_return_status := FND_API.G_RET_STS_ERROR;
IF p_Line_Adj_rec.update_allowed IS NOT NULL
THEN
IF NOT OE_CNCL_Validate_Adj.update_allowed(p_Line_Adj_rec.update_allowed) THEN
x_return_status := FND_API.G_RET_STS_ERROR;