PLS-00049: bad bind variable 'INVENTORY_ITEM_ID' [message #589197] |
Wed, 03 July 2013 05:03 |
|
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi,
In my Function i used "where INVENTORY_ITEM_ID=: INVENTORY_ITEM_ID", Error--PLS-00049: bad bind variable 'INVENTORY_ITEM_ID', Actually based on INVENTORY_ITEM_ID i want to display ONHANDQUANTITY Details..So,can any onr please suggest me?
Thanks&Regards,
Siva
|
|
|
|
|
Re: PLS-00049: bad bind variable 'INVENTORY_ITEM_ID' [message #589206 is a reply to message #589197] |
Wed, 03 July 2013 05:37 |
rajthampi
Messages: 28 Registered: December 2006 Location: Kuwait
|
Junior Member |
|
|
Hi
You cannot call a bind variable inside a function! You have to either pass it to the function or assign to a local variable through a Select statement or constant value, please see below
onhand_qty := myfunction(item_id);
Create or replace function myfunction(p_item_id NUMBER) return number is
l_item_id number;
oh_qty NUMBER
Begin
l_item_id := p_item_id; --this is unnecessary as you can straight away refer to p_item_id
Select quantity into onhand_qty from my table
where item_id = p_item_id; -- (or l_item_id) as you wish
return onhand_qty;
Exception
when no_data_found then
return 0;
End;
[Updated on: Wed, 03 July 2013 05:39] Report message to a moderator
|
|
|
|
|
Re: PLS-00049: bad bind variable 'INVENTORY_ITEM_ID' [message #589209 is a reply to message #589207] |
Wed, 03 July 2013 05:46 |
rajthampi
Messages: 28 Registered: December 2006 Location: Kuwait
|
Junior Member |
|
|
There is one API returns the ATT, ATR quantities. Start using it! Sample code as below
CREATE OR REPLACE FUNCTION APPS.xx_retrive_quantity_f (item_id NUMBER,
org_id NUMBER,
subinv VARCHAR2
)
return number
IS
v_api_return_status VARCHAR2 (1);
v_qty_oh NUMBER;
v_qty_res_oh NUMBER;
v_qty_res NUMBER;
v_qty_sug NUMBER;
v_qty_att NUMBER;
v_qty_atr NUMBER;
v_msg_count NUMBER;
v_msg_data VARCHAR2 (1000);
v_inventory_item_id VARCHAR2 (250) := item_id;
v_organization_id VARCHAR2 (10) := org_id;
v_subinventory_code VARCHAR2 (20) := subinv;
qattrns number := 0;
BEGIN
inv_quantity_tree_grp.clear_quantity_cache;
apps.INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES (
p_api_version_number => 1.0,
p_init_msg_lst => apps.fnd_api.g_false,
x_return_status => v_api_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
p_organization_id => v_organization_id,
p_inventory_item_id => v_inventory_item_id,
p_tree_mode => apps.inv_quantity_tree_pub.g_transaction_mode,
p_onhand_source => 3,
p_is_revision_control => FALSE,
p_is_lot_control => FALSE,
p_is_serial_control => FALSE,
p_revision => NULL,
p_lot_number => NULL,
p_subinventory_code => NVL(v_subinventory_code,NULL),
p_locator_id => NULL,
x_qoh => v_qty_oh,
x_rqoh => v_qty_res_oh,
x_qr => v_qty_res,
x_qs => v_qty_sug,
x_att => v_qty_att,
x_atr => v_qty_atr
);
qattrns := v_qty_att;
return(nvl(qattrns,0));
END xx_retrive_quantity_f;
Once compiled you should call the function like following
my_item_qty := APPS.xx_retrive_quantity_f (item_id, org_id, subinv);
eg: my_item_qty := APPS.xx_retrive_quantity_f (1222122, 405, 'MYSUBINV');
leaving the subinv NULL will generate the quantity for entire org, otherwise subinventory quantity will be calculated
regards,
raj
[Updated on: Wed, 03 July 2013 05:47] Report message to a moderator
|
|
|
|
|