Need help in optimizing the query with joins and group by clause

I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
CREATE TABLE FILE_STATUS
(FILE_ID VARCHAR2(14),
FILE_NAME VARCHAR2(20),
CARR_CD VARCHAR2(5),
TOT_REC NUMBER,
TOT_SUCC NUMBER);
CREATE TABLE COMM
(SRC_FILE_ID VARCHAR2(14),
REC_ID NUMBER,
STATUS CHAR(1));
INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
INSERT INTO COMM VALUES ('12345678', 1, 'T');
INSERT INTO COMM VALUES ('12345678', 3, 'T');
INSERT INTO COMM VALUES ('12345678', 4, 'P');
INSERT INTO COMM VALUES ('12345678', 5, 'P');
COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
SELECT
    FS.CARR_CD
    ,FS.FILE_NAME
    ,FS.FILE_ID
    ,FS.TOT_REC
    ,FS.TOT_SUCC
    ,NVL(C.TOT_TRANS, 0) TOT_TRANS
FROM FILE_STATUS FS
LEFT JOIN
    SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
    FROM COMM
    WHERE STATUS = 'T'
    GROUP BY SRC_FILE_ID
) C ON C.SRC_FILE_ID = FS.FILE_ID
WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!

I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
  from (select fs.carr_cd,
               fs.file_name,
               fs.file_id,
               fs.tot_rec,
               fs.tot_succ,
               count(case
                        when c.status = 'T' then
                         1
                        else
                         null
                      end) over(partition by c.src_file_id) tot_trans,
               row_number() over(partition by c.src_file_id order by null) rn
          from file_status fs
          left join comm c
            on c.src_file_id = fs.file_id
         where carr_cd = 'LIBM')
where rn = 1;
CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
LIBM    CM_LIBM.TXT          12345678                5          4          2
LIBM    CM_LIBM.TXT          12345677               10          0          0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
select fs.carr_cd,
       fs.file_name,
       fs.file_id,
       fs.tot_rec,
       fs.tot_succ,
       count(case
                when c.status = 'T' then
                 1
                else
                 null
              end) over(partition by c.src_file_id) tot_trans,
       row_number() over(partition by c.src_file_id order by null) rn
from file_status fs
left join comm c
on c.src_file_id = fs.file_id
where carr_cd = 'LIBM';
CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS         RN
LIBM    CM_LIBM.TXT          12345678                5          4          2          1
LIBM    CM_LIBM.TXT          12345678                5          4          2          2
LIBM    CM_LIBM.TXT          12345678                5          4          2          3
LIBM    CM_LIBM.TXT          12345678                5          4          2          4
LIBM    CM_LIBM.TXT          12345677               10          0          0          1

Similar Messages

  • Tune the query with join and not exists

    This is on 10g R2.
    I have a query similar to :
    Select A.*, C.*
    From A inner join B on A.id = B.id
    Left join C on A.kid = C.kid
    Where not exists
    (select * from D where A.fid = D.fid and A.stat = 2);
    I want avoiding to use the NOT EXISTS in the last part of the query
    I tried the autotrace explain of above and compared with others format and found no better execution plan than that. The explain plan indicated that there were long "table access full" operation on B, due to its little huge records, and a long operation of the "NESTED LOOPS OUTER". I had tried to replace the NOT EXISTS part with another LEFT JOIN in the FROM, but it went worse. So Anyone can suggest a better way? or it is the most efficient query I can get?

    Here is the tkprof output
    from baandb.ttfacr200201 a
       inner join baandb.ttfgld106201 c on (a.t$ttyp = c.t$otyp and a.t$ninv = c.t$odoc) and c.t$leac like :"SYS_B_0"
       left join baandb.ttfgld910201 d on c.t$dim2 = d.t$dimx and d.t$dtyp = :"SYS_B_1"
       where not exists
        (select * from baandb.tcisli205201 b
         where a.t$ttyp = b.t$ityp and a.t$ninv = b.t$idoc)
         and (a.t$trec = :"SYS_B_2" or a.t$trec = :"SYS_B_3" and t$tdoc = :"SYS_B_4")
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.01       0.01          0          0          0           0
    Fetch        5      1.06      52.11      29925      45943          0          54
    total        7      1.07      52.12      29925      45943          0          54
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 31
    Rows     Row Source Operation
         54  HASH JOIN RIGHT ANTI (cr=45943 pr=29925 pw=0 time=2317005 us)
       9957   INDEX FAST FULL SCAN TCISLI205201$IDX1 (cr=39 pr=0 pw=0 time=54 us)(object id 16639)
      10067   NESTED LOOPS OUTER (cr=45904 pr=29925 pw=0 time=68531937 us)
      10067    HASH JOIN  (cr=35837 pr=29925 pw=0 time=68471521 us)
      10420     TABLE ACCESS FULL TTFACR200201 (cr=2424 pr=0 pw=0 time=20894 us)
      33156     TABLE ACCESS FULL TTFGLD106201 (cr=33413 pr=29925 pw=0 time=117767552 us)
         51    INDEX UNIQUE SCAN TTFGLD910201$IDX1 (cr=10067 pr=0 pw=0 time=53177 us)(object id 20402)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute      3      0.02       0.02          0          0          0           0
    Fetch        6      1.06      52.11      29925      45943          0          55
    total       11      1.08      52.14      29925      45943          0          55

  • Plz help in optimizing the query

    I have a query which is written to cater to the scenario that the entered start and end date do not overlap with the start and end date already present in the database records. Can someone help in optimizing this query. all inclusion and exclusion scenario's have to be taken care of.
    the query is as follows:
    SELECT COUNT(*) FROM CLAS WHERE TRIM(UPPER(CLAS_CDE)) =UPPER('timecheck') AND TRIM(UPPER(CLAS_TYPE_CDE))=UPPER('TEST_3')
    AND TRIM(UPPER(LANG_CDE))=UPPER('en')
    AND (
    (END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
    OR
    (START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
    OR (
    (START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
    AND
    (END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
    OR(('09/13/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
    AND ('09/15/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
    );

    I format your code in different way:
    SELECT COUNT(*)
    FROM CLAS
    WHERE TRIM(UPPER(CLAS_CDE)) = UPPER('timecheck')
    AND TRIM(UPPER(CLAS_TYPE_CDE))=UPPER('TEST_3')
      AND TRIM(UPPER(LANG_CDE))=UPPER('en')
       AND (
         (END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
            OR
         (START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
            OR (
              (START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
              AND
              (END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
         OR (
              ('09/13/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
              AND
              ('09/15/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
          );First thought that cross my mind it to check if changing this:
    UPPER('timecheck') to simple:
    'TIMECHECK' and do the same with other expressions with UPPER function.
    Peter D.

  • Need complex query  with joins and AGGREGATE  functions.

    Hello Everyone ;
    Good Morning to all ;
    I have 3 tables with 2 lakhs record. I need to check query performance.. How CBO rewrites my query in materialized view ?
    I want to make complex join with AGGREGATE FUNCTION.
    my table details
    SQL> select from tab;*
    TNAME TABTYPE CLUSTERID
    DEPT TABLE
    PAYROLL TABLE
    EMP TABLE
    SQL> desc emp
    Name
    EID
    ENAME
    EDOB
    EGENDER
    EQUAL
    EGRADUATION
    EDESIGNATION
    ELEVEL
    EDOMAIN_ID
    EMOB_NO
    SQL> desc dept
    Name
    EID
    DNAME
    DMANAGER
    DCONTACT_NO
    DPROJ_NAME
    SQL> desc payroll
    Name
    EID
    PF_NO
    SAL_ACC_NO
    SALARY
    BONUS
    I want to make  complex query  with joins and AGGREGATE  functions.
    Dept names are : IT , ITES , Accounts , Mgmt , Hr
    GRADUATIONS are : Engineering , Arts , Accounts , business_applications
    I want to select records who are working in IT and ITES and graduation should be "Engineering"
    salary > 20000 and < = 22800 and bonus > 1000 and <= 1999 with count for males and females Separately ;
    Please help me to make a such complex query with joins ..
    Thanks in advance ..
    Edited by: 969352 on May 25, 2013 11:34 AM

    969352 wrote:
    why do you avoid providing requested & NEEDED details?I do NOT understand what do you expect ?
    My Goal is :
    1. When executing my own query i need to check expalin plan.please proceed to do so
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9010.htm#SQLRF01601
    2. IF i enable query rewrite option .. i want to check explain plan ( how optimizer rewrites my query ) ? please proceed to do so
    http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF009
    3. My only aim is QUERY PERFORMANCE with QUERY REWRITE clause in materialized view.It is an admirable goal.
    Best Wishes on your quest for performance improvements.

  • Need help in refining the query

    Hello Experts,
    Need your help in refining the query further more.
    table structure 
    Mskey  Col A Col B
    1   empno [20141127-20151128]1234
    1   empno [20151201-99991231]232544
    1   salutation [20141127-99991231]Mrs
    1   salutation [20151127-99991231]Mr
    2   empno [20141127-20151128]1234
    2   empno [20151201-99991231]232544
    2   salutation [20141127-99991231]Mrs
    2   salutation [20151127-99991231]Mr
    My requirement is to find the list of overlapping records based on the dates
    user details may be varying from time to time as new data would be pushed through HR systems to identity store via an interface.
    The job is getting failed whenever there is any overlapping with dates. So we proactively decided to schedule a job in this regards which runs weekly and would let us know for which and all the users there is overlapping dates are there, so that we can send the list to HR team for pushing new data.
    Overlapping Issue Example:
    The users employee id for an year it is 1234 and later he moved to another department and his employee id got changed and it became 2345 remaining all details are same. So the HR systems send the data for this user as empno - [20141127-20151128]1234 and empno - [20151201-99991231]232544
    it means from 20141127 to 20151128 his employee no is 1234 and from 20151201 to 99991231 his employee would be 2345.
    This is a correct case and the tool would accept this data.
    the below cases are invald
    Case 1: 1 salutation [20141127-99991231]Mrs 1 salutation [20151127-99991231]Mr
    Case 2: 2 salutation [20141127-99991231]Mrs 2 salutation [20141127-99991231]Mr
    So we wanted to find these overlapping records from tables.
    My Query:
    I am able to successfully write query for the case 2 type but unable to write for case1.
    select id,colA
    count(left(ColB,CHARINDEX(']',ColB))) as 'Count'
    from tblA with (nolock)
    where id in (Select distinct id from tblb with (nolock))
    group by id, cola,left(ColB,CHARINDEX(']',ColB))
    having count(left(ColB,CHARINDEX(']',ColB)))>1

    Finally got the required answer with the below query
    WITH Cte AS
    SELECT ID,ColA,ColB,ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS RN,
    CAST(SUBSTRING(ColB,2,CHARINDEX('-',ColB)-2) AS DATE) AS StartDT,
    CAST(SUBSTRING(ColB,CHARINDEX('-',ColB)+1,8) AS DATE)  AS EndDT  FROM TblA
    SELECT c1.ID, c1.ColA,c1.ColB
    FROM Cte c1 JOIN Cte c2
    ON c1.RN != c2.RN
    AND c1.ID=c2.ID
    AND c1.ColA=c2.ColA
    AND (c1.StartDT BETWEEN c2.StartDT AND c2.EndDT OR c2.StartDT BETWEEN c1.StartDT AND c1.EndDT )

  • Need help in optimizing the process

    I need help in optimizing my process. Here is what am I doing:
    I have two tables table A and table B. table A has list of names and table B has name and ID. Right now I am loading name into cursor from table A and for each name from the cursor I try to match with name in table B to get the ID. This process takes very long to complete. I need help to replace PL/SQL with SQL if possible. I am using oracle utl_match to match the best possible record in table B. table B sometimes returns multiple matching records. I take the top nearest match name and ID for my use (there is not always one to one match)
    Any idea or help will be appreciated. Thanks

    always provide create table and sample data instert statements when asking a question. also, provide your database version.
    because you're using utl_match, you can't really use an index, there must be a cartesian join on the two tables so it may always be slow.
    however, here's a sample SQL that you may be able to make use of:
    with n as (select 'KATHERINE' person_name from dual
                 union all
                 select 'STEVE' from dual
                 union all
                 select 'BRUCE' from dual)
        ,nid as (select 'CATHERINE' person_name, 1 NID FROM DUAL
                 union all
                 select 'STEFAN', 2 from dual
                 UNION ALL
                 select 'STEVEN', 2 from dual
                 union all
                 select 'CATHY',3 from dual)
    select n_name, nid
      from (
            select n.person_name N_NAME
                  ,nid.person_name
                  ,nid.nid
                  ,ROW_NUMBER() OVER (partition by n.person_name ORDER BY utl_match.jaro_winkler_similarity(n.person_name,nid.person_name) DESC) jws_ORDER
              from n
              join nid on (utl_match.jaro_winkler_similarity(n.person_name,nid.person_name) > 70)
      where jws_order = 1;    

  • Hello friends like everybody? I need help, I have the CC version 2014 and I can not ge "extract filter" because I get the following message:   "Could not complete the Extract command, this version of Photoshot not offer the services required by the Plugin

    I need help, i have the CC 2014 and  i can npt get to associate the "extract filter"

    How did you get the Extract filter into Photoshop CC?  You will need to undo that - especially if you copied a whole batch of plug-ins supplied by Adobe with an earlier version.
    -Noel

  • Need help in tunnig the query

    Experts,
    Plz help in tuning this query
    SELECT
    DECODE(WSH_DELIVERY_DETAILS.LOT_NUMBER,'5I27164/1U',1, TO_NUMBER(SUBSTR(WSH_DELIVERY_DETAILS.LOT_NUMBER, (LENGTH(WSH_DELIVERY_DETAILS.LOT_NUMBER) - INSTR(REVERSE(WSH_DELIVERY_DETAILS.LOT_NUMBER),'/') + 2), (INSTR(REVERSE(WSH_DELIVERY_DETAILS.LOT_NUMBER),'/')-1))) ) AS NO_OF_PLATES,
         P_FORM.DESCRIPTION FORMOFPRODUCT,
    HZ_PARTIES.PARTY_NAME CUSTOMER, HZ_CUST_ACCOUNTS.ACCOUNT_NUMBER ACCT_NUM,
         NVL(OE_ORDER_HEADERS_ALL.CUST_PO_NUMBER,'XXXX') CUST_PO,
         INITCAP(HZ_PARTIES.ADDRESS1) BILL_ADD1,
    INITCAP(HZ_PARTIES.ADDRESS2) BILL_ADD2,
    INITCAP(HZ_PARTIES.ADDRESS3) BILL_ADD3,
    INITCAP(HZ_PARTIES.ADDRESS4) BILL_ADD4,
         INITCAP(HZ_PARTIES.CITY) BILL_CITY,
    INITCAP(HZ_PARTIES.STATE) BILL_STATE,
    HZ_PARTIES.POSTAL_CODE BILL_PC,
         INITCAP(HZ_LOCATIONS.ADDRESS1) SHIP_ADD1,
    INITCAP(HZ_LOCATIONS.ADDRESS2) SHIP_ADD2,
    INITCAP(HZ_LOCATIONS.ADDRESS3) SHIP_ADD3,
    INITCAP(HZ_LOCATIONS.ADDRESS4) SHIP_ADD4,
         INITCAP(HZ_LOCATIONS.CITY) SHIP_CITY,
    INITCAP(HZ_LOCATIONS.STATE) SHIP_STATE,
    HZ_LOCATIONS.POSTAL_CODE SHIP_PC,
         OE_TRANSACTION_TYPES_TL.NAME CATEGORY ,
         OE_ORDER_HEADERS_ALL.ORDER_NUMBER,
    OE_ORDER_HEADERS_ALL.SOURCE_DOCUMENT_ID,
    OE_ORDER_HEADERS_ALL.HEADER_ID,
    OE_ORDER_HEADERS_ALL.FREIGHT_TERMS_CODE,
    /* to_char(oe_order_headers_all.ORDERED_DATE,'DD-MON-RR HH24:MI:SS') ORDER_DATE,*/
    to_char(sysdate,'DD/MM/RRRR HH24:MI:SS') ORDERED_DATE,
         ROWNUM,
    OE_ORDER_LINES_ALL.INVENTORY_ITEM_ID,
         OE_ORDER_LINES_ALL.ORDERED_ITEM,
         OE_ORDER_LINES_ALL.ORDERED_QUANTITY,
         WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY+DECODE(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID,129881,.22,0) AS SHIPPED_QUANTITY1, (WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY+DECODE(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID,129881,.22,0))*OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE AS LINE_PRICE,
         OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE,
         JA_IN_RG_I.FOR_HOME_USE_PAY_ED_VAL,
    ----      SUBSTR(JA_IN_RG_I.EXCISE_INVOICE_NUMBER,1,2)|| SUBSTR(JA_IN_RG_I.EXCISE_INVOICE_NUMBER,4,8) INVOICE_NO,
         JA_IN_RG_I.EXCISE_INVOICE_NUMBER INVOICE_NO,
    to_char(JA_IN_RG_I.CREATION_DATE,'DD/MM/RRRR') INVOICE_DATE1,
         to_char(JA_IN_RG_I.EXCISE_INVOICE_DATE,'DD-MON-RR HH24:MI:SS') INV_DATE,
         to_char(JA_IN_RG_I.CREATION_DATE,'DD/MM/RRRR HH24:MI:SS') INVOICE_DATE,
         JA_IN_RG_I.EXCISE_DUTY_RATE,
         JA_IN_RG_I.EXCISE_DUTY_AMOUNT,
         WSH_DELIVERY_DETAILS.LOT_NUMBER,
    WSH_TRIPS.CARRIER_ID CARRIER_ID,
    WSH_TRIPS.VEHICLE_NUM_PREFIX,
    WSH_TRIPS.SEAL_CODE,
    WSH_TRIPS.ROUTING_INSTRUCTIONS,
    WSH_TRIPS.OPERATOR, WSH_NEW_DELIVERIES. DELIVERY_ID,
    WSH_NEW_DELIVERIES. ADDITIONAL_SHIPMENT_INFO TRUCK_NO,
         WSH_TRIPS.MODE_OF_TRANSPORT VEHICLE_TYPE,
    WSH_TRIPS.ATTRIBUTE6||' '|| WSH_TRIPS.ATTRIBUTE7||' '|| WSH_TRIPS.ATTRIBUTE8 REMARKS,
         WSH_TRIPS.ATTRIBUTE1 LR_NO, WSH_TRIPS.ATTRIBUTE7,
         WSH_TRIPS.ATTRIBUTE2 LR_DATE,
         DECODE(WSH_TRIPS.ATTRIBUTE3, '', '', 'ARE NO '||WSH_TRIPS.ATTRIBUTE3) AS ARE_NO,
         DECODE(WSH_TRIPS.ATTRIBUTE6, '', '', WSH_TRIPS.ATTRIBUTE6) AS REMARK1,
         DECODE(WSH_TRIPS.ATTRIBUTE4, '', '', 'R.P. NO. ' ||WSH_TRIPS.ATTRIBUTE4) AS PERMIT,
         DECODE(WSH_TRIPS.ATTRIBUTE5, '', '', 'Export Under '||WSH_TRIPS.ATTRIBUTE5) AS EXPORT_UNDER,
         DECODE(WSH_NEW_DELIVERIES.PORT_OF_DISCHARGE,'','', 'Seal No : '||WSH_NEW_DELIVERIES.PORT_OF_DISCHARGE) AS SEAL_NO,
         DECODE(WSH_NEW_DELIVERIES.DESCRIPTION, '', '', 'Container No : ' ||WSH_NEW_DELIVERIES.DESCRIPTION) AS CONTAINER_NO,
         MTL_SYSTEM_ITEMS_B.ATTRIBUTE4 AS EXCISE_TARIFF_NO,
         --MTL_SYSTEM_ITEMS_B.DESCRIPTION,
         HZ_CUST_ACCOUNTS.ACCOUNT_NUMBER,
         JSW_LOT_PACKSLIP.PACKSLIP_NO PACKSLIP,
         PR_TYPE.DESCRIPTION ||' ,'||
         P_FORM.DESCRIPTION || ' ,'||
         PR_GRADE.DESCRIPTION ||' ,'||
         PR_QTY.DESCRIPTION || ' ,'||
         DECODE(SUBSTR(PR_STL.DESCRIPTION,1,3),'Not','', PR_STL.DESCRIPTION) DESCRIPTION ,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE7 S_CST_NO,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE6 S_LST_NO,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE5 S_ECC_NO,
    A.ATTRIBUTE7 B_CST_NO,
    A.ATTRIBUTE6 B_LST_NO,
    INTERFACECRM.JSW_MES_COMMON_TNGL_T.JSW_ADDMINUTES(WSH_TRIPS.VEHICLE_NUM_PREFIX) POSTFIX_NUM
    FROM -- jsw_vat_slno,
         MTL_PARAMETERS,
         HZ_PARTIES,
         HZ_CUST_ACCOUNTS,
         HZ_LOCATIONS,
         HZ_PARTY_SITES,
         HZ_CUST_ACCT_SITES_ALL,
         HZ_CUST_SITE_USES_ALL,
    HZ_CUST_ACCT_SITES_ALL A,
    HZ_CUST_SITE_USES_ALL B,
         OE_TRANSACTION_TYPES_TL,
         JA_IN_RG_I,
         WSH_DELIVERY_DETAILS,
         OE_ORDER_LINES_ALL,
         OE_ORDER_HEADERS_ALL,
         WSH_DELIVERY_ASSIGNMENTS,
         WSH_NEW_DELIVERIES,
         WSH_DELIVERY_LEGS,
         WSH_TRIP_STOPS,
         WSH_TRIPS,
         MTL_SYSTEM_ITEMS_B,
         JSW_LOT_PACKSLIP,
         IC_TRAN_PND,
                   JSW_ITM_SEARCH_PRD_TYP          PR_TYPE,
              JSW_ITM_SEARCH_PRD_FRM          P_FORM     ,
                   JSW_ITM_SEARCH_PRD_GRD          PR_GRADE,      
              JSW_ITM_SEARCH_QUALITY_LEVEL PR_QTY,      
                   JSW_ITEM_SEARCH_SLITTING      PR_STL
    WHERE /* jsw_vat_slno.excise_invoice_number=ja_in_rg_i.excise_invoice_number and jsw_vat_slno.organization_id = ja_in_rg_i.organization_id */
    HZ_PARTIES.PARTY_ID = HZ_CUST_ACCOUNTS.PARTY_ID
         AND HZ_CUST_ACCOUNTS.CUST_ACCOUNT_ID = OE_ORDER_HEADERS_ALL.SOLD_TO_ORG_ID
         AND OE_ORDER_HEADERS_ALL.SHIP_TO_ORG_ID = HZ_CUST_SITE_USES_ALL.SITE_USE_ID
         AND HZ_CUST_SITE_USES_ALL.CUST_ACCT_SITE_ID = HZ_CUST_ACCT_SITES_ALL.CUST_ACCT_SITE_ID
    AND OE_ORDER_HEADERS_ALL.INVOICE_TO_ORG_ID = B.SITE_USE_ID
         AND B.CUST_ACCT_SITE_ID                          = A.CUST_ACCT_SITE_ID
         AND HZ_CUST_ACCT_SITES_ALL.PARTY_SITE_ID      = HZ_PARTY_SITES.PARTY_SITE_ID
         AND HZ_PARTY_SITES.LOCATION_ID = HZ_LOCATIONS.LOCATION_ID
         AND OE_ORDER_LINES_ALL.SHIP_FROM_ORG_ID = MTL_PARAMETERS.ORGANIZATION_ID
         AND OE_ORDER_HEADERS_ALL.ORDER_TYPE_ID = OE_TRANSACTION_TYPES_TL.TRANSACTION_TYPE_ID
    and upper(oe_transaction_types_tl.description) not like '%SUP%'
         AND OE_ORDER_HEADERS_ALL.HEADER_ID = WSH_DELIVERY_DETAILS.SOURCE_HEADER_ID
         AND OE_ORDER_HEADERS_ALL.HEADER_ID = OE_ORDER_LINES_ALL.HEADER_ID
         AND OE_ORDER_LINES_ALL.LINE_ID = WSH_DELIVERY_DETAILS.SOURCE_LINE_ID
         AND TO_CHAR(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID ) = JA_IN_RG_I.REF_DOC_ID
         AND WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID = WSH_DELIVERY_ASSIGNMENTS.DELIVERY_DETAIL_ID
         AND WSH_DELIVERY_ASSIGNMENTS.DELIVERY_ID = WSH_NEW_DELIVERIES.DELIVERY_ID
         AND WSH_NEW_DELIVERIES.DELIVERY_ID = WSH_DELIVERY_LEGS.DELIVERY_ID
         AND WSH_DELIVERY_LEGS.PICK_UP_STOP_ID = WSH_TRIP_STOPS.STOP_ID
         AND WSH_TRIP_STOPS.TRIP_ID                = WSH_TRIPS.TRIP_ID
    /* Input parameter can be either Invoice number or Delivery Id */
         AND (WSH_NEW_DELIVERIES.DELIVERY_ID = :DEL_ID OR JA_IN_RG_I.EXCISE_INVOICE_NUMBER = :INVOICE_NUMBER)
         AND NVL(WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY,0) <>0
         AND     MTL_SYSTEM_ITEMS_B.ORGANIZATION_ID     = WSH_DELIVERY_DETAILS.ORGANIZATION_ID
         AND     MTL_SYSTEM_ITEMS_B.INVENTORY_ITEM_ID = WSH_DELIVERY_DETAILS.INVENTORY_ITEM_ID
         AND IC_TRAN_PND.LINE_DETAIL_ID               = WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID
         AND     JSW_LOT_PACKSLIP.LOT_ID                    = IC_TRAN_PND.LOT_ID(+)
         AND     JSW_LOT_PACKSLIP.DELIVERY_ID          = WSH_NEW_DELIVERIES.DELIVERY_ID(+)
         AND      IC_TRAN_PND.LINE_ID                    = OE_ORDER_LINES_ALL.LINE_ID                                                  
         AND     IC_TRAN_PND.DELETE_MARK                = 0
         AND IC_TRAN_PND.COMPLETED_IND      = 1
         AND      IC_TRAN_PND.STAGED_IND                    =     1
         AND     P_FORM.CODE(+)                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,3,2)
         AND     PR_TYPE.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,1,2)
         AND     PR_TYPE.CODE                                   = P_FORM.PRD_TYPE_CODE
         AND     P_FORM.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,3,2)
    AND     P_FORM.CODE                                   = PR_GRADE.PRD_FRM_CODE
         AND     PR_GRADE.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,5,2)     
         AND     PR_GRADE.CODE                                   = PR_QTY.PRD_GRD_CODE
         AND     PR_QTY.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,7,2)
         AND     PR_STL.PROD_CODE                              = PR_TYPE.CODE
         AND     PR_STL.QUALITY_LEVEL_CODE                    = PR_QTY.CODE
         AND     PR_STL.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,9,2)
         AND rownum=1
    thanks,
    baskar.l

    Here is the explain plan
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1 | 920 | 12628 |
    | 1 | COUNT STOPKEY | | | | |
    | 2 | NESTED LOOPS | | 1 | 920 | 12628 |
    | 3 | NESTED LOOPS | | 1 | 728 | 12627 |
    | 4 | NESTED LOOPS | | 1 | 718 | 12626 |
    | 5 | NESTED LOOPS | | 1 | 684 | 12625 |
    | 6 | NESTED LOOPS | | 1 | 674 | 12624 |
    | 7 | NESTED LOOPS | | 1 | 665 | 12623 |
    | 8 | NESTED LOOPS | | 1 | 655 | 12622 |
    | 9 | NESTED LOOPS | | 1 | 532 | 12621 |
    | 10 | NESTED LOOPS | | 1 | 522 | 12620 |
    | 11 | FILTER | | | | |
    | 12 | NESTED LOOPS OUTER | | | | |
    | 13 | NESTED LOOPS | | 1 | 494 | 12617 |
    | 14 | NESTED LOOPS | | 1 | 477 | 12614 |
    | 15 | NESTED LOOPS | | 1 | 467 | 12611 |
    | 16 | NESTED LOOPS | | 1 | 382 | 12610 |
    | 17 | NESTED LOOPS | | 1 | 366 | 12609 |
    | 18 | NESTED LOOPS | | 1 | 321 | 12606 |
    | 19 | FILTER | | | | |
    | 20 | HASH JOIN OUTER | | | | |
    | 21 | TABLE ACCESS BY INDEX ROWID| IC_TRAN_PND | 1 | 22 | 3 |
    | 22 | NESTED LOOPS | | 1 | 292 | 12601 |
    | 23 | HASH JOIN | | 1 | 270 | 12598 |
    | 24 | NESTED LOOPS | | 4011 | 908K| 6272 |
    | 25 | HASH JOIN | | 4012 | 893K| 6272 |
    | 26 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_GRD | 33 | 759 | 2 |
    | 27 | HASH JOIN | | 20547 | 4113K| 6269 |
    | 28 | TABLE ACCESS FULL | JSW_ITM_SEARCH_QUALITY_LEVEL | 54 | 1296 | 2 |
    | 29 | HASH JOIN | | 24352 | 4304K| 6266 |
    | 30 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_TYP | 7 | 154 | 2 |
    | 31 | HASH JOIN | | 170K| 25M| 6260 |
    | 32 | TABLE ACCESS FULL | JSW_ITEM_SEARCH_SLITTING | 73 | 1971 | 2 |
    | 33 | HASH JOIN | | 44367 | 5719K| 6257 |
    | 34 | HASH JOIN | | 4469 | 410K| 367 |
    | 35 | TABLE ACCESS FULL| OE_TRANSACTION_TYPES_TL | 18 | 846 | 4 |
    | 36 | TABLE ACCESS FULL| OE_ORDER_HEADERS_ALL | 38240 | 1755K| 362 |
    | 37 | TABLE ACCESS FULL | OE_ORDER_LINES_ALL | 379K| 13M| 5761 |
    | 38 | INDEX UNIQUE SCAN | MTL_PARAMETERS_U1 | 1 | 4 | |
    | 39 | TABLE ACCESS FULL | WSH_DELIVERY_DETAILS | 579K| 21M| 5926 |
    | 40 | INDEX RANGE SCAN | IC_TRAN_PND_N1 | 2 | | 2 |
    | 41 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_FRM | 16 | 272 | 2 |
    | 42 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 12 | 2 |
    | 43 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 |
    | 44 | TABLE ACCESS BY INDEX ROWID | JA_IN_RG_I | 1 | 45 | 3 |
    | 45 | INDEX RANGE SCAN | JA_IN_RG_I_N3 | 1 | | 2 |
    | 46 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 1 | 16 | 1 |
    | 47 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 1 | | |
    | 48 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 1 | 85 | 1 |
    | 49 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 1 | | |
    | 50 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_ASSIGNMENTS | 1 | 10 | 3 |
    | 51 | INDEX RANGE SCAN | WSH_DELIVERY_ASSIGNMENTS_N3 | 1 | | 2 |
    | 52 | TABLE ACCESS BY INDEX ROWID | JSW_LOT_PACKSLIP | 1 | 17 | 3 |
    | 53 | INDEX RANGE SCAN | JSW_LOT_PACKSLIP_N1 | 1 | | 2 |
    | 54 | TABLE ACCESS BY INDEX ROWID | WSH_NEW_DELIVERIES | 1 | 18 | 1 |
    | 55 | INDEX UNIQUE SCAN | WSH_NEW_DELIVERIES_U1 | 1 | | |
    | 56 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_LEGS | 1 | 10 | 2 |
    | 57 | INDEX RANGE SCAN | WSH_DELIVERY_LEGS_N1 | 1 | | 1 |
    | 58 | TABLE ACCESS BY INDEX ROWID | WSH_TRIP_STOPS | 1 | 10 | 1 |
    | 59 | INDEX UNIQUE SCAN | WSH_TRIP_STOPS_U1 | 1 | | |
    | 60 | TABLE ACCESS BY INDEX ROWID | WSH_TRIPS | 1 | 123 | 1 |
    | 61 | INDEX UNIQUE SCAN | WSH_TRIPS_U1 | 1 | | |
    | 62 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 1 | 10 | 1 |
    | 63 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 1 | | |
    | 64 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 1 | 9 | 1 |
    | 65 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 1 | | |
    | 66 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 1 | 10 | 1 |
    | 67 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 1 | | |
    | 68 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 1 | 34 | 1 |
    | 69 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 1 | | |
    | 70 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 1 | 10 | 1 |
    | 71 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 1 | | |
    | 72 | TABLE ACCESS BY INDEX ROWID | HZ_LOCATIONS | 1 | 192 | 1 |
    | 73 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 1 | | |
    we need to tune this query to reduce it time of execution as our users are very much affected in running requests.
    thanks,
    baskar.l

  • Need help in highlighting the query text in document

    Hi, I am trying to load the files in the blob column and trying to create the text index on it.
    i need to query the blob column in the document table with a string, which needs to return the relevant documents with the query string highlighted with some color.
    Can you please help me with an example on the above.
    Thanks in advance.

    SCOTT@orcl_11gR2> -- table:
    SCOTT@orcl_11gR2> CREATE TABLE document_tab
      2    (document_col  BLOB)
      3  /
    Table created.
    SCOTT@orcl_11gR2> -- procedure to load documents:
    SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE load_document
      2    (p_dir  IN VARCHAR2,
      3       p_file IN VARCHAR2)
      4  AS
      5    v_blob       BLOB;
      6    v_bfile       BFILE;
      7  BEGIN
      8    INSERT INTO document_tab (document_col)
      9    VALUES (EMPTY_BLOB())
    10    RETURNING document_col INTO v_blob;
    11    v_bfile := BFILENAME (UPPER (p_dir), p_file);
    12    DBMS_LOB.FILEOPEN (v_bfile, DBMS_LOB.LOB_READONLY);
    13    DBMS_LOB.LOADFROMFILE (v_blob, v_bfile, DBMS_LOB.GETLENGTH (v_bfile));
    14    DBMS_LOB.FILECLOSE (v_bfile);
    15  END load_document;
    16  /
    Procedure created.
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> -- load documents (directory and files must be on server, not client):
    SCOTT@orcl_11gR2> CREATE OR REPLACE DIRECTORY my_dir AS 'c:\my_oracle_files'
      2  /
    Directory created.
    SCOTT@orcl_11gR2> BEGIN
      2    load_document ('my_dir', 'banana.pdf');
      3    load_document ('my_dir', 'english.doc');
      4    load_document ('my_dir', 'sample.txt');
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- confirm files were loaded:
    SCOTT@orcl_11gR2> SELECT DBMS_LOB.GETLENGTH (document_col)
      2  FROM   document_tab
      3  /
    DBMS_LOB.GETLENGTH(DOCUMENT_COL)
                              222824
                               22016
                                  60
    3 rows selected.
    SCOTT@orcl_11gR2> -- text index:
    SCOTT@orcl_11gR2> CREATE INDEX document_idx
      2  ON document_tab (document_col)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  /
    Index created.
    SCOTT@orcl_11gR2> -- confirm files were indexed:
    SCOTT@orcl_11gR2> SELECT COUNT(*) FROM dr$document_idx$i
      2  /
      COUNT(*)
           319
    1 row selected.
    SCOTT@orcl_11gR2> -- function to return highlighted document:
    SCOTT@orcl_11gR2> CREATE OR REPLACE FUNCTION your_markup
      2    (p_index_name IN VARCHAR2,
      3       p_textkey    IN VARCHAR2,
      4       p_text_query IN VARCHAR2,
      5       p_plaintext  IN BOOLEAN  DEFAULT TRUE,
      6       p_tagset     IN VARCHAR2 DEFAULT 'HTML_DEFAULT',
      7       p_starttag   IN VARCHAR2 DEFAULT '*',
      8       p_endtag     IN VARCHAR2 DEFAULT '*',
      9       p_key_type   IN VARCHAR2 DEFAULT 'ROWID')
    10    RETURN          CLOB
    11  AS
    12    v_clob          CLOB;
    13  BEGIN
    14    CTX_DOC.SET_KEY_TYPE (p_key_type);
    15    CTX_DOC.MARKUP
    16        (index_name => p_index_name,
    17         textkey    => p_textkey,
    18         text_query => p_text_query,
    19         restab     => v_clob,
    20         plaintext  => p_plaintext,
    21         tagset     => p_tagset,
    22         starttag   => p_starttag,
    23         endtag     => p_endtag);
    24    RETURN v_clob;
    25  END your_markup;
    26  /
    Function created.
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> -- query that returns highlighted document:
    SCOTT@orcl_11gR2> VARIABLE string VARCHAR2(100)
    SCOTT@orcl_11gR2> EXEC :string := 'test AND demonstration'
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> SELECT your_markup ('document_idx', ROWID, :string)
      2           AS highlighted_text
      3  FROM   document_tab
      4  WHERE  CONTAINS (document_col, :string) > 0
      5  /HIGHLIGHTED_TEXT
    This is a test document for demonstration of highlighting.
    1 row selected.
    SCOTT@orcl_11gR2>

  • Need help in optimizing the ABAP code

    Hi,
    Can anyone help me in optimizing the code. Here the select statement has select within the loop. Need help in optimization.
    WHEN '0CO_PC_PCP_03'.
    LOOP AT C_T_DATA INTO TBL_KKBW_ITEM.
          W_TABIX = SY-TABIX.
          IF TBL_KKBW_ITEM-CURRENCY_TYPE EQ '20'.
    SELECT SINGLE KALNR KALKA KADKY TVERS KADAT KOKRS INTO (W_KALNR, W_KALKA, W_KADKY, W_TVERS,  
                    TBL_KKBW_ITEM-COSTING_DATE,
                    TBL_KKBW_ITEM-CONTROLLING_AREA)           
                    FROM KEKO                                  
                       WHERE KLVAR EQ TBL_KKBW_ITEM-COSTING_VARIANT                              
                        AND  KADKY EQ TBL_KKBW_ITEM-COSTING_DATE
                        AND  TVERS EQ TBL_KKBW_ITEM-COSTING_VERSION                           
                        AND  MATNR EQ TBL_KKBW_ITEM-HEADER_MATERIAL                             
                        AND  WERKS EQ TBL_KKBW_ITEM-HEADER_PLANT.
               IF SY-SUBRC EQ 0.                                
              SELECT SINGLE KOSTL INTO TBL_KKBW_ITEM-COST_CENTER
                              FROM CKIS WHERE KOSTL NE SPACE   
                                         AND  KALNR EQ W_KALNR 
                                         AND  KALKA EQ W_KALKA 
                                         AND  KADKY EQ W_KADKY 
                                         AND  TVERS EQ W_TVERS.
              IF SY-SUBRC NE 0.                                
                CLEAR TBL_KKBW_ITEM-COST_CENTER.               
              ENDIF.                                           
            ENDIF.                                             
            MODIFY C_T_DATA FROM TBL_KKBW_ITEM INDEX W_TABIX.
          ELSE.
            DELETE C_T_DATA INDEX W_TABIX.
          ENDIF.
        ENDLOOP.
    Thanks,
    Rani.

    hi
    plz use the below code :
    WHEN '0CO_PC_PCP_03'.
    SELECT  KALNR KALKA KADKY TVERS KADAT KOKRS INTO it_keko "declare internal table with the mentioned fields
    " also select the fields to be used in where condition
    FROM KEKO
    for all entries in c_t_data
    WHERE KLVAR EQ c_t_data-COSTING_VARIANT
    AND KADKY EQ c_t_data-COSTING_DATE
    AND TVERS EQ c_t_data-COSTING_VERSION
    AND MATNR EQ c_t_data-HEADER_MATERIAL
    AND WERKS EQ c_t_data-HEADER_PLANT.
    "sort the tables on the fields used in where.
    IF SY-SUBRC EQ 0.
    SELECT  KOSTL "and other fields to be used in where
    INTO it _ckis
    FROM CKIS
    for all entries in c_t_data
    WHERE KOSTL NE SPACE "use c_t_data
    AND KALNR EQ W_KALNR
    AND KALKA EQ W_KALKA
    AND KADKY EQ W_KADKY
    AND TVERS EQ W_TVERS.
    IF SY-SUBRC NE 0.
    CLEAR TBL_KKBW_ITEM-COST_CENTER.
    ENDIF.
    it_data[] = c_t_data. "declare it_data same as the extract structure
    delete it_data where CURRENCY_TYPE  NE '20'.
    LOOP AT it_data assigning <fs_data>. "use field symbols
    read from it_keko into wa_keko
    where
    KLVAR EQ <fs_data>-COSTING_VARIANT
    AND KADKY EQ <fs_data>-COSTING_DATE
    AND TVERS EQ <fs_data>-COSTING_VERSION
    AND MATNR EQ <fs_data>-HEADER_MATERIAL
    AND WERKS EQ<fs_data>-HEADER_PLANT
    binary search.
    if sy_subrc = 0.
    similarly read from the second itab
    ENDIF.
    ENDLOOP.
    c_t_data[] = it_data[].
    Pls let me know in case of any issues
    Regards,
    Aparna
    Edited by: Aparna KS on Jun 13, 2010 11:01 PM

  • Need help in writing the query

    The initial data is as follows:
    ID PARENT_ID
    =============
    1 NULL
    2 NULL
    3 2
    4 6
    5 3
    6 7
    7 4
    8 NULL
    but output is as follows in such way that Parent_Id should be displayed in ID place
    ID PARENT_ID
    =============
    1 NULL
    2 NULL
    3 2
    8 NULL
    6 8
    4 6
    5 3
    7 4
    Can any one help how resolve this query?
    Thanks in advance

    Your output is inconsistent with initial data :) But
    select * from t start with parent_id is null connect by parent_id = prior id;

  • Need help asap regarding the query windowing

    Dear friends,
    The database i'm using (mvdemo - mapviewer demo DB that comes along with Oracle 10g), has only data about united states. Say if i have my query window like this, -180, 0, 180 , 90 (which is the upper half of the earth), i am getting the desired result. ie., Here is that query,
    SELECT count(s.geom) FROM states s WHERE
    SDO_FILTER(s.geom,
    SDO_GEOMETRY(
         2003,
         8265,
         NULL,
         SDO_ELEM_INFO_ARRAY(1,1003,3),
         SDO_ORDINATE_ARRAY(-180, 0 , 180, 90))
    ) = 'TRUE';
    Returns 55
    I'm currently having a problem with my rectangular window query. When i query with a window value of -180, -90, 180, 90 (which covers the whole earth), the number of spatial objects (SDO_GEOM) that is returned is 0. It is not throwing any ORA error. But the expected result is as usual 55.
    SELECT count(s.geom) FROM states s WHERE
    SDO_FILTER(s.geom,
    SDO_GEOMETRY(
         2003,
         8265,
         NULL,
         SDO_ELEM_INFO_ARRAY(1,1003,3),
         SDO_ORDINATE_ARRAY(-180, 0 , 180, 90))
    ) = 'TRUE';
    Returns 0
    Could anyone please help me out with this issue??
    thank you in advance,
    Bragadeesh

    hi all,
    i found the solution to my problem.
    actually the query given here works just fine.
    wat i was doing was using the sdo_intersection(<some geom>, <query window>). The query window am using here is the whole earth. But according to spatial rule, there cant be any geometry greater than half the surface of the earth.
    Thank you all..

  • Need help on enhancement of 0CO_OM_OPA_1 with Material and Plant

    Hi,
    I have a requirement that need to build a BW report which shows Actual costs and Planned Costs of Service Orders. We are getting Actual costs from 0CO_OM_OPA_6 and now i am getting planned costs from 0CO_OM_OPA_1. For actual costs we are getting Service Orders, Material and plant from Satandard DS 0CO_OM_OPA_6. Where as For Planned Costs standard data source 0CO_OM_OPA_1 is not having Material and Plant information. For this we decided to enhance 0CO_OM_OPA_1 with Material and Plant.
    But we are not sure the source tables for material and plant and the logic to extract these data from the tables. Can anybody please help me out.
    Thanks for your supprt in advance.

    It's possible you may need to use a CO-PA (profitability analysis) datasource instead of 0CO_OM_OPA_6.  0CO_OM_OPA_6 extracts data from CO tables. 
    Based on the path you provided "...Profit. segment...", the requested data might exist with CO-PA.
    If you determine the required data resides in CO-PA, you'll have to create a datasource based on the operating concern.  You can perform a search within the online docs for steps to create this datasource.
    Hope this helps.
    Rod

  • Update with join and group by

    Hello All,
    I'm trying to update several colums of a table from a inner join query.
    First a retrieve the rows afected and the values that I need for the update (I call this subquery ED_Query).
    It's important to note that this subquery has a group by and and having clause.
    My first attemp (using the query that work in SQL Server query) fails:
    SQL> update ED_Update
    2 set ED_Update.dtHoraInicioReal = ED_Query.dtHoraInicioReal,
    3 ED_Update.dtHoraFinReal = ED_Query.dtHoraFinReal,
    4 ED_Update.fPorcentajeRealizado = ED_Query.fPorcentajeRealizado
    5 from HISTORICOS_AVANZA.HSAE_HIS_EXPEDICIONDIARIA ED_Update
    6 inner join (
    7 select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,
    8 MAX(PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    9 MAX(HPP.iOrden) as iOrdenUltimaParada,
    10 MIN(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60)) as dtHoraInicioReal,
    11 MAX(dtHora_LlegadaReal) as dtHoraFinReal,
    12 100 * cast ((MAX(HPP.iOrden) + 1) as float) / cast ((MAX(PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado
    13 from HISTORICOS_AVANZA.HSAE_HIS_EXPEDICIONDIARIA ED
    14 left join HISTORICOS_AVANZA.HSAE_HIS_HORAPASOPARADA HPP
    15 on ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    16 left join AVANZA.SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    17 where ED.dtJornada = TO_DATE('14/01/2013', 'DD/MM/YYYY') and ED.iIdExpedicion in (-131076)
    18 group by ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal, ED.dtHoraFinReal
    19 having ED.dtHoraInicioReal <> min(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60))
    20 or ED.dtHoraFinReal <> max(dtHora_LlegadaReal)
    21 ) ED_Query
    22 on ED_Update.iIdExpedicionDiaria = ED_Query.iIdExpedicionDiaria;
    ERROR at line 5:
    ORA-00933: SQL command not properly ended
    The subquery (ED_Query) work fine in Oracle, so I suspect that the problems are when I mix it with the update clause.
    SQL> select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,
    2 MAX(PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    3 MAX(HPP.iOrden) as iOrdenUltimaParada,
    4 MIN(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60)) as dtHoraInicioReal,
    5 MAX(dtHora_LlegadaReal) as dtHoraFinReal,
    6 100 * cast ((MAX(HPP.iOrden) + 1) as float) / cast ((MAX(PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado,
    7 ED.dtHoraInicioReal as ED_dtHoraInicioReal, ED.dtHoraFinReal as ED_dtHoraFinReal, ED.fPorcentajeRealizado as ED_fPorcentajeRealizado
    8 from HISTORICOS_AVANZA.HSAE_HIS_EXPEDICIONDIARIA ED
    9 left join HISTORICOS_AVANZA.HSAE_HIS_HORAPASOPARADA HPP
    10 on ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    11 left join AVANZA.SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    12 where ED.dtJornada = TO_DATE('14/01/2013', 'DD/MM/YYYY') and ED.iIdExpedicion in (-131076)
    13 group by ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal, ED.dtHoraFinReal, ED.fPorcentajeRealizado
    14 having ED.dtHoraInicioReal <> min(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60))
    15 or ED.dtHoraFinReal <> max(dtHora_LlegadaReal);
    IIDEXPEDICION IIDEXPEDICIONDIARIA INUMPARADAS IORDENULTIMAPARADA DTHORAINI
    DTHORAFIN FPORCENTAJEREALIZADO ED_DTHORA ED_DTHORA ED_FPORCENTAJEREALIZADO
    -131076 5662 406 15-JAN-13
    15-JAN-13 15-JAN-13 15-JAN-13 0
    -131076 5663 406 15-JAN-13
    15-JAN-13 15-JAN-13 15-JAN-13 0
    -131076 5664 406 15-JAN-13
    15-JAN-13 15-JAN-13 15-JAN-13 0
    After reading this forum, I change the query and try the next one:
    SQL> UPDATE
    2 (
    3 select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,
    4 MAX(PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    5 MAX(HPP.iOrden) as iOrdenUltimaParada,
    6 MIN(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60)) as dtHoraInicioReal,
    7 MAX(dtHora_LlegadaReal) as dtHoraFinReal,
    8 100 * cast ((MAX(HPP.iOrden) + 1) as float) / cast ((MAX(PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado,
    9 ED.dtHoraInicioReal as ED_dtHoraInicioReal, ED.dtHoraFinReal as ED_dtHoraFinReal, ED.fPorcentajeRealizado as ED_fPorcentajeRealizado
    10 from HISTORICOS_AVANZA.HSAE_HIS_EXPEDICIONDIARIA ED
    11 left join HISTORICOS_AVANZA.HSAE_HIS_HORAPASOPARADA HPP
    12 on ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    13 left join AVANZA.SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    14 where ED.dtJornada = TO_DATE('14/01/2013', 'DD/MM/YYYY') and ED.iIdExpedicion in (-131076)
    15 group by ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal,ED.dtHoraFinReal, ED.fPorcentajeRealizado
    16 having ED.dtHoraInicioReal <> min(dtHora_LlegadaReal + iTiempoEnParada/(24*60*60))
    17 or ED.dtHoraFinReal <> max(dtHora_LlegadaReal)
    18 )
    19 SET ED_dtHoraInicioReal = dtHoraInicioReal,
    20 ED_dtHoraFinReal = dtHoraFinReal,
    21 ED_fPorcentajeRealizado = fPorcentajeRealizado;
    ERROR at line 2:
    ORA-01732: data manipulation operation not legal on this view
    Some help?
    Thanl in advance.
    Edited by: 984483 on 28-ene-2013 1:48

    Thanks for your answer. I tried to rewrite my question.
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    PL/SQL Release 9.2.0.3.0 - Production
    CORE 9.2.0.3.0 Production
    TNS for 32-bit Windows: Version 9.2.0.3.0 - Production
    NLSRTL Version 9.2.0.3.0 - Production
    I have 2 tables. I like to update one of them (ED_Update) with the data from the another one (ED_Query).
    This example is equivalent:
    create table ED_Query (id number,
         date01 date,
    number01 number)
    insert into ED_Query values (1, to_date('01/01/2013','DD/MM/YYYY'), 10);
    insert into ED_Query values (2, to_date('01/01/2013','DD/MM/YYYY'), 20);
    insert into ED_Query values (3, to_date('01/01/2013','DD/MM/YYYY'), 30);
    insert into ED_Query values (4, to_date('02/01/2013','DD/MM/YYYY'), 40);
    insert into ED_Query values (5, to_date('03/01/2013','DD/MM/YYYY'), 50);
    create table ED_Update (date01 date,
              numberMax number,
              numberSum number)
    insert into ED_Update values (to_date('01/01/2013','DD/MM/YYYY'), 0, 0);
    insert into ED_Update values (to_date('02/01/2013','DD/MM/YYYY'), 0, 0);
    insert into ED_Update values (to_date('03/01/2013','DD/MM/YYYY'), 0, 0);     
    The next update query fails with ORA-00933: SQL command not properly ended.
    update ED_Update
    set ED_Update.date01 = ED_Query.date01,
         ED_Update.numberMax = ED_Query.numberMax,
         ED_Update.numberSum = ED_Query.numberSum
    inner join
         select date01, max (number01) as numberMax, sum(number01) as numberSum
         from ED_Query
         where date01 = TO_DATE('01/01/2013', 'DD/MM/YYYY')
         group by date01
    ) ED_Query
    on ED_Update.date01 = ED_Query.date01
    I think the problem is in the update clause because the next query work:
    select * from
    ED_Update
    inner join
         select date01, max (number01) as numberMax, sum(number01) as numberSum
         from ED_Query
         where date01 = TO_DATE('01/01/2013', 'DD/MM/YYYY')
         group by date01
    ) ED_Query
    on ED_Update.date01 = ED_Query.date01
    Thank in advance.

  • Need help on resolving the issue with adobe output server - error MSG256 & MSG 210 not in .ini file

    Hi,
    I am using adobe output designer 5.5 for designing the label template and using the Adobe output server for printing process.
    In the Jfmerge.ini we given the condition "DiscardUnknownFields=Yes" for ignoring the unwanted fields in the .dat file.
    During the process, I faced some issue with the output server in printing the labels.
    When the .dat file is placed in the Data folder of adobe, the label is not getting printed in the printer.
    The file is move to the error folder and an error file is getting generated which contains the error message as given below:
    090826 02:59:02 D:\Program Files\Adobe\Central\Bin\jfmerge: [256]** Message Msg256 not in .ini file **
    090826 02:59:02 D:\Program Files\Adobe\Central\Bin\jfmerge: [210]** Message Msg210 not in .ini file **
    2009/08/26 02:59:02 D:\Program Files\Adobe\Central\Bin\jfserver.exe: [314]Agent exit message: [210]** Message Msg210 not in .ini file **
    The output server is a new installtion and I verified the Jfmerge.ini file. It contains the message details of Msg256 and Msg210.
    I also verified the license and it is a valid licence.
    Kindly help me out in solving this issue.
    Thanks
    Senthil

    I assume this is too late to help you, but other might need a hint.  I had the same problem, and found some possible causes that I posted on http://codeznips.blogspot.com/2010/02/adobe-output-server-message-msg210-not.html.
    It is quite likely that you are missing some double quotes around the path specifying the ini file (-aii), if its installed under "Program Files".
    Hope this helps anyone....
    Vegard

Maybe you are looking for

  • Sap-syscmd=nocookie and Statefull BSP's - Session timeout

    I have a tricky problem - and I'am hoping for your helpfull input... please.. I have developed a Statefull BSP application - and this application should be called from a SAP CRM application - and it should be possible to call and execute this aplicat

  • HELP!!! Could someone help me with a jar file issue and JRE 1.3 & 1.4

    We had a problem with the last Oracle patch in that it tried to extract from a jar file using the "jar" executable. But the jar executable is not installed on the server where we have JRE 1.4 On one server, Jar.exe is installed where we have JRE 1.3.

  • No sound under bootcamp XP SP3

    I just installed Windows XP SP2 and updated it to SP3 under bootcamp. I did the bootcamp 2.1 update, and installed the drivers from the leopard disk. However, I still have no sound, either in my headphones or in the built-in speakers. Any help would

  • IDVD disks won't play in home DVD player. They used to

    Hi, can you help I'm using iDVD 5, iMovie 5, saving as disk image, mounting image and burning using Toast 6 to firewire LaCie D2 DVD burner. I have done this many times using same configuration, but not for a while. The disks created will play in the

  • Green picture during video calls

    I am only getting a green screen from my camera when making video calls on x box one,can anyone suggest anything