Order by in Cursor
I have problems in using Order by in Cursor.
Your help shall be appreciated
I have problems in using Order by in Cursor.
Your help shall be appreciated
Similar Messages
-
Sort(Order by) a cursor by cursor parameter
Hello,
I want to make cursor to query three column data, and order by the paramter when calling store procedure. But the cursor did not order by column name at all.
Any help will be appreciated.
ggu.
My package/procedure:
CREATE OR REPLACE PACKAGE test_PKG AUTHID DEFINER
AS
TYPE REF_CUR IS REF CURSOR;
PROCEDURE test_proc(COLN IN VARCHAR2, OUTCUR OUT REF_CUR);
END test_PKG;
CREATE OR REPLACE PACKAGE BODY TEST_PKG
AS
PROCEDURE test_proc(COLN in varchar2, outcur out ref_cur) IS
BEGIN
IF NOT OUTCUR%ISOPEN
THEN
open OUTCUR FOR
SELECT CPS.PYROL_ID,
CPS.VEND_ID,
CPS.CONT_ID
FROM EPRS.CNTRCTR_PYROL_SUBMIT CPS
ORDER BY COLN; <------What should be here?
END IF;
end test_proc;
end test_pkg;
var results refcursor;
execute test_PKG.test_PROC('Vend_ID', :results);
print results;
It gave me results:
PYROL_ID VEND_ID CONT_ID
193 06883 009214070
196 11756 202101064
205 06507 072202046
206 06507 042202046
207 06507 032202046
208 06883 012202046I could make the question more clear;
I want to query a table, for example, with three columns. The query results should be sorted by one specific column. I want to leave the column to be ordered by as a parameter, how to implment it?
Thanks. -
Cannot use ORDER BY in cursors - why not?
When defining af cursor in a stored procedure, Oracle 8.1.7 wont let me add an ORDER BY clause. I have tried on two installations with the same result. I then asked a peer why, but he demonstrated that it was perfectly alright on his installation of 8.1.7.
So what may be wrong in my (two) configurations?
Best regards
Poul-JorgenJust in case you are not convinced, here is a test that duplicates the error with the cursor that has parentheses and no error with the cursor that does not have parentheses. It also demonstrates the type of cut and paste of complete code that is most helpful, that includes the SQL*Plus version, the Oracle version, the code tested, and the error message. In the example below, I saved everything to a file called test.sql, set echo on, then started the file. I added the minimum requirements, such as create or replace and null in order to complete the codes.
SQL*Plus: Release 8.1.7.0.0 - Production on Thu Oct 24 16:49:38 2002
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
SQL> SET ECHO ON
SQL> @ TEST
SQL> -- table for testing
SQL> CREATE TABLE anytable
2 (anycolumn NUMBER)
3 /
Table created.
SQL>
SQL>
SQL> -- test of what you posted with parentheses:
SQL> CREATE OR REPLACE
2 PROCEDURE myProcedure IS
3 CURSOR myCursor IS (SELECT * FROM anyTable ORDER BY anyColumn);
4 BEGIN
5 --further procedure logic
6 NULL;
7 END myProcedure;
8 /
Warning: Procedure created with compilation errors.
SQL> SHOW ERRORS
Errors for PROCEDURE MYPROCEDURE:
LINE/COL ERROR
2/44 PLS-00103: Encountered the symbol "ORDER" when expecting one of
the following:
. ) , @ <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus partition start subpartition union where connect
SAMPLE_
The symbol "group was inserted before "ORDER" to continue.
SQL>
SQL>
SQL> -- test of what I posted without parentheses:
SQL> CREATE OR REPLACE PROCEDURE myProcedure IS
2 CURSOR myCursor IS SELECT * FROM anyTable ORDER BY anyColumn;
3 BEGIN
4 --further procedure logic
5 NULL;
6 END myProcedure;
7 /
Procedure created.
SQL> SHOW ERRORS
No errors. -
Cursor selection does not follow chapter order on sub-menu
I used iMovieHD6 to add chapter markers to my large DVD project. They "shared" very nicely into iDVD8 and the Chapter Selection sub-menus were created nicely.
The problem is that when I use the cursor arrows on the DVD remote (real or virtual, in or out of iDVD), the highlight jumps around the sub-menu items rather than moving in a logical order. For example, I have 4 sub-menus with 6 chapters in each. Let's use numbers for them starting with the upper left they are 1,2,3 and then at the lower left they begin 4,5,6. I am using the Reflection White theme. When I press the right remote cursor button it will move from 1 to 2 to 5 to 6 to 3 to 4 and back to 1. Note that this order is not the same for each sub-menu, but none of them go 1,2,3,4,5,6.
I don't know what might be wrong or how to correct it, but I have a really big project that is otherwise perfect and I'd really like to get it out, please help!
Thanks.I just wanted to add this before closing this topic.
After poking around with the Reflection theme I better understood what Len was talking about. It appears that there are no modifiable parameters in the theme itself that control the order of cursor's motion through the buttons. That I assume is hard-coded into iDVD and follows a pre-programmed logic.
The point of failure is the position and orientation of the buttons in the Reflection theme's sub-menus when added automatically. They are made to look to the viewer as though they are set on an angled surface and viewed at an angle from above. While our brains can process this effect nicely, iDVD's cursor logic doesn't fare as well.
The work-around is fairly simple: Realizing that iDVD treats all chapter buttons as though they are two-dimensional objects on a flat surface, you must re-arrange them so that from top-left to bottom-right they follow a logical order, with the first buttons higher and farther left than the later-selected buttons. You don't have to move them very far to get the desired result and it doesn't have to affect the overall appearance of the menu in a noticeable way.
A slight rearrangement in my case left the overall look of the chapter menu the same but yielded a zig-zag flow through the buttons as follows:
[1] [3] [5]
[2] [4] [6]
Pressing the right cursor key jumps from top left to bottom left to top center then bottom center then top right and finally bottom right before going back to the start. Granted this is not quite "right" in that if iDVD could "see" the menu the way my brain does it would go left to right across the upper row of buttons rather than zig-zagging, but I figure that as long as the user can understand how to get to the button they want it'll be fine.
If you really need your menu selection to move linearly left to right with those arrows and with the up/down arrow used to move it vertically, then you have to arrange the buttons on the menu in a rectangular pattern with the top of each row of buttons all in a nice horizontal line. Note that's not the same as the alignment line that Reflection provides for you, it's a true horizontal line in relation to the monitor screen.
I'd much prefer that iDVD revisit the logic of the cursor control code, perhaps adding the choice of allowing the numerical sequence of the chapters to dictate the order of the cursor's motion rather than their relative position on the screen, but since they don't call me for advice, the above will likely have to do. -
How to determine the positioning order when using tab key?
Hallo,
in my jspx-page i want to define the order which the cursor jumps when the user is using the tab key.
i don't know how to? in html there i can use tabindex. which way i must go?
Any help is appreciated.I found that tabindex is not applicable. But i think it is an important point for better handling.
Is there no easy way to do it? -
Hi All,
I want to order my SELECT using "dynamic ORDER BY". I have a CURSOR (in my PL/SQL procedure) contains a select with ORDER BY clause. I have implemented two combobox in my form (the first contains the column name, the second contains ASC and DESC).I tried with the next:
1) Dynamic ORDER BY in CURSOR with combobox results. IT DOESN'T WORK.
2) Using a block property named "ORDER BY CLAUSE". Here I put, for example, :myBlock.comboColumnOrder. IT DOESN'T WORK.
3) Using a function: set_block_property(myBlock,order_by,:myBlock.comboColumnOrder) or set_block_property(myBlock,default_where,:myBlock.comboColumnOrder). IT DOESN'T WORK.
4) Using dynamic CURSOR: ORACLE FORMS give me an error that said: "...it can't to the CLIENT-SIDE".
I have thought my last solution, but it maybe cumbersome. I do a TEMPORARY TABLE, and my CURSOR insert in this TABLE, and then I'll fetch to my BLOCK.
Thanks a lot.
PS: My ORACLE Version is 10g.PROCEDURE CHEQUEAR_V0 IS
V_ORDEN VARCHAR2(50) := '' || :BLOCK_CHECK.ORDER_BY_NAME || ' ' || :BLOCK_CHECK.ORDER_BY_ASC_DES ;
CURSOR FILA_RESULTADO_TABLA IS
SELECT Last_name,First_name,App_user, App_role, UserDB
FROM adm_users
WHERE
((Last_name IS NULL OR Last_name LIKE '%'||:BLOCK_CHECK.Last_name||'%') AND
(First_name IS NULL OR First_name LIKE '%'||:BLOCK_CHECK.First_name||'%') AND
(App_user IS NULL OR App_user LIKE '%'||:BLOCK_CHECK.App_user||'%') AND
(App_role IS NULL OR App_role LIKE '%'||:BLOCK_CHECK.App_role||'%') AND
(UserDB IS NULL OR UserDB LIKE '%'||:BLOCK_CHECK.User_DB||'%'))
ORDER BY V_ORDEN;
V_Last_name VARCHAR2(50);
V_First_name VARCHAR2(50);
V_App_user VARCHAR2(50);
V_App_role VARCHAR2(50) ;
V_User_DB VARCHAR2(50);
CONT NUMBER ;
BEGIN
CONT := 1 ;
GO_BLOCK('BLOCK_APPS_GRANTS');
CLEAR_BLOCK;
SYNCHRONIZE;
OPEN FILA_RESULTADO_TABLA;
LOOP
FETCH FILA_RESULTADO_TABLA INTO V_Last_name,V_First_name,V_App_user,V_App_role,V_User_DB ;
EXIT WHEN FILA_RESULTADO_TABLA%NOTFOUND;
:BLOCK_APPS_GRANTS.Last_name := V_Last_name ;
:BLOCK_APPS_GRANTS.First_name := V_First_name ;
:BLOCK_APPS_GRANTS.App_user := V_App_user ;
:BLOCK_APPS_GRANTS.App_role := V_App_role ;
:BLOCK_APPS_GRANTS.User_DB := V_User_DB ;
NEXT_RECORD;
CONT := CONT+1;
END LOOP;
IF FILA_RESULTADO_TABLA%ISOPEN THEN
CLOSE FILA_RESULTADO_TABLA;
END IF;
SET_BLOCK_PROPERTY('BLOCK_APPS_GRANTS', ORDER_BY, :BLOCK_CHECK.ORDER_BY_NAME || ' ' || :BLOCK_CHECK.ORDER_BY_ASC_DES);
GO_BLOCK('BLOCK_APPS_GRANTS');
EXECUTE_QUERY;
synchronize;
exception when others then
raise;
END;
Thanks a lot.
Edited by: user11285646 on 22-jul-2009 2:30 -
How to get the cursor position from screen in module pool program
Hi,
I am doing the module pool program, I have one table control in one screen.
I have to give functionality to the user that when the user enters first record in the table control and after filling the last field
when he presses enter the cursor will have to come in the starting field of the second record.
I know the logic , but i m bit confused.
Can any body help me to solve this....
thanksHi,
Check this code,
Write it in the PBO
MODULE SET_CURSOR_WERTKONTRAKT.
MODULE SET_CURSOR_WERTKONTRAKT OUTPUT.
PERFORM SET_CURSOR USING 'VBAP-ZWERT'.
ENDMODULE. " SET_CURSOR_WERTKONTRAKT OUTPUT
FORM SET_CURSOR USING US_FELDNAME.
DATA: DA_TFILL LIKE SY-TFILL.
DESCRIBE TABLE IVBAP LINES DA_TFILL.
FCODE 'Create Position':
==> Cursor to the first free line set to make the new position
Can be created directly
IF DA_TFILL EQ 0.
SET CURSOR FIELD US_FELDNAME LINE 1. -> set cursor position
ELSE.
SET CURSOR FIELD US_FELDNAME LINE 2.
ENDIF.
Product proposal actively
Set ==> cursor in the first row
IF DPP_ACTIVE EQ CHARX AND
XVBAP_UMFANG_OPV IS INITIAL.
in the 'target volume' if available
IF KOPGR_MIT_ZMENG CS TVAK-KOPGR.
SET CURSOR FIELD 'VBAP-ZMENG' LINE 1.
EXIT.
ELSE.
Else in the field 'Order quantity'
SET CURSOR FIELD 'RV45A-KWMENG' LINE 1.
EXIT.
ENDIF.
ENDIF.
Hope it helps you,
Regards,
Abhijit G. Borkar -
Placing multiple images in order
Sorry if this has been discussed. I searched, but didn't see anything. Anyway, when I try to place multiple images with the new bullet cursor or whatever it's called, the images don't stay in order. i.e. I select images named 1-50, when I place them, they get placed as 1, 15, 7, 28, etc. How can I get them to stay in the order I select? It makes for a serious pain when trying to build contact sheets.
I wish they wouldn't have gotten rid of that feature in CS4 (create contact sheets from Bridge).I see nobody else has anything useful to say...
I don't know how to get files to stay in order in the cursor, except perhaps to have them named in alphabetic order. I think the ordering is controleed by the OS. Are you aware that you can use the arrow keys to scroll through the thumbnails in the loaded cursor until you get the one you want? Would that help? -
Tuning Oracle Applicatons Order Management Query
Hi
We are trying to build a Order Management related workbench for this I have created below query as per the client requirement.
And I have to use one package function to get Available_qty based on client defination. Package Function name is "xx_eg_calculated_onhand".
User will query this view based on Customer_id and Salesperson_id. When this view executed with these two values its taking long time.
But, if user queries with order_number it is getting executed fastly. Could somebody let me know what should I do to get this query execute fast when
user query with either customer_id or salesrep_id OR both.
CREATE OR REPLACE VIEW xxrelease_sales_orders_v (row_id,
sales_oder,
cust_po_number,
line_id,
carrier,
segment1,
customer_item_number,
description,
ship_from,
ship_to,
request_date,
order_quality,
available_qty,
shipped_quality,
uom,
customer_name,
sales_person_name,
delivery_detail_id,
cust_hold,
release_check,
line_status,
organization_code,
org_id,
order_number,
tolerance,
delivery_id,
organization_id,
salesrep_id,
party_id,
inventory_item_id,
header_id,
cust_account_id,
location_id,
cust_acct_site_id
AS
SELECT a.row_id,
a.Sales_Order,
a.Cust_Po_Number,
a.Line_ID,
a.Carrier,
a.segment1,
a.Customer_Item_Number,
a.description,
a.Ship_From,
a.ship_to,
a.request_date,
a.order_quality,
DECODE(SIGN(a.Available_qty),-1, 0, a.available_qty) Available_Qty,
DECODE(SIGN(LEAST(a.order_quality, a.Available_qty)), -1,0, LEAST(a.order_quality, a.Available_qty)) Shipped_Qty,
a.uom,
a.Customer_Name,
a.Sales_Person_Name,
a.delivery_detail_id,
a.cust_hold,
a.release_check,
a.Line_status,
a.organization_code,
a.org_id,
a.order_number,
a.tolerance,
a.delivery_id,
a.organization_id,
a.salesrep_id,
a.party_id,
a.inventory_item_id,
a.header_id,
a.cust_account_id,
a.location_id,
a.cust_acct_site_id
From (
SELECT ooh.ROWID row_id,
ooh.order_number||'-'||ool.line_number||'.'||ool.shipment_number Sales_Order,
ool.cust_po_number,
ool.line_id,
NVL (ool.freight_carrier_code, 'NA') carrier,
msi.segment1,
ool.ordered_item Customer_Item_Number,
msi.description,
haou.name Ship_From,
hl.city || ' ' || hl.state || ' ' || hl.postal_code ship_to,
NVL (ool.request_date, SYSDATE) request_date,
NVL (ool.ordered_quantity, 0) order_quality,
xxeg_releaseworkbench_form_pkg.xx_eg_calculated_onhand(ool.line_id) Available_qty,
ool.order_quantity_uom uom,
hp.party_name Customer_Name,
hca.account_number Customer_Number,
jrs.name Sales_Person_Name,
wdd.delivery_detail_id,
0 cust_hold,
0 release_check,
oe_line_status_pub.Get_Line_Status(ool.line_id, ool.flow_status_code) Line_status,
ool.org_id,
ooh.order_number,
NVL (ool.ship_tolerance_above, 0) tolerance,
wda.delivery_id,
ool.ship_from_org_id organization_id,
jrs.salesrep_id,
hp.party_id,
msi.inventory_item_id,
ooh.header_id,
hca.cust_account_id,
hps.location_id,
hcsu.cust_acct_site_id,
ooh.ship_to_org_id site_use_id,
hcas.party_site_id,
'0' organization_code
FROM oe_order_headers_all ooh,
oe_order_lines_all ool,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
mtl_system_items_b msi,
hz_cust_accounts hca,
hz_parties hp,
jtf_rs_salesreps jrs,
hz_cust_site_uses_all hcsu,
hz_cust_acct_sites_all hcas,
hz_party_sites hps,
hz_locations hl,
hr_all_organization_units haou
WHERE ooh.header_id = ool.header_id
AND ooh.header_id = wdd.source_header_id
AND ool.line_id = wdd.source_line_id
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND ool.inventory_item_id = msi.inventory_item_id
AND ooh.ship_from_org_id = msi.organization_id
AND ooh.sold_to_org_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND ool.salesrep_id = jrs.salesrep_id
AND ool.org_id = jrs.org_id
AND ooh.ship_to_org_id = hcsu.site_use_id
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.party_site_id = hps.party_site_id
AND hps.location_id = hl.location_id
AND ool.ship_from_org_id = haou.organization_id
AND wdd.released_status = 'R'
AND hcsu.site_use_code = 'SHIP_TO'
AND ool.flow_status_code = 'AWAITING_SHIPPING'
--and hca.cust_account_id = 1531 and jrs.salesrep_id = 100000060
--AND ooh.order_number = '361130'
) a
Function
FUNCTION xx_eg_calculated_onhand (p_so_line_id IN NUMBER) RETURN NUMBER IS
--CREATE OR REPLACE PROCEDURE xx_eg_calculated_onhand (p_so_line_id IN NUMBER) IS
-- Steps Involved to calculate the onhand availability
-- 1. Get Inventory Item ID and Warehouse from given sales order line ID
-- Local Variable Declration
l_inventory_item_id apps.oe_order_lines_all.inventory_item_id%TYPE := 0;
l_organization_id apps.oe_order_lines_all.ship_from_org_id%TYPE := 0;
l_order_quantity_uom apps.oe_order_lines_all.order_quantity_uom%TYPE := '';
l_primary_uom_code apps.mtl_system_items_b.primary_uom_code%TYPE := '';
l_onhand_reserve NUMBER(15,2) := 0;
l_hard_reservation NUMBER(15,2) := 0;
l_so_soft_reservation NUMBER(15,2) := 0;
l_wo_soft_reservation NUMBER(15,2) := 0;
l_so_released_ware_qty NUMBER(15,2) := 0;
-- Cursor declrations
-- Get inventory item, warehouse and order UOM Details
CURSOR Get_inv_and_org_details IS
SELECT ool.inventory_item_id,
ool.ship_from_org_id,
ool.order_quantity_uom,
msi.primary_uom_code
FROM apps.oe_order_lines_all ool,
apps.mtl_system_items_b msi
WHERE ool.line_id = NVL(p_so_line_id,0)
AND ool.inventory_item_id = msi.inventory_item_id
AND ool.ship_from_org_id = msi.organization_id;
-- Get Hard Reservation details for given item and warehouse
CURSOR Get_Hard_reservation(p_inventory_item_id IN NUMBER, p_organization_id IN NUMBER) IS
SELECT SUM(reservation_quantity)
FROM apps.mtl_reservations
WHERE inventory_item_id = NVL(p_inventory_item_id,0)
AND organization_id = NVL(p_organization_id, 0)
AND demand_source_line_id <> p_so_line_id;
-- Get Soft reservation details for given item and warehouse for Sales order
CURSOR Get_so_soft_reservation (p_inventory_item_id IN NUMBER, p_organization_id IN NUMBER) IS
SELECT SUM(mlqv.onhand_qty)
FROM xxapps.xx_eg_lot_reservations xelr,
xxapps.mtl_lot_qty_vw mlqv,
apps.oe_order_lines_all ool
WHERE xelr.lot_no = mlqv.lot_no
AND xelr.so_line_id = ool.line_id
AND mlqv.org_id = ool.ship_from_org_id
AND mlqv.item_id = ool.inventory_item_id
AND mlqv.org_id = p_organization_id
AND mlqv.item_id = p_inventory_item_id;
-- Get Soft reservation details for given item and warehouse for work orders
CURSOR Get_wo_soft_reservation (p_inventory_item_id IN NUMBER, p_organization_id IN NUMBER) IS
SELECT SUM(mlqv.onhand_qty)
FROM xxapps.xx_eg_lot_reservations xelr,
xxapps.mtl_lot_qty_vw mlqv,
wip.wip_requirement_operations wro
WHERE xelr.lot_no = mlqv.lot_no
AND xelr.wip_entity_id = wro.wip_entity_id
AND mlqv.org_id = wro.organization_id
AND mlqv.item_id = wro.inventory_item_id
AND mlqv.org_id = p_organization_id
AND mlqv.item_id = p_inventory_item_id;
-- Get Sales order lines quantity for the shipment status 'Released to Wareshoue'
CURSOR Get_so_qty (p_inventory_item_id IN NUMBER, p_organization_id IN NUMBER) IS
SELECT SUM(requested_quantity)
FROM apps.wsh_deliverables_v
WHERE released_status='S'
AND inventory_item_id = p_inventory_item_id
AND organization_id = p_organization_id;
BEGIN
Dbms_output.put_line('Function Started with so_line_id = '||p_so_line_id);
-- Get the inventory_item_id and warehouse id and
-- ordered quantity uom details
-- By opening the cursor Get_inv_and_org_details
OPEN Get_inv_and_org_details;
FETCH Get_inv_and_org_details INTO l_inventory_item_id,l_organization_id,l_order_quantity_uom,l_primary_uom_code;
CLOSE Get_inv_and_org_details;
Dbms_output.put_line('Inventory item id = '||l_inventory_item_id||' and warehouse id = '||l_organization_id);
IF (l_inventory_item_id = 0 OR l_inventory_item_id IS NULL) OR
(l_organization_id = 0 OR l_organization_id IS NULL) THEN
dbms_output.put_line('No inventory/wareshouse details available for given sales order line');
RETURN 0;
END IF;
-- Get onhand available to reserve quantity using API
-- passing inventory item id and organization id as
-- a parameters.
l_onhand_reserve := apps.xx_utility_pkg.Get_Available_to_Reserve_org(l_inventory_item_id,l_organization_id);
Dbms_output.put_line('Onhand availability to Reserve quantity = '||l_onhand_reserve);
-- Get hard reservation quantity by
-- passing inventory item id and organization id as
-- a parameters to cursor Get_Hard_reservation
OPEN Get_Hard_reservation(l_inventory_item_id,l_organization_id);
FETCH Get_Hard_reservation INTO l_hard_reservation;
CLOSE Get_Hard_reservation;
Dbms_output.put_line('Hard Reserve quantity = '||l_hard_reservation);
-- Get Soft reservation quantity by
-- passing inventory item id and organization id as
-- a parameters to cursor
-- Get_so_soft_reservation for sales lines
OPEN Get_so_soft_reservation(l_inventory_item_id,l_organization_id);
FETCH Get_so_soft_reservation INTO l_so_soft_reservation;
CLOSE Get_so_soft_reservation;
-- Get Soft reservation quantity by
-- passing inventory item id and organization id as
-- a parameters to cursor
-- Get_wo_soft_reservation for work orders
OPEN Get_wo_soft_reservation(l_inventory_item_id,l_organization_id);
FETCH Get_wo_soft_reservation INTO l_wo_soft_reservation;
CLOSE Get_wo_soft_reservation;
-- Get Sales order line sum quantity for those
-- lines which has a status of 'Released to Warehouse'
-- at their shipment level for given parameters
OPEN Get_so_qty(l_inventory_item_id,l_organization_id);
FETCH Get_so_qty INTO l_so_released_ware_qty;
CLOSE Get_so_qty;
INSERT INTO xxapps.xxeg_calculated_onhand_tbl
order_line_id,
inventory_item_id,
organization_id,
available_to_reserve,
hard_reservation,
soft_reservation_so,
soft_reservation_wo,
other_so_lines_qty,
run_date
VALUES
p_so_line_id,
l_inventory_item_id,
l_organization_id,
NVL(l_onhand_reserve,0),
NVL(l_hard_reservation,0),
NVL(l_so_soft_reservation,0),
NVL(l_wo_soft_reservation,0),
NVL(l_so_released_ware_qty,0),
sysdate
Commit Work;
Create table xxapps.xxeg_calculated_onhand_tbl
order_line_id NUMBER,
inventory_item_id NUMBER,
organization_id NUMBER,
available_to_reserve NUMBER,
hard_reservation NUMBER,
soft_reservation_so NUMBER,
soft_reservation_wo NUMBER,
other_so_lines_qty NUMBER,
run_date DATE
RETURN (NVL(l_onhand_reserve,0) + NVL(l_hard_reservation,0) - (NVL(l_so_soft_reservation,0) + NVL(l_wo_soft_reservation,0)) - NVL(l_so_released_ware_qty,0));
EXCEPTION
WHEN others THEN
RETURN (0);
END xx_eg_calculated_onhand;
KiranHi
I have gathered a explain plan. Could somebody let me know whats going on.
plan_table_output
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 1 | 404 | 87 |
| 1 | NESTED LOOPS | | 1 | 404 | 87 |
| 2 | NESTED LOOPS | | 1 | 374 | 86 |
| 3 | NESTED LOOPS | | 1 | 323 | 85 |
| 4 | NESTED LOOPS | | 1 | 300 | 84 |
| 5 | NESTED LOOPS | | 1 | 290 | 83 |
| 6 | NESTED LOOPS | | 1 | 280 | 80 |
| 7 | NESTED LOOPS | | 1 | 261 | 79 |
| 8 | NESTED LOOPS | | 1 | 209 | 78 |
| 9 | NESTED LOOPS | | 1 | 192 | 75 |
| 10 | NESTED LOOPS | | 1 | 164 | 74 |
| 11 | NESTED LOOPS | | 1 | 76 | 72 |
| 12 | NESTED LOOPS | | 1 | 46 | 3 |
| 13 | TABLE ACCESS BY INDEX ROWID| HZ_CUST_ACCOUNTS | 1 | 16 | 2 |
|* 14 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 1 | | 1 |
| 15 | TABLE ACCESS BY INDEX ROWID| HZ_PARTIES | 1 | 30 | 1 |
|* 16 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 1 | | |
| 17 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 1 | 30 | 69 |
|* 18 | INDEX RANGE SCAN | OE_ORDER_HEADERS_N2 | 1 | | 1 |
|* 19 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 1 | 88 | 2 |
|* 20 | INDEX RANGE SCAN | OE_ORDER_LINES_N1 | 6 | | 1 |
| 21 | TABLE ACCESS BY INDEX ROWID | JTF_RS_SALESREPS | 1 | 28 | 1 |
|* 22 | INDEX UNIQUE SCAN | JTF_RS_SALESREPS_U1 | 1 | | |
|* 23 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_DETAILS | 1 | 17 | 3 |
|* 24 | INDEX RANGE SCAN | WSH_DELIVERY_DETAILS_N3 | 4 | | 2 |
| 25 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 52 | 1 |
|* 26 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | |
|* 27 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 1 | 19 | 1 |
|* 28 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 1 | | |
| 29 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_ASSIGNMENTS | 1 | 10 | 3 |
|* 30 | INDEX RANGE SCAN | WSH_DELIVERY_ASSIGNMENTS_N3 | 1 | | 2 |
| 31 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 1 | 10 | 1 |
|* 32 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 1 | | |
|* 33 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 1 | 23 | 1 |
|* 34 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 1 | | |
|* 35 | TABLE ACCESS BY INDEX ROWID | HZ_LOCATIONS | 1 | 51 | 1 |
|* 36 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 1 | | |
| 37 | TABLE ACCESS BY INDEX ROWID | HR_ALL_ORGANIZATION_UNITS | 1 | 30 | 1 |
|* 38 | INDEX UNIQUE SCAN | HR_ORGANIZATION_UNITS_PK | 1 | | |
Predicate Information (identified by operation id):
14 - access("HCA"."CUST_ACCOUNT_ID"=1531)
16 - access("HCA"."PARTY_ID"="HP"."PARTY_ID")
18 - access("OOH"."SOLD_TO_ORG_ID"=1531)
filter("OOH"."SOLD_TO_ORG_ID"="HCA"."CUST_ACCOUNT_ID")
19 - filter("OOL"."FLOW_STATUS_CODE"='AWAITING_SHIPPING' AND "OOL"."SALESREP_ID"=100000060)
20 - access("OOH"."HEADER_ID"="OOL"."HEADER_ID")
22 - access("JRS"."SALESREP_ID"=100000060 AND "OOL"."ORG_ID"="JRS"."ORG_ID")
filter("OOL"."SALESREP_ID"="JRS"."SALESREP_ID")
23 - filter("OOH"."HEADER_ID"="WDD"."SOURCE_HEADER_ID" AND "WDD"."RELEASED_STATUS"='R')
24 - access("OOL"."LINE_ID"="WDD"."SOURCE_LINE_ID")
26 - access("OOL"."INVENTORY_ITEM_ID"="MSI"."INVENTORY_ITEM_ID" AND
"OOH"."SHIP_FROM_ORG_ID"="MSI"."ORGANIZATION_ID")
27 - filter("HCSU"."SITE_USE_CODE"='SHIP_TO')
28 - access("OOH"."SHIP_TO_ORG_ID"="HCSU"."SITE_USE_ID")
30 - access("WDD"."DELIVERY_DETAIL_ID"="WDA"."DELIVERY_DETAIL_ID")
32 - access("HCSU"."CUST_ACCT_SITE_ID"="HCAS"."CUST_ACCT_SITE_ID")
33 - filter("HZ_PARTY_SITES"."ACTUAL_CONTENT_SOURCE"<>'DNB' AND
"HZ_PARTY_SITES"."ACTUAL_CONTENT_SOURCE"<>'SST')
34 - access("HCAS"."PARTY_SITE_ID"="HZ_PARTY_SITES"."PARTY_SITE_ID")
35 - filter(NVL("HZ_LOCATIONS"."ACTUAL_CONTENT_SOURCE","HZ_LOCATIONS"."CONTENT_SOURCE_TYPE")<>'DNB'
AND NVL("HZ_LOCATIONS"."ACTUAL_CONTENT_SOURCE","HZ_LOCATIONS"."CONTENT_SOURCE_TYPE")<>'SST')
36 - access("HZ_PARTY_SITES"."LOCATION_ID"="HZ_LOCATIONS"."LOCATION_ID")
38 - access("OOL"."SHIP_FROM_ORG_ID"="HAOU"."ORGANIZATION_ID")
Note: cpu costing is off
Regards
Kiran -
Hello,
in a post-query trigger i'm populating a non-database text item (with Items displayed=7) with the code
DECLARE
CURSOR crElev IS
SELECT name ||' '|| surname
FROM elevi
WHERE ID=:vw_angajati_note.id_elev order by nume;
BEGIN
OPEN crElev;
FETCh crElev INTO :vw_angajati_note.elev;
CLOSE crElev;
END;but when executing the query, the non-database item doesn't contain the names ordered.. and i don't know why
is it possible to order in a cursor?
Thanks in advancewhere id=:vw_angajati_note.id_elev --here are 7 records, and i fetch each of them in :vw_angajati_note.elev (i fetch the name ||' ' || surname).
yes, i wanna the records being sorted and displayed alphabetically
p.s. the database item is id_elev (so there are just numbers) and the non-database item is elev, where i fetch the names -
Hello. I have this code I'm working on. A few facts: I'm running it in SQL Developer. I'm getting an ORA-06502 and ORA-06512 at line 138, 156 error. There are 2480 records total and the report should generate data on about half of that. I've tried everything I know to do. I was hoping someone could lead me in the right direction. Thanks
SET SERVEROUTPUT ON SIZE UNLIMITED
DECLARE
type mytype
IS
record
pidm NUMBER,
st_id VARCHAR2(9),
st_name VARCHAR2(100),
b_area VARCHAR2 (20),
b_areadesc varchar2 (100)
TYPE tabs IS TABLE OF mytype INDEX BY PLS_INTEGER;
TYPE big_tab
IS
RECORD
(num_rows PLS_INTEGER, course tabs);
courses big_tab;
application VARCHAR2 (30) := 'STUDENT';
selection VARCHAR2 (30) := 'CAPPREPORTS_HOURSGPA';
creator VARCHAR2 (30) := 'MESANBUR';
usercode VARCHAR2 (30) := 'MESANBUR';
CURSOR get_glbextr (
l_appl IN VARCHAR2,
l_selection IN VARCHAR2,
l_creator IN VARCHAR2,
l_user IN VARCHAR2)
IS
SELECT TO_NUMBER (glbextr_key) glbextr_key,
spriden_id st_id,
spriden_last_name || ': ' || spriden_first_name st_name
FROM spriden, glbextr
WHERE spriden_pidm = TO_NUMBER (glbextr_key)
AND spriden_change_ind IS NULL
AND glbextr_application = l_appl
AND glbextr_selection = l_selection
AND glbextr_creator_id = l_creator
AND glbextr_user_id = l_user
ORDER BY st_name;
CURSOR getaogn (l_pidm IN NUMBER)
is
SELECT
smbaogn_area,
smbaogn_request_no,
smbaogn_met_ind,
smralib_area_desc
FROM smbaogn a, smralib
WHERE NOT EXISTS
(SELECT 'x'
FROM smbaogn
WHERE smbaogn_met_ind = 'Y'
AND smbaogn_area = a.smbaogn_area
AND smbaogn_program = a.smbaogn_program
AND smbaogn_request_no = a.smbaogn_request_no
AND smbaogn_pidm = a.smbaogn_pidm)
AND smbaogn_met_ind = 'N'
and smbaogn_pidm = l_pidm
and smbaogn_area = smralib_area
AND a.smbaogn_request_no =
(SELECT MAX (b.smbaogn_request_no)
FROM smbaogn b
WHERE b.smbaogn_pidm = a.smbaogn_pidm) ;
aogn_rec getaogn%ROWTYPE;
--Procedure inside the anonymous block
PROCEDURE new_proc
l_courses IN OUT big_tab,
l_pidm IN NUMBER,
l_st_name IN VARCHAR2,
l_st_id IN VARCHAR2,
l_b_area in varchar2,
l_b_areadesc in varchar2
IS
found_it BOOLEAN := FALSE;
BEGIN
FOR i IN 1 .. l_courses.num_rows
LOOP
IF l_courses.course .pidm = l_pidm
AND NVL (l_courses.course .st_name, 'xxx') = NVL (l_st_name, 'xxx')
AND NVL (l_courses.course .st_id, 'xxx') = NVL (l_st_id, 'xxx')
AND NVL (l_courses.course .b_area, 'xxx') = NVL (l_b_area, 'xxx')
AND NVL (l_courses.course .b_areadesc, 'xxx') = NVL (l_b_areadesc, 'xxx')
THEN
found_it := TRUE;
EXIT;
END IF;
END LOOP;
IF NOT found_it THEN
l_courses.num_rows := l_courses.num_rows + 1;
l_courses.course (l_courses.num_rows).pidm := l_pidm;
l_courses.course (l_courses.num_rows).st_id := l_st_id;
l_courses.course (l_courses.num_rows).st_name := l_st_name;
l_courses.course (l_courses.num_rows).b_area := l_b_area;
l_courses.course (l_courses.num_rows).b_areadesc := l_b_areadesc;
END IF;
END new_proc;
--BEGIN stmt for outer block----------------------------------------------------
BEGIN
courses.num_rows := 0;
DBMS_OUTPUT.put_line ('Begin processing.');
FOR PIDMS IN get_glbextr (application, selection, creator, usercode)
loop
for aogn_rec in getaogn(pidms.glbextr_key)
loop
new_proc
(courses,
pidms.glbextr_key,
pidms.st_id,
pidms.st_name,
aogn_rec.smbaogn_area,
aogn_rec.smralib_area_desc);
end loop;
end loop;
FOR i IN 1 .. courses.num_rows
loop
DBMS_OUTPUT.enable(3000000);
DBMS_OUTPUT.PUT_LINE (courses.course .st_name
||' : '
|| courses.course .st_id
||' : '
|| courses.course .b_area);
END LOOP;
END;Hi,
921910 wrote:
I new to this PL/SQL stuff. Where would I insert a function?
ThanksI'm not sure what you mean by "insert a function".
You can call a function anywhere an expression is allowed. You call user-defined functions the same way as you call built-in functions.
Here's an example of how you might use the to_num function (from the link I posted) to find the bad data:
SELECT glbextr_key
, ... -- Whatever columns help you identify the row
WHERE glbextr_key IS NOT NULL
AND to_num (glbextr_key) IS NULL
; -
How to move the cursor dynamically
Hi friends,
I want to move the cursor in the output list. According to the cursor movment I want the output order.
Normally cursor will move -
when first line completes then only it will go to next line. after that same process but for me I want to move the cursor position from 40 th line to 2nd line or anywhere. Please explain me.
Regards,
SuryaHi,
Thank u,
SET cursor is used to put the cursor on the selection screen. but what my requirement is I want to display the all contents of internal table into he colum wise.
normally we will print like this f1 f2 f3 ....one row shows one record.
but for me output is.
f1
f2
f3
. one colum will show one record.
Regards,
Surya -
My cursor for update doesn't work:(
hi, i have code:
create or replace procedure szkodowosc_STMT_WC is
date_do varchar2(8);
v_data_b1 szkod_wc_blokady_Wc_07.Data_Przetw%TYPE;
v_data_b2 szkod_wc_blokady_Wc_07.Data_Przetw%TYPE;
v_data_b3 szkod_wc_blokady_Wc_07.Data_Przetw%TYPE;
v_brak_blokady szkod_wc_blokady_Wc_07.Szkodowosc_Procent%TYPE;
v_blokada_all szkod_wc_blokady_Wc_07.Szkodowosc_Procent%TYPE;
v_blokada_za_miesiac szkod_wc_blokady_Wc_07.Szkodowosc_Procent%TYPE;
CURSOR cur_szkod_brak_blokady IS
select data_przetw, szkodowosc_procent
from szkod_wc_blokady_Wc_07
where grupa_porownanie = 'brak blokady'
order by data_przetw;
CURSOR cur_szkod_blokada_all IS
select data_przetw, szkodowosc_procent
from szkod_wc_blokady_Wc_07
where grupa_porownanie = 'blokada all' -- blokada od pierwszego stmt
order by data_przetw;
CURSOR cur_szkod_blokada_za_miesiac IS
select data_przetw, szkodowosc_procent
from szkod_wc_blokady_Wc_07
where grupa_porownanie = 'blokada za miesiac' -- blokada od drugiego stmt
order by data_przetw;
CURSOR cur_update IS
select data_przetw, blokada_all
from SZKOD_WC_BLOKADY_WC_07_results
for update of blokada_all NOWAIT;
begin
-- select * from szkod_wc_blokady_Wc_07
delete from SZKOD_WC_BLOKADY_WC_07_results;
commit;
-- przetwarzanie, brak blokady
OPEN cur_szkod_brak_blokady;
LOOP
FETCH cur_szkod_brak_blokady INTO v_data_b1, v_brak_blokady;
EXIT WHEN cur_szkod_brak_blokady%NOTFOUND;
INSERT INTO SZKOD_WC_BLOKADY_WC_07_results (data_przetw, Brak_Blokady) VALUES (v_data_b1, v_brak_blokady);
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM); -- dodac wyrzucanie logow do pliku txt
ROLLBACK;
CLOSE cur_szkod_brak_blokady;
OPEN cur_szkod_blokada_all;
OPEN cur_update;
LOOP
FETCH cur_szkod_blokada_all INTO v_data_b2, v_blokada_all;
EXIT WHEN cur_szkod_blokada_all%NOTFOUND;
FOR rec IN cur_update
LOOP
IF rec.data_przetw = v_data_b2
THEN
UPDATE SZKOD_WC_BLOKADY_WC_07_results
SET blokada_all = v_blokada_all
WHERE CURRENT OF cur_update;
END IF;
END LOOP;
COMMIT;
END LOOP;
CLOSE cur_update;
CLOSE cur_szkod_blokada_all;
-- select * from SZKOD_WC_BLOKADY_WC_07_results
end;my cur_update should update column blokada_all in SZKOD_WC_BLOKADY_WC_07_results table, but i have still NULLs here, why?
my table after update looks like:
DATA_PRZETW BRAK_BLOKADY BLOKADA_ALL BLOKADA_ZA_MIESIAC
2009-08-14 0,362
2009-08-21 0,406
2009-08-28 0,462
2009-09-04 0,509
2009-09-11 0,573
2009-09-18 0,608
2009-09-25 0,645
2009-10-02 0,68
2009-10-09 0,763
2009-10-16 0,852
2009-10-23 0,935
2009-10-30 1,059
2009-11-06 1,148
2009-11-13 1,343
2009-11-20 1,442
2009-11-27 1,554
2009-12-04 1,583
2009-12-11 1,707
2009-12-18 1,807
2009-12-25 1,878
2010-01-01 1,955
2010-01-08 2,086
2010-01-15 2,136
2010-01-22 2,361
2010-01-29 2,469
2010-02-05 2,549looking at your code (it's quite hard to follow with these table name - probably because I don't understand them), your procedure might look like
create or replace procedure szkodowosc_STMT_WC is
begin
INSERT INTO SZKOD_WC_BLOKADY_WC_07_results
select data_przetw, szkodowosc_procent
from szkod_wc_blokady_Wc_07
where grupa_porownanie = 'brak blokady'
order by data_przetw;
UPDATE SZKOD_WC_BLOKADY_WC_07_results r
SET blokada_all = (select szkodowosc_procent
from szkod_wc_blokady_Wc_07 b
where grupa_porownanie = 'blokada all'
and b.data_przetw = r.data_przetw
end;But it probably can be condensed even further by removing the UPDATE, hope you get the gist. :) -
Stored Procedure: Extract data into second cursor
This is ready-to-run script with a commented out INCOMPLETE section of code where i need to select from a cursor.
--== PDF Dcument Table of contents ==---
--== PDF Report contains Period to date on condiments and bun sales for a region
--== For each week for a 4-week period with week 6 representing PTD and week 7 representing
--== YTD. Data should be gathered in rowsets and pivoted on client
--==
--== Basic Functionallity:
--=== Write a stored procedure that performs the following:
--== 1) Select the report data into cursor 1 in the order with a resultset order
--== in the way it will be printed to report.
--== 2) Create list of inique stores in separate cursor
--== Approach:
--== Create the Type object of fields needed to build table of contents for each row of the table. Add a sort field
--== to enable restore the original order of data after any sorting done on client
--== Create table table of the row objects
--== Declare 2 cursors:
-- a) ) First cursor holds the data for the PDF Report to be pivoted by the client
-- b) ) Second should contain a table of contents (unique storenbr) in the
--== same order as the stores in the first cursor.
--== Oracle version 10g v2 on W2K3
begin execute immediate 'drop type TYP_TBL_CWSR_TOC'; exception when others then null; end;
begin execute immediate 'drop type TYP_CWSR_TOC'; exception when others then null; end;
begin execute immediate 'drop procedure Create_Rpt_and_TOC'; exception when others then null; end;
create or replace TYPE TYP_CWSR_TOC AS OBJECT
( sortcol number --== probably not needed, just in case
, storenbr varchar2(100)
, storename varchar2(200)
create or replace TYPE TYP_TBL_CWSR_TOC AS TABLE OF TYP_CWSR_TOC;
create or replace procedure create_rpt_and_toc
pc_report_data OUT sys_refcursor
, pc_TOC OUT sys_refcursor
AS
v_tblTOC TYP_TBL_CWSR_TOC;
v_rec TYP_CWSR_TOC := TYP_CWSR_TOC(NULL,NULL, NULL);
BEGIN
OPEN pc_report_data FOR
with sample_data as
( select 22 storeid , 1 week_nbr, 15942 net_sales, 372 buns, 176 condiments from dual union all
select 22 storeid , 6 week_nbr, 15942 net_sales, 372 buns, 176 condiments from dual union all
select 22 storeid , 7 week_nbr, 15942 net_sales, 372 buns, 176 condiments from dual union all
select 23 storeid , 1 week_nbr, 25302 net_sales, 481 buns, 221 condiments from dual union all
select 23 storeid , 6 week_nbr, 25302 net_sales, 481 buns, 221 condiments from dual union all
select 23 storeid , 7 week_nbr, 25302 net_sales, 481 buns, 221 condiments from dual union all
select 24 storeid , 1 week_nbr, 29347 net_sales, 598 buns, 238 condiments from dual union all
select 24 storeid , 6 week_nbr, 29347 net_sales, 598 buns, 238 condiments from dual union all
select 24 storeid , 7 week_nbr, 29347 net_sales, 598 buns, 238 condiments from dual union all
select 25 storeid , 1 week_nbr, 17637 net_sales, 360 buns, 165 condiments from dual union all
select 25 storeid , 6 week_nbr, 17637 net_sales, 360 buns, 165 condiments from dual union all
select 25 storeid , 7 week_nbr, 17637 net_sales, 360 buns, 165 condiments from dual union all
select 27 storeid , 1 week_nbr, 22010 net_sales, 405 buns, 172 condiments from dual union all
select 27 storeid , 6 week_nbr, 22010 net_sales, 405 buns, 172 condiments from dual union all
select 27 storeid , 7 week_nbr, 22010 net_sales, 405 buns, 172 condiments from dual union all
select 31 storeid , 1 week_nbr, 16836 net_sales, 345 buns, 168 condiments from dual union all
select 31 storeid , 6 week_nbr, 16836 net_sales, 345 buns, 168 condiments from dual union all
select 31 storeid , 7 week_nbr, 16836 net_sales, 345 buns, 168 condiments from dual union all
select 38 storeid , 1 week_nbr, 28244 net_sales, 524 buns, 247 condiments from dual union all
select 38 storeid , 6 week_nbr, 28244 net_sales, 524 buns, 247 condiments from dual union all
select 38 storeid , 7 week_nbr, 28244 net_sales, 524 buns, 247 condiments from dual union all
select 39 storeid , 1 week_nbr, 21011 net_sales, 407 buns, 238 condiments from dual union all
select 39 storeid , 6 week_nbr, 21011 net_sales, 407 buns, 238 condiments from dual union all
select 39 storeid , 7 week_nbr, 21011 net_sales, 407 buns, 238 condiments from dual union all
select 41 storeid , 1 week_nbr, 18026 net_sales, 430 buns, 179 condiments from dual union all
select 41 storeid , 6 week_nbr, 18026 net_sales, 430 buns, 179 condiments from dual union all
select 41 storeid , 7 week_nbr, 18026 net_sales, 430 buns, 179 condiments from dual union all
select 42 storeid , 1 week_nbr, 24821 net_sales, 466 buns, 212 condiments from dual union all
select 42 storeid , 6 week_nbr, 24821 net_sales, 466 buns, 212 condiments from dual union all
select 42 storeid , 7 week_nbr, 24821 net_sales, 466 buns, 212 condiments from dual union all
select 65 storeid , 1 week_nbr, 13356 net_sales, 281 buns, 136 condiments from dual union all
select 65 storeid , 6 week_nbr, 13356 net_sales, 281 buns, 136 condiments from dual union all
select 65 storeid , 7 week_nbr, 13356 net_sales, 281 buns, 136 condiments from dual union all
select 66 storeid , 1 week_nbr, 15421 net_sales, 337 buns, 155 condiments from dual union all
select 66 storeid , 6 week_nbr, 15421 net_sales, 337 buns, 155 condiments from dual union all
select 66 storeid , 7 week_nbr, 15421 net_sales, 337 buns, 155 condiments from dual union all
select 67 storeid , 1 week_nbr, 28064 net_sales, 625 buns, 283 condiments from dual union all
select 67 storeid , 6 week_nbr, 28064 net_sales, 625 buns, 283 condiments from dual union all
select 67 storeid , 7 week_nbr, 28064 net_sales, 625 buns, 283 condiments from dual union all
select 68 storeid , 1 week_nbr, 22875 net_sales, 493 buns, 238 condiments from dual union all
select 68 storeid , 6 week_nbr, 22875 net_sales, 493 buns, 238 condiments from dual union all
select 68 storeid , 7 week_nbr, 22875 net_sales, 493 buns, 238 condiments from dual union all
select 70 storeid , 1 week_nbr, 26434 net_sales, 562 buns, 248 condiments from dual union all
select 70 storeid , 6 week_nbr, 26434 net_sales, 562 buns, 248 condiments from dual union all
select 70 storeid , 7 week_nbr, 26434 net_sales, 562 buns, 248 condiments from dual union all
select 71 storeid , 1 week_nbr, 14259 net_sales, 297 buns, 133 condiments from dual union all
select 71 storeid , 6 week_nbr, 14259 net_sales, 297 buns, 133 condiments from dual union all
select 71 storeid , 7 week_nbr, 14259 net_sales, 297 buns, 133 condiments from dual union all
select 82 storeid , 1 week_nbr, 24446 net_sales, 469 buns, 210 condiments from dual union all
select 82 storeid , 6 week_nbr, 24446 net_sales, 469 buns, 210 condiments from dual union all
select 82 storeid , 7 week_nbr, 24446 net_sales, 469 buns, 210 condiments from dual union all
select 83 storeid , 1 week_nbr, 13959 net_sales, 280 buns, 104 condiments from dual union all
select 83 storeid , 6 week_nbr, 13959 net_sales, 280 buns, 104 condiments from dual union all
select 83 storeid , 7 week_nbr, 13959 net_sales, 280 buns, 104 condiments from dual union all
select 181 storeid , 1 week_nbr, 13140 net_sales, 273 buns, 136 condiments from dual union all
select 181 storeid , 6 week_nbr, 13140 net_sales, 273 buns, 136 condiments from dual union all
select 181 storeid , 7 week_nbr, 13140 net_sales, 273 buns, 136 condiments from dual union all
select 221 storeid , 1 week_nbr, 27347 net_sales, 546 buns, 289 condiments from dual union all
select 221 storeid , 6 week_nbr, 27347 net_sales, 546 buns, 289 condiments from dual union all
select 221 storeid , 7 week_nbr, 27347 net_sales, 546 buns, 289 condiments from dual union all
select 222 storeid , 1 week_nbr, 16456 net_sales, 379 buns, 148 condiments from dual union all
select 222 storeid , 6 week_nbr, 16456 net_sales, 379 buns, 148 condiments from dual union all
select 222 storeid , 7 week_nbr, 16456 net_sales, 379 buns, 148 condiments from dual union all
select 223 storeid , 1 week_nbr, 20611 net_sales, 439 buns, 165 condiments from dual union all
select 223 storeid , 6 week_nbr, 20611 net_sales, 439 buns, 165 condiments from dual union all
select 223 storeid , 7 week_nbr, 20611 net_sales, 439 buns, 165 condiments from dual union all
select 224 storeid , 1 week_nbr, 21537 net_sales, 420 buns, 173 condiments from dual union all
select 224 storeid , 6 week_nbr, 21537 net_sales, 420 buns, 173 condiments from dual union all
select 224 storeid , 7 week_nbr, 21537 net_sales, 420 buns, 173 condiments from dual union all
select 260 storeid , 1 week_nbr, 19329 net_sales, 380 buns, 196 condiments from dual union all
select 260 storeid , 6 week_nbr, 19329 net_sales, 380 buns, 196 condiments from dual union all
select 260 storeid , 7 week_nbr, 19329 net_sales, 380 buns, 196 condiments from dual union all
select 280 storeid , 1 week_nbr, 20692 net_sales, 512 buns, 202 condiments from dual union all
select 280 storeid , 6 week_nbr, 20692 net_sales, 512 buns, 202 condiments from dual union all
select 280 storeid , 7 week_nbr, 20692 net_sales, 512 buns, 202 condiments from dual union all
select 294 storeid , 1 week_nbr, 26522 net_sales, 481 buns, 252 condiments from dual union all
select 294 storeid , 6 week_nbr, 26522 net_sales, 481 buns, 252 condiments from dual union all
select 294 storeid , 7 week_nbr, 26522 net_sales, 481 buns, 252 condiments from dual union all
select 362 storeid , 1 week_nbr, 20611 net_sales, 317 buns, 221 condiments from dual union all
select 362 storeid , 6 week_nbr, 20611 net_sales, 317 buns, 221 condiments from dual union all
select 362 storeid , 7 week_nbr, 20611 net_sales, 317 buns, 221 condiments from dual union all
select 501 storeid , 1 week_nbr, 28337 net_sales, 518 buns, 273 condiments from dual union all
select 501 storeid , 6 week_nbr, 28337 net_sales, 518 buns, 273 condiments from dual union all
select 501 storeid , 7 week_nbr, 28337 net_sales, 518 buns, 273 condiments from dual union all
select 521 storeid , 1 week_nbr, 26118 net_sales, 438 buns, 257 condiments from dual union all
select 521 storeid , 6 week_nbr, 26118 net_sales, 438 buns, 257 condiments from dual union all
select 521 storeid , 7 week_nbr, 26118 net_sales, 438 buns, 257 condiments from dual union all
select 524 storeid , 1 week_nbr, 31929 net_sales, 582 buns, 247 condiments from dual union all
select 524 storeid , 6 week_nbr, 31929 net_sales, 582 buns, 247 condiments from dual union all
select 524 storeid , 7 week_nbr, 31929 net_sales, 582 buns, 247 condiments from dual
, store_data as
select 27 storeid, 'County Gate' storename , '5601' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 67 storeid, 'N. Jackson' storename , '0177' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 68 storeid, 'Dyersburg' storename , '0277' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 280 storeid, 'Poplar Ave.' storename , '3080' storenbr , 'R1-Roosevelt' regionname , 'D12-Smart' districtname , 'VMS' companyname from dual union all
select 294 storeid, 'Goodman Rd' storename , '5702' storenbr , 'R1-Roosevelt' regionname , 'D12-Smart' districtname , 'VMS' companyname from dual union all
select 25 storeid, 'Germantown' storename , '5094' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 181 storeid, 'Mendehall' storename , '4090' storenbr , 'R1-Roosevelt' regionname , 'D12-Smart' districtname , 'VMS' companyname from dual union all
select 31 storeid, 'Winchester' storename , '2684' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 41 storeid, 'Washington' storename , '4190' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 42 storeid, 'Cordova' storename , '4393' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 70 storeid, 'S. Jackson' storename , '0679' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 221 storeid, 'Jackson' storename , '5500' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 223 storeid, 'Highway 51' storename , '3485' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 66 storeid, 'New Summer' storename , '2980' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 82 storeid, 'Navy Road' storename , '1476' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 224 storeid, 'New Covington' storename , '5397' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 501 storeid, 'Kirby Quince' storename , '6504' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 22 storeid, 'Wchstr/Good' storename , '2385' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 23 storeid, 'Union Ave' storename , '1275' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 24 storeid, 'West Poplar' storename , '4290' storenbr , 'R1-Roosevelt' regionname , 'D11-Wilcox' districtname , 'VMS' companyname from dual union all
select 222 storeid, 'Thomas St.' storename , '1977' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 362 storeid, 'Wolfchase' storename , '5802' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 524 storeid, 'Houston Levee' storename , '6705' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 521 storeid, 'G-Town/I-40' storename , '6604' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 38 storeid, 'Horn Lake' storename , '4994' storenbr , 'R1-Roosevelt' regionname , 'D12-Smart' districtname , 'VMS' companyname from dual union all
select 39 storeid, 'Macon/Syc' storename , '2885' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 65 storeid, 'Poplar/Fenwick' storename , '2581' storenbr , 'R1-Roosevelt' regionname , 'D13-Bowser' districtname , 'VMS' companyname from dual union all
select 71 storeid, 'Humboldt' storename , '0785' storenbr , 'R1-Roosevelt' regionname , 'D14-Sandus' districtname , 'VMS' companyname from dual union all
select 83 storeid, 'Mt. Moriah' storename , '1174' storenbr , 'R1-Roosevelt' regionname , 'D15-Rickard' districtname , 'VMS' companyname from dual union all
select 260 storeid, 'Getwell' storename , '1576' storenbr , 'R1-Roosevelt' regionname , 'D12-Smart' districtname , 'VMS' companyname from dual
select decode(gc,0,companyname, 'VanderbiltFoods') as companyname
, decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')) as regionname
, decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods'))) as districtname
, decode(gs,0,storenbr,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storenbr
, decode(gs,0,storename,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storename
, net_sales
, buns
, condiments
from ( select companyname
, grouping(companyname) gc
, regionname
, grouping(regionname) gr
, districtname
, grouping(districtname) gd
, storenbr
, grouping(storenbr) gs
, max(storename) storename
, sum(net_sales) net_sales
, sum(buns) buns
, sum(condiments) condiments
from store_data stdata
inner join sample_data sampdata on sampdata.storeid = stdata.storeid
group by rollup(companyname, regionname, districtname, storenbr), week_nbr
order by companyname nulls first,gc desc, regionname nulls first, gr desc, districtname nulls first, gd desc,storenbr nulls first, gs desc
/* --== INCOMPLETE CODE --
--== GET TABLE OF CONTENTS In same order as first cursor
open pc_report_data for
select rownum as sortcol
, storenbr
, storename)
BULK COLLECT INTO pc_TOC
END create_rpt_and_toc;I don't know sQL developer well enough to view cursor results from stored procedure
but here is test code from debugger window
DECLARE
PC_REPORT_DATA sys_refcursor;
PC_TOC sys_refcursor;
BEGIN
CREATE_RPT_AND_TOC(
PC_REPORT_DATA => PC_REPORT_DATA,
PC_TOC => PC_TOC
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('PC_REPORT_DATA = ' || PC_REPORT_DATA);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('PC_TOC = ' || PC_TOC);
END;I am currently doing this in the presentation layer but is a lot cleaner and easier to maintain if handled in DB
I'd googled that suggested this was possible. I had decided on the FETCH. But I've been to avoid FETCH and LOOP
wherever possible.
One eample I found: I always try so much stuff, I forget where i got the idea) was:
-- pseudoscript
FETCH outer cursor.
Select outer cursor
open second cursor for select into and CLOSE Cursor.
LOOPI also found this.
create or replace procedure testproc(c_test out sys_refcursor) is
begin
open c_test for select first_name, last_name, email from employees where rownum < 10;
end;Here though, its a simple select from a table vs. a cursor.
I thouht it was woth asking the question. -
Hi,
I have a doubt in the code mentioned below ..indicated in the code by
" -- id shoud be the value fetched from variable v_samp;".
I am not sure of how I get the value into the ref cursor from the variable
declare
Cursor C1
Is Select Table_Name,Rownum R_Num From User_Tables Where Table_Name Like 'T%' Order By Table_Name;
Cursor C2 Is Select Sample From code_tbl;
Type Ref1 Is Ref Cursor;
R_1 Ref1;
Type T_Samp Is Table Of Varchar2(100);
Lv_Samp T_Samp;
lv_geno T_Samp;
Begin
For L1 in C1 loop
V_tbl := L1.table_name;
For L2 In C2 Loop
V_samp := L2.sample;
Open R_1 for 'Select sample_id, genotype from ' || V_tbl || ' where id = ? '; -- id shoud be the value fetched from variable v_samp;
Loop
Fetch R_1 Bulk Collect Into Lv_Samp,Lv_Geno Limit 10000;
FOR indx IN 1 .. lv_samp.COUNT
Loop
V1 := V1 || lv_geno(indx);
End Loop;
EXIT WHEN Lv_samp.COUNT = 0;
end loop;
end loop;
end loop;
end;
ThanksSorry about my approach..I did that using tool. I don't know how to keep it..I do apologize if I did hurt you..
This is my complete requirement...
For every sample in table all_f if it exists in table t1
then the output should be the concatenated value of type
for the corresponding sample. Let me know if I need to do anything else..There are million types for every sample.
The output should be
'AB35652626-G8' 1 1 1 1 1 1 1 1 1 1 0 0
since only this id exists in c3 (table t1).
This is just a sample...I have huge number of rows to be concatenated for multiple id's.
So that is the reason why I don't want to do any processing in the loop except concatenation.
DDL's and DML's are as follows :
create table all_f (sample varchar2(20), typeo varchar2(20));
insert into all_f (SAMPLE, typeo)
values ('AB35053903-C10', '2');
insert into all_f (SAMPLE, typeo)
values ('AB35053995-A10', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35054283-C3', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35054582-A7', '2');
insert into all_f (SAMPLE, typeo)
values ('AB35055053-H12', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35055158-B2', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35500856-F4', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35501332-G11', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35501428-B9', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35504972-F11', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35505551-H7', '2');
insert into all_f (SAMPLE, typeo)
values ('AB35506138-G5', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35507097-C11', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35507190-G9', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35561723-H10', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35651275-E6', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35896175-C8', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35897805-A3', '2');
insert into all_f (SAMPLE, typeo)
values ('AB35899249-H8', '1');
insert into all_f (SAMPLE, typeo)
values ('AB35899918-H6', '1');
insert into t1 (SAMPLE, TYPEO)
values ('AB35652626-G8', '1');
commit;
create table t1 (sample_id varchar2(20), type varchar2(20));
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '1');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '0');
insert into t1 (SAMPLE_ID, TYPE)
values ('AB35652626-G8', '0');
Thanks,
Maybe you are looking for
-
USB 6009 DAQ to use in Simulink at External mode with DAQ toolbox
hi Currently I am using usb 6009 daq board for data acquisition in using simulink. I have created a model with taking analog input from data acquisition toolbox. Then when i want to run in external mode and try to connet to target, the following erro
-
I can't download any music or transfer at all is
When I download from iTunes it just says download error, tap to retry. But it still doesn't work, none of my music from iPhone will transfer either. Although no music will download I did download a book from iTunes the other day.
-
Why don't standard XPath functions work in XSLT?
I'm having a lot of trouble trying to do some simple string processing in XSLT. What I would like to do is make selection using the standard xpath functions defined by the w3c. I'm using this as my cheat sheet: http://w3schools.com/xpath/xpath_functi
-
What mode to use????
I have OT Pro, and have a 101 mg movie file I wish to email. I tried converting using Windows Media, but it only renders the first 10 seconds of the clip! How can I elongate this time??? And what IS the best file type to use in this case???
-
When I forward an email the main body comes up blank
When I try to forward an email the main body and attachment comes up blank. == This happened == Every time Firefox opened == when I updated