The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT organization_id, inventory_item_id, lot_number
FROM mtl_lot_numbers
WHERE organization_id = nvl(p_org_id, organization_id)
AND lot_attribute_category IS NULL
ORDER BY organization_id, inventory_item_id;
l_update_count NUMBER := 0;
-- Step 3. Update lot with the default attribute
UPDATE_LOT_SERIAL_ATTR(
x_return_status => l_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
, x_update_count => l_update_count
, p_lot_serial_option => OPTION_LOT
, p_organization_id => v_lot.organization_id
, p_inventory_item_id => v_lot.inventory_item_id
, p_lot_serial_number => v_lot.lot_number
, p_attribute_category => l_context_code
, p_attributes => l_attribute_default);
--trace('Updated lot wtih attributes, status, count '
-- || l_return_status || ',' || l_update_count);
trace('Successfully updated lot:'||v_lot.lot_number
|| ',org:'||v_lot.organization_id||',item:'||v_lot.inventory_item_id);
END IF; -- Step 3. update lot
SELECT current_organization_id, inventory_item_id, serial_number
FROM mtl_serial_numbers
WHERE current_organization_id = nvl(p_org_id, current_organization_id)
AND serial_attribute_category IS NULL
AND current_status in (3,4,5)
ORDER BY current_organization_id, inventory_item_id;
l_update_count NUMBER := 0;
-- Step 3. Update serial with the default attribute
UPDATE_LOT_SERIAL_ATTR(
x_return_status => l_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
, x_update_count => l_update_count
, p_lot_serial_option => OPTION_SERIAL
, p_organization_id => v_serial.current_organization_id
, p_inventory_item_id => v_serial.inventory_item_id
, p_lot_serial_number => v_serial.serial_number
, p_attribute_category => l_context_code
, p_attributes => l_attribute_default);
--trace('Updated serial wtih attributes, status, count '
-- || l_return_status || ',' || l_update_count);
trace('Successfully updated serial:'||v_serial.serial_number
|| ',org:'||v_serial.current_organization_id ||',item:'||v_serial.inventory_item_id);
END IF; -- Step 3. update serial
/* Update lot/serial number with the given attribute record
Input Parameter:
p_lot_serial_option: specify update lot or serial
possible value: OPTION_LOT(1), OPTION_SERIAL(2)*/
PROCEDURE UPDATE_LOT_SERIAL_ATTR(
x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
, x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
, x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
, x_update_count OUT NOCOPY /* file.sql.39 change */ NUMBER
, p_lot_serial_option IN NUMBER
, p_organization_id IN NUMBER
, p_inventory_item_id IN NUMBER
, p_lot_serial_number IN VARCHAR2
, p_attribute_category IN VARCHAR2
, p_attributes IN inv_lot_sel_attr.lot_sel_attributes_tbl_type
)IS
l_update_cur INTEGER;
l_update_stmt VARCHAR2(1000);
l_rowupdated NUMBER;
--trace('In UPDATE_LOT_SERIAL, lot/ser option, org, item, lot/ser, p_attr_count ');
-- Construct the update statement
l_update_stmt := 'UPDATE ';
l_update_stmt := l_update_stmt || LOT_TABLE_NAME ||
' SET lot_attribute_category = :attr_category ';
l_update_stmt := l_update_stmt || SERIAL_TABLE_NAME ||
' SET serial_attribute_category = :attr_category ';
l_update_stmt := l_update_stmt || ' , ' || p_attributes(i).column_name || '=';
l_update_stmt := l_update_stmt || 'null';
l_update_stmt := l_update_stmt || p_attributes(i).column_value;
l_update_stmt := l_update_stmt || '''' || p_attributes(i).column_value|| '''';
l_update_stmt := l_update_stmt || p_attributes(i).column_value;
l_update_stmt := l_update_stmt ||
' WHERE organization_id=:org_id AND inventory_item_id=:item_id AND lot_number=:lot_serial';
l_update_stmt := l_update_stmt ||
' WHERE current_organization_id=:org_id AND inventory_item_id=:item_id AND serial_number=:lot_serial';
l_update_cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(l_update_cur, l_update_stmt, DBMS_SQL.v7);
DBMS_SQL.BIND_VARIABLE(l_update_cur, ':attr_category', p_attribute_category);
DBMS_SQL.BIND_VARIABLE(l_update_cur, ':org_id', p_organization_id);
DBMS_SQL.BIND_VARIABLE(l_update_cur, ':item_id', p_inventory_item_id);
DBMS_SQL.BIND_VARIABLE(l_update_cur, ':lot_serial', p_lot_serial_number);
l_rowupdated := DBMS_SQL.EXECUTE(l_update_cur);
IF l_rowupdated >= 1 THEN
x_update_count := l_rowupdated;
trace(' No rows updated , error in update lot/serial ' ||p_lot_serial_number
|| ',org:'||p_organization_id ||',item:'||p_inventory_item_id);
DBMS_SQL.CLOSE_CURSOR(l_update_cur);
DBMS_SQL.CLOSE_CURSOR(l_update_cur);
trace('Error in update lot/serial '|| p_lot_serial_number
|| ',org:'||p_organization_id ||',item:'||p_inventory_item_id);
END UPDATE_LOT_SERIAL_ATTR;