| calling proc with packag giving no output [message #631082] |
Thu, 08 January 2015 22:58  |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi all,
CREATE OR REPLACE PACKAGE sample_param_pkg
IS
PROCEDURE proc1 (p_order_no IN VARCHAR2 DEFAULT NULL);
PROCEDURE xxc_item_id (v_inventory_item_id IN NUMBER,
v_item_id OUT NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY sample_param_pkg
IS
PROCEDURE proc1 (p_order_no IN VARCHAR2 DEFAULT NULL)
IS
CURSOR c_1 ( v_order_number VARCHAR2)
IS
SELECT b.header_id, a.order_number, b.inventory_item_id
FROM oe_order_headers_all a,
oe_order_lines_all b
WHERE a.header_id = b.header_id
AND a.OPEN_FLAG = 'Y'
AND TO_CHAR (a.order_number) = v_order_number
GROUP BY b.header_id, order_number, b.inventory_item_id
HAVING COUNT (*) > 18;
BEGIN
FOR c_rec IN c_1 (p_order_no)
LOOP
xxc_item_id (c_rec.inventory_item_id, v_item_id);
IF NVL (v_item_id, 0) > 0
THEN
DBMS_OUTPUT.put_line ('Item Id is already Existing');
END IF;
END LOOP;
END ;
PROCEDURE xxc_item_id (v_inventory_item_id in NUMBER,v_item_id out NUMBER)
IS
BEGIN
SELECT inventory_item_id
INTO v_item_id
FROM mtl_system_items
WHERE inventory_item_id = v_inventory_item_id;
End;
END;
Execute command
--------------------
SQL> exec sample_param_pkg.proc1
PL/SQL procedure successfully completed.
Fetching no data
|
|
|
|
| Re: calling proc with packag giving no output [message #631085 is a reply to message #631082] |
Thu, 08 January 2015 23:14   |
 |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Sorry, in the cursor i am using with b.inventory_item_id that's why i am not getting any values ,can you please help me why it is happening??
SQL> SELECT b.header_id, a.order_number
2 FROM oe_order_headers_all a,
3 oe_order_lines_all b
4 WHERE a.header_id = b.header_id
5 AND a.OPEN_FLAG = 'Y'
6 -- AND TO_CHAR (a.order_number) = v_order_number
7 GROUP BY b.header_id, order_number
8 HAVING COUNT (*) > 15;
HEADER_ID ORDER_NUMBER
---------- ------------
171366 80034
49522 85040
171379 80038
49520 85038
SQL> SELECT b.header_id, a.order_number,b.inventory_item_id
2 FROM oe_order_headers_all a,
3 oe_order_lines_all b
4 WHERE a.header_id = b.header_id
5 AND a.OPEN_FLAG = 'Y'
6 -- AND TO_CHAR (a.order_number) = v_order_number
7 GROUP BY b.header_id, order_number,b.inventory_item_id
8 HAVING COUNT (*) > 15;
no rows selected
|
|
|
|
|
|
|
|
|
|
| Re: calling proc with packag giving no output [message #631098 is a reply to message #631093] |
Fri, 09 January 2015 01:48  |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
mist598 wrote on Fri, 09 January 2015 07:21Thanks for reply Littlefoot
Quote:Because no combination of (b.header_id, order_number, b.inventory_item_id) contains more than 15 records.
Yes.So then,how to get inventory_item_id value also?
Which one? According to the posted results, there are multiple (=more than one) different INVENTORY_ITEM_IDs for each listed (HEADER_ID, ORDER_NUMBER) combination.
One option would be using any agregate function to obtain one (MIN, MAX) or all (LISTAGG, COLLECT) of them.
For 11gR2, they are listed e.g. here: https://docs.oracle.com/cd/E11882_01/server.112/e41084/functions003.htm#SQLRF20035
Other option would be using the aggregate in a subquery, but it does two passes via tables:
select b.header_id, a.order_number, b.inventory_item_id
FROM oe_order_headers_all a,
oe_order_lines_all b
WHERE a.header_id = b.header_id
AND a.OPEN_FLAG = 'Y'
AND (b.header_id, order_number) in (<the first aggregate query>);
|
|
|
|