How to avoid the below nested select statement

Please any one help me how this select statemet is working and      how to avoid the nesetd select statement .
if we avoid below nested , does it improve performace ?
select field1 field2                                  
           into table w_feeds                                 
           from ZTable as t                         
           where field2 in r_feedf1                       
           and  POSITION_POSTDT =                           
           ( SELECT MAX( position_postdt ) FROM zTable 
                  where position_postdt le r_pdate-high    
                  and   field1 = t~field1 ).
Thanks in Advace.

Hi,
Instead of nested query go for two separate queries. I see you are querying on the same table...so better go by this approach
select field1 field2 POSITION_POSTDT
into table w_feeds
from ZTable
where field2 in r_feedf1.
Remove the where condition on POSITION_POSTDT
Sort the table w_feeds by POSITION_POSTDT  Descending; So you will get data pertaining to Max Position_Postdt.
Finally delete the other entries which are not Max.
This will enhance the performance over the nested query.
Regards
Shiva
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM

Similar Messages

  • How to avoid the screen of selection output device

    Hi all,
    Who can tell me how to avoid the screen selection output device when running a smartform.
    Best regard.

    Hi,
          data: wa_SSFCTRLOP  type SSFCTRLOP.
           wa_SSFCTRLOP-DEVICE = 'PRINTER'.
           wa_SSFCTRLOP-NO_DIALOG =  'X'.
           wa_SSFCTRLOP-PREVIEW = 'X'.
        in the function module
       call function '....
       exporting
       CONTROL_PARAMETERS = wa_ssfctrlop
    regards,
    Santosh Thorat

  • How to avoid using schema_name in select statements

    Hello
    I am in the process of developing a 3-tier database application with Delphi, using Oracle database server. When I try to to execute the following code in a query on the client application(with a logged user who has been granted select on that table):
    SELECT C1,C2
    FROM TABLE1
    WHERE ((C3 = :P1) OR (C3 IS NULL))
    AND (C4 = :P2)
    ORDER BY C5
    it raises an "ORA-00942: table or view does not exist" exception. The table exists, the user has the necessary grants, but it still doesn't work. When I put the actual schema_name before the table name it starts to work(like this):
    SELECT C1,C2
    FROM SCHEMA1.TABLE1
    WHERE ((C3 = :P1) OR (C3 IS NULL))
    AND (C4 = :P2)
    ORDER BY C5
    What am I doing wrong?

    To explain the reason for the solutions suggested.
    The problem is scope. Just like having a constant in another Delphi unit which is what you want to reference in the current unit.
    You refer to an object. Oracle scope resolution first looks in the current schema for the session. If it does not find the object there (as a table/view/synonym/etc), it looks in the public context (public synonyms). It does not traverse any other schemas as that would be a very dangerous and inefficient thing to do (e.g. imagine referring to EMP and you have access to EMP tables in JOE's and SCOTT's schemas - which EMP is the real EMP?).
    You can change the current schema for scope resolution. E.g. you're signed in as schema SCOTT. You issue an alter session set current_schema=hr_system. Now the default scope is HR_SYSTEM and no longer SCOTT. However, you're SCOTT privs are still applicable.
    Alternatively you can use synonyms or public synonyms. The latter should however not be used for application objects. Public should only be used for generic objects applicable across all application schemas.

  • Prompting for user input in nested select statements

    I recently rewrote a query to use a nested select statement instead of specifying every SELECT field on the GROUP BY line.  Here's the query which works perfectly with hard-coded values of '030', '01/01/11', and '12/31/11'.
    SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country],  T1.[TotalSales]
    FROM OCRD T0 
    INNER JOIN
       (SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
        FROM OINV I
        WHERE left (I.[CardCode], 3) = '030' AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
        GROUP BY I.[CardCode]) T1
    ON T0.[CardCode] = T1.[CardCode]
    ORDER BY T0.[CardName]
    When I try to prompt for the left 3 characters of the CardCode (or the dates), ie.
        WHERE left (I.[CardCode], 3) = [%0] AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
    I get an error "Column 'OCRD.CardName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause".
    It's like putting a user variable in the inner SELECT made it part of the outer SELECT which is exactly what I was trying to avoid by re-writing this query with the inner SELECT.
    Can anyone explain what SQL Server is doing here and how to fix it?

    Thanks Gordon.  That's how I originally wrote the query and it works fine.  But I was disturbed that I had to GROUP BY every field in my SELECT statement when I really only wanted to group by CardCode.  So I did some research and came up with this where the inner select still groups by only CardCode and still takes user input.  I don't really understand why you need the commented SELECT statements in the SET lines, but you do.  Something about using real table fields for variables.
    DECLARE @startDate datetime
    DECLARE @endDate datetime
    DECLARE @rep varchar(10)
    SET @rep /* SELECT T0.[CardCode] FROM ORDR T0 WHERE T0.[CardCode] */ = '[%0]'
    SET @startDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%1]'
    SET @endDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%2]'
    SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country],  T1.[TotalSales]
    FROM OCRD T0 
    INNER JOIN
       (SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
        FROM OINV I
        WHERE left (I.[CardCode], 3) = @rep AND (I.[DocDate] >= @startDate AND I.[DocDate] <= @endDate)
        GROUP BY I.[CardCode]) T1
    ON T0.[CardCode] = T1.[CardCode]
    ORDER BY T0.[CardName]
    FOR BROWSE

  • How can avoid the  problem of Parameter Prompting when I submitting ?

    I am developing web application in visual studio 2008 in csharp.How can avoid the issue or problem of  Parameter Prompting when I send parameters programaticaly or dyanmicaly?  I am sending the values from .net web form to crystal report but it is still asking for parameters. so when i submit second time that is when the reports is being genereated. How can i solve this problem. Please help. The code Iam using is below.
       1. using System; 
       2. using System.Collections; 
       3. using System.Configuration; 
       4. using System.Data; 
       5. using System.Linq; 
       6. using System.Web; 
       7. using System.Web.Security; 
       8. using System.Web.UI; 
       9. using System.Web.UI.HtmlControls; 
      10. using System.Web.UI.WebControls; 
      11. using System.Web.UI.WebControls.WebParts; 
      12. using System.Xml.Linq; 
      13. using System.Data.OleDb; 
      14. using System.Data.OracleClient; 
      15. using CrystalDecisions.Shared; 
      16. using CrystalDecisions.CrystalReports.Engine; 
      17. using CrystalDecisions.Web; 
      18.  
      19.  
      20. public partial class OracleReport : System.Web.UI.Page 
      21. { 
      22.     CrystalReportViewer crViewer = new CrystalReportViewer(); 
      23.     //CrystalReportSource crsource = new CrystalReportSource(); 
      24.     int nItemId; 
      25.  
      26.     protected void Page_Load(object sender, EventArgs e) 
      27.     { 
      28.         //Database Connection 
      29.         ConnectionInfo ConnInfo = new ConnectionInfo(); 
      30.         { 
      31.             ConnInfo.ServerName = "127.0.0.1"; 
      32.             ConnInfo.DatabaseName = "Xcodf"; 
      33.             ConnInfo.UserID = "HR777"; 
      34.             ConnInfo.Password = "zghshshs"; 
      35.         } 
      36.         // For Each  Logon  parameters 
      37.         foreach (TableLogOnInfo cnInfo in this.CrystalReportViewer1.LogOnInfo) 
      38.         { 
      39.             cnInfo.ConnectionInfo = ConnInfo; 
      40.  
      41.         } 
      42.  
      43.  
      44.  
      45.  
      46.  
      47.  
      48.         //Declaring varibles 
      49.          nItemId = int.Parse(Request.QueryString.Get("ItemId")); 
      50.         //string strStartDate = Request.QueryString.Get("StartDate"); 
      51.         //int nItemId = 20; 
      52.         string strStartDate = "23-JUL-2010"; 
      53.  
      54.         // object declration 
      55.         CrystalDecisions.CrystalReports.Engine.Database crDatabase; 
      56.         CrystalDecisions.CrystalReports.Engine.Table crTable; 
      57.  
      58.  
      59.         TableLogOnInfo dbConn = new TableLogOnInfo(); 
      60.  
      61.         // new report document object 
      62.         ReportDocument oRpt = new ReportDocument(); 
      63.  
      64.         // loading the ItemReport in report document 
      65.         oRpt.Load("C:
    Inetpub
    wwwroot
    cryreport
    CrystalReport1.rpt"); 
      66.  
      67.         // getting the database, the table and the LogOnInfo object which holds login onformation 
      68.         crDatabase = oRpt.Database; 
      69.  
      70.         // getting the table in an object array of one item 
      71.         object[] arrTables = new object[1]; 
      72.         crDatabase.Tables.CopyTo(arrTables, 0); 
      73.  
      74.         // assigning the first item of array to crTable by downcasting the object to Table 
      75.         crTable = (CrystalDecisions.CrystalReports.Engine.Table)arrTables[0]; 
      76.  
      77.         dbConn = crTable.LogOnInfo; 
      78.  
      79.         // setting values 
      80.         dbConn.ConnectionInfo.DatabaseName = "Xcodf"; 
      81.         dbConn.ConnectionInfo.ServerName = "127.0.0.1"; 
      82.         dbConn.ConnectionInfo.UserID = "HR777"; 
      83.         dbConn.ConnectionInfo.Password = "zghshshs"; 
      84.  
      85.         // applying login info to the table object 
      86.         crTable.ApplyLogOnInfo(dbConn); 
      87.  
      88.  
      89.  
      90.  
      91.  
      92.  
      93.         crViewer.RefreshReport(); 
      94.          
      95.                 // defining report source 
      96.         crViewer.ReportSource = oRpt; 
      97.         //CrystalReportSource1.Report = oRpt; 
      98.          
      99.         // so uptill now we have created everything 
    100.         // what remains is to pass parameters to our report, so it 
    101.         // shows only selected records. so calling a method to set 
    102.         // those parameters. 
    103.      setReportParameters();  
    104.     } 
    105.  
    106.     private void setReportParameters() 
    107.     { 
    108.       
    109.         // all the parameter fields will be added to this collection 
    110.         ParameterFields paramFields = new ParameterFields(); 
    111.          //ParameterFieldDefinitions ParaLocationContainer = new ParameterFieldDefinitions(); 
    112.        //ParameterFieldDefinition ParaLocation = new ParameterFieldDefinition(); 
    113.         
    114.         // the parameter fields to be sent to the report 
    115.         ParameterField pfItemId = new ParameterField(); 
    116.         //ParameterField pfStartDate = new ParameterField(); 
    117.         //ParameterField pfEndDate = new ParameterField(); 
    118.  
    119.         // setting the name of parameter fields with wich they will be recieved in report 
    120.        
    121.         pfItemId.ParameterFieldName = "RegionID"; 
    122.  
    123.         //pfStartDate.ParameterFieldName = "StartDate"; 
    124.         //pfEndDate.ParameterFieldName = "EndDate"; 
    125.  
    126.         // the above declared parameter fields accept values as discrete objects 
    127.         // so declaring discrete objects 
    128.         ParameterDiscreteValue dcItemId = new ParameterDiscreteValue(); 
    129.         //ParameterDiscreteValue dcStartDate = new ParameterDiscreteValue(); 
    130.         //ParameterDiscreteValue dcEndDate = new ParameterDiscreteValue(); 
    131.  
    132.         // setting the values of discrete objects 
    133.          
    134.  
    135.           dcItemId.Value = nItemId; 
    136.          
    137.         //dcStartDate.Value = DateTime.Parse(strStartDate); 
    138.         //dcEndDate.Value = DateTime.Parse(strEndDate); 
    139.          
    140.         // now adding these discrete values to parameters 
    141.           //paramField.HasCurrentValue = true; 
    142.  
    143.        
    144.  
    145.           //pfItemId.CurrentValues.Clear(); 
    146.          int valueIDD = int.Parse(Request.QueryString.Get("ItemId").ToString()); 
    147.           pfItemId.Name = valueIDD.ToString();  
    148.            
    149.         pfItemId.CurrentValues.Add(dcItemId); 
    150.         //ParaLocation.ApplyCurrentValues; 
    151.         pfItemId.HasCurrentValue = true; 
    152.         
    153.         //pfStartDate.CurrentValues.Add(dcStartDate); 
    154.         //pfEndDate.CurrentValues.Add(dcEndDate); 
    155.  
    156.         // now adding all these parameter fields to the parameter collection 
    157.         paramFields.Add(pfItemId); 
    158.          
    159.         //paramFields.Add(pfStartDate); 
    160.         //paramFields.Add(pfEndDate); 
    161.         ///////////////////// 
    162.         //Formula from Crystal 
    163.        //crViewer.SelectionFormula = "{COUNTRIES.REGION_ID} = " + int.Parse(Request.QueryString.Get("ItemId")) + ""; 
    164.         crViewer.RefreshReport(); 
    165.         // finally add the parameter collection to the crystal report viewer 
    166.         crViewer.ParameterFieldInfo = paramFields; 
    167.         
    168.          
    169.      
    170.     } 
    171. }

    Keep your post to under 1200 characters, else you loose the formatting. (you can do two posts if need be).
    Re. parameters. First, make sure yo have SP 1 for CR 10.5:
    https://smpdl.sap-ag.de/~sapidp/012002523100009351512008E/crbasic2008sp1.exe
    Next, see the following:
    [Crystal Reports for Visual Studio 2005 Walkthroughs|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23]
    CR Dev help file:
    http://msdn2.microsoft.com/en-us/library/bb126227.aspx
    Samples:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup

  • Is it possible to nest SELECT statements?

    Greetings community,
    Another newbie’s question it is. Looking tutorials and some posts here I’ve been advised not to pull entire table through the local network, and torture client machines’ processors and memory. It’s been said that better solution is to
    pull just one part of the table.
    So, imagine this: you want to make a part of your app that would allow your user to view list of orders. So you put one data grid view on the form, pull last 20 headers from the table into it and leave to user to choose one to be opened
    in another form. If user doesn’t find header they want, they press page up for example and previous 20 headers are loaded into data grid view. Of course, user could filter headers list by customer, or by distribution lane (having all customers residing in
    one part of the town), or whatever more, but let’s not complicate things at this moment, because I’m practically in the beginning.
    I’m trying to make a stored procedure that would load penultimate 20 headers when user presses page up. So, not knowing any better, I created table variable that has the same structure as Orders table with one difference: OrderID column,
    which is identity (auto incremented) in Orders table, here is simply defined as bigint not null. Community member Visakh16 warned me few months ago it’s the bad practice to put self-incrementing columns in table variables.
    At this moment there’s a query on my screen, which waits to become store procedure. After boring part with table variable definition, it goes like this:
    INSERT INTO @OrdersTemp SELECT TOP 40 * FROM dbo.Orders ORDER BY OrderID DESC
    SELECT TOP 20 * FROM @OrdersTemp ORDER BY OrderID ASC
    To put that simply, I pull last 40 headers into table variable, and then pull first 20 from there. This thing works, and I just have to replace 40 with parameter, for every page up or down.
    Now I have few questions.
    -Is there some better way (considering performance) to achieve that? Here is the place where I wanted to ask the question from the title of the post. I don’t know much about T-SQL, and I’m not sure about the proper syntax to nest SELECT
    statements, if something like that is even possible
    -Is there any better way (some built-in function) to find about the count of the rows in one table than
    SELECT COUNT(OrdersID) FROM dbo.Orders
    Thanks for any suggestions.

    Hi Erland,
    Sorry for the very late reply, but I said that I would start another thread when I find more free time to dedicate it to this, so I didn’t really expected you to reply anymore. I didn’t really check here for more than a week, and I glanced
    at mail accidentally.
    As for the negative result I got, its measurement unit is microsecond, so it doesn’t go out of margins you had experienced.
    As for the number of cores, you got me surprised there. I use express edition of SQL server. Last time I checked was SQL server 2012 express, and in specifications it said that express edition is limited to 1 processor core, 1GB of RAM
    and creates up to 10GB database file. I don’t believe they changed any of those specifications. It was generous enough when they doubled size of DB file few editions ago. Still, it appears that “one processor core for express edition” statement has some gray
    areas in it.
    However, at this moment I’m just learning, and I just wanted some way to test how efficient my queries are. I don’t have a real biz problem to solve. I don’t expect that any real performance problem should rise in years of everyday work
    of populating database. What I expect is performance impact when it comes to creating reports, but after all, I don’t think that my boss would create reports by himself. I believe that creating reports would be my task, and I will be doing it after hours,
    being the only user at the moment. Or maybe I could make de-normalized copy of database that would be populated after hours to make it possible for my boss to get his reports faster by himself, as I’ve heard that was the way of making BI in older non-express
    editions.
    So, I do suggest that we finally close this thread for sake of other readers. I’ll start another one with this subject when I find the time to do it.
    Again, thanks for being with me along this journey.

  • How to put OR clause in SELECT statement

    Hi
    How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
    <pre>
    SELECT
    a.id ,
    flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
    apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
    from
    a ,
    b
    where b.street_name = a.street_name
    AND b.SUBURB = a.SUBURB
    AND b.STATE = a.STATE
    </pre>
    Thsi will return this as exact match.
    ADDRESS 1
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    ADDRESS2
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    However this only matches number_first.
    How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.

    Hi, I have a hard time understanding your request, and below is what I thought you want:
    SELECT
        a.id ,
           flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb  address1,
             apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
          from
                 a ,
                 b
                where          b.street_name = a.street_name
                 AND            b.SUBURB      = a.SUBURB
                AND            b.STATE       = a.STATE
                AND  (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
    Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
    (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
    Edited by: PhoenixBai on Aug 26, 2010 11:33 AM

  • Nested select statements.

    Hi, I am writing a piece of code in which i use nested select statements for 4 tables to retrieve one column's data (ie: POSNR). But when i execute it, it takes way too long to get the data. I'm quite new to ABAP so very in need of your help. Thanks
    REPORT  z_impos_test.
    TABLES: coss,       "CO Object: Cost Totals for Internal Postings
            afvc,       "Operation within an order
            prps,       "WBS (Work Breakdown Structure) Element Master Data
            imzo.       "Table: CO Object - Capital Investment Prog.Pos.
    TYPES: BEGIN OF st_impos,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF st_impos.
    data: year TYPE coss-gjahr value '2007'.
    DATA: t_output  TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output TYPE st_impos,
          t_output2 TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output2 TYPE st_impos.
    SELECT objnr gjahr kstar FROM coss
    INTO CORRESPONDING FIELDS OF st_output
    WHERE ( objnr LIKE 'NV%' OR
          objnr LIKE 'PR%' ) AND
           gjahr = year.
       SELECT SINGLE projn from afvc into CORRESPONDING FIELDS OF st_output
           WHERE objnr = st_output-objnr.
    APPEND st_output to t_output.
    ENDSELECT.
    SORT t_output BY objnr.
    DELETE ADJACENT DUPLICATES FROM t_output.
    LOOP AT t_output into st_output.
    SELECT objnr pspnr
           INTO CORRESPONDING FIELDS OF st_output2
           FROM prps
           WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr.
      SELECT SINGLE posnr from imzo into CORRESPONDING FIELDS OF st_output2
           WHERE objnr = st_output2-objnr.
    APPEND st_output2 to t_output2.
    ENDSELECT.
    ENDLOOP.
    LOOP AT t_output2 to st_output2.
    WRITE:   st_output2-posnr.
    ENDLOOP.
    Edited by: Jacie Johns on Apr 23, 2009 11:26 PM

    HI John,
    Try to avoid INTO CORRESPONDING FIELDS in SELECT statement.
    As you are not using PSPNR and POSNR fields in the first SELECT statement. If you remove these fields, in structure, INTO CORRESPONDING FIELDS can be avoided. Create a separate structure with the fields that are required for T_OUTPUT table (i.e. create another structure with only first 4 fields, as T_OUTPUT1.
    And as mentioned in your code,
      WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr
    in select statement, ST_OUTPUT-PSPNR value is not fetched in the previous select statements.
    Create Another structure with fields OBJNR, PSPNR, POSNR for table T_OUTPUT2 to store the data from tables, PRPS and IMZO.
    Use JOINS and FOR ALL ENTRIES to fetch the desired data.
    The sample code is as follows:
    ===
    TYPES: BEGIN OF ty_output1,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
    END OF ty_output1,
    BEGIN OF ty_output2,
      objnr       TYPE coss-objnr,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output2,
    BEGIN OF ty_output3,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output3.
    data: year TYPE coss-gjahr value '2007'.
    DATA:
           wa_output1 TYPE ty_output1,   
           wa_output2 TYPE ty_output2,
           wa_output3 TYPE ty_output3,
           t_output1  TYPE STANDARD TABLE OF ty_output1 ,
           t_output2 TYPE STANDARD TABLE OF ty_output2 ,
           t_output3 TYPE STANDARD TABLE OF ty_output3..
    SELECT cobjnr cgjahr ckstar aprojn FROM coss as c
         INNER JOIN afvc as A on aobjnr = cobjnr
      INTO table t_output1
      WHERE ( c~objnr like 'NV%'   or
              c~objnr like 'PR%' ) and
            c~gjahr = year.
    SELECT pobjnr ppspnr i~posnr FROM prps as P
         INNER JOIN imzo AS I on pobjnr = iobjnr
         INTO TABLE t_output2
         for all entries in table T_OUTPUT1
         WHERE      p~objnr = t_output1-objnr.
    SORT : t_output1 BY objnr,
                t_output2 BY objnr.
    DELETE ADJACENT DUPLICATES FROM : t_output1 COMPARING objnr,
                                                                     t_output2 COMPARING objnr.
    LOOP AT t_output1 INTO wa_output1
    READ TABLE t_output2 INTO wa_output2 WITH KEY objnr - wa_output1-objnr BINARY SEARCH.
    if sy-subrc = 0.
      MOVE <wa_output1 fiels> and <wa_output2 fields> to WA_OUTPUT3.
      append wa_output3 to T_OUTPUT3.
    endif.
    ENDLOOP.
    Hope this will solve your problem.
    Regards,
    Sai Prasad

  • How to avoid the duplicate values, I do not want the duplicate............

    i have one database table called "sms1" that table is updated every day or on daily basis it has the following fields in it:
    SQL> desc sms1;
    Name Null? Type
    MOBILE NUMBER
    RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)
    SNO NUMBER
    INDATE DATE
    From this table the is one column "RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)" . I am splitting it into different columns like :
    SQL> desc smssplit;
    Name Null? Type
    R VARCHAR2(2 CHAR)
    C VARCHAR2(2 CHAR)
    S VARCHAR2(1 CHAR)
    TC VARCHAR2(3 CHAR)
    NA VARCHAR2(3 CHAR)
    TC2 VARCHAR2(3 CHAR)
    NA2 VARCHAR2(3 CHAR)
    TC3 VARCHAR2(3 CHAR)
    NA3 VARCHAR2(3 CHAR)
    TC4 VARCHAR2(3 CHAR)
    NA4 VARCHAR2(3 CHAR)
    WTHER VARCHAR2(10 CHAR)
    SNO NUMBER
    INSERTDATA VARCHAR2(25 CHAR)
    Now I am written a procedure to insert the data from "Sms1" table to smssplit table...
    CREATE OR REPLACE PROCEDURE SPLITSMS
    AS
    BEGIN
    INSERT INTO scott.SMSSPLIT ( R,C,S,TC,NA,TC2,NA2,TC3,NA3,TC4,NA4,WTHER,SNO)
    SELECT SUBSTR(RCSTCNATCNATCNATCNAWTHER,1,2) R,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,3,2) C,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,5,1) S,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,6,3) TC,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,9,3) NA,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,12,3) TC2,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,15,3) NA2,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,18,3) TC3,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,21,3) NA3,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,24,3) TC4,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,27,3) NA4,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,30,10) WTHER, SNO
    FROM scott.SMS1 where SNO=(select MAX (sno) from SMS1);
    END;
    Now in order to update the second table with data from first table on regular basis I have written a job scheduler and I am using oracle 9.0. version...
    DECLARE
    X NUMBER;
    JobNumber NUMBER;
    BEGIN
    SYS.DBMS_JOB.SUBMIT
    job => X
    ,what => 'scott.SPLITSMS;'
    ,next_date => SYSDATE+1/1440
    ,interval => 'SYSDATE+1/1440 '
    ,no_parse => FALSE
    :JobNumber := to_char(X);
    END;
    Now this job scheduler is working properly and updating the data for every one minute but it is taking or updating the duplicate values also ..like example:
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:49:16
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:49:16
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:50:17
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:50:17
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:51:19
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:51:19
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:52:20
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:52:20
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:53:22
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:53:22
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:54:45
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:54:45
    Now I do not want the duplicate values to be updated ...and want them to ignore them.....
    please I need a help on this query........How to avoid the duplicate values............

    Look at the posts closely:might not be needed if formatted ;)
    create or replace procedure splitsms as
    begin
      insert into scott.smssplit (r,c,s,tc,na,tc2,na2,tc3,na3,tc4,na4,wther,sno)
      select substr(rcstcnatcnatcnatcnawther,1,2) r,
             substr(rcstcnatcnatcnatcnawther,3,2) c,
             substr(rcstcnatcnatcnatcnawther,5,1) s,
             substr(rcstcnatcnatcnatcnawther,6,3) tc,
             substr(rcstcnatcnatcnatcnawther,9,3) na,
             substr(rcstcnatcnatcnatcnawther,12,3) tc2,
             substr(rcstcnatcnatcnatcnawther,15,3) na2,
             substr(rcstcnatcnatcnatcnawther,18,3) tc3,
             substr(rcstcnatcnatcnatcnawther,21,3) na3,
             substr(rcstcnatcnatcnatcnawther,24,3) tc4,
             substr(rcstcnatcnatcnatcnawther,27,3) na4,
             substr(rcstcnatcnatcnatcnawther,30,10) wther,
             sno
        from scott.sms1 a
       where sno = (select max(sno)
                      from sms1
                     where sno != a.sno
                   ); ---------------> added where clause with table alias.
    end;Regards
    Etbin

  • How to call user fuction in select statement.

    hi,
    i am facing some problem.How to call user functions in select statement.please send me answer with example.
    Thanks
    Gopal

    Locations to Call User-Defined Functions
    • Select list of a SELECT command
    • Condition of the WHERE and HAVING clauses
    • CONNECT BY, START WITH, ORDER BY, and GROUP
    BY clauses
    • VALUES clause of the INSERT command
    • SET clause of the UPDATE command
    Restrictions on Calling Functions from SQL Expressions
    To be callable from SQL expressions, a user-defined
    function must:
    • Be a stored function
    • Accept only IN parameters
    • Accept only valid SQL data types, not PL/SQL
    specific types, as parameters
    • Return data types that are valid SQL data types,
    not PL/SQL specific types
    • Functions called from SQL expressions cannot
    contain DML statements.
    • Functions called from UPDATE/DELETE statements
    on a table T cannot contain DML on the same table
    T.
    • Functions called from an UPDATE or a DELETE
    statement on a table T cannot query the same table.
    • Functions called from SQL statements cannot
    contain statements that end the transactions.
    • Calls to subprograms that break the previous
    restriction are not allowed in the function.
    jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get the values of Select-options from the screen.

    The value of parameter can be obtained by function module 'DYNP_VALUES_READ' but How to get the values of Select-options from the screen? I want the F4 help values of select-options B depending on the values in Select-option A.So I want to read the Select-option A's value.

    Hi,
    Refer this following code..this will solve your problem...
    "Following code reads value entered in s_po select options and willprovide search
    "help for s_item depending upon s_po value.
    REPORT TEST.
    TABLES : ekpo.
    DATA: BEGIN OF itab OCCURS 0,
    ebelp LIKE ekpo-ebelp,
    END OF itab.
    SELECT-OPTIONS   s_po FOR ekpo-ebeln.
    SELECT-OPTIONS s_item FOR ekpo-ebelp.
    INITIALIZATION.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_item-low.
      DATA:
      dyn_field TYPE dynpread,
      temp_fields TYPE TABLE OF dynpread,
      zlv_dynpro TYPE syst-repid.
      zlv_dynpro = syst-repid.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname     = zlv_dynpro
          dynumb     = syst-dynnr
          request    = 'A'
        TABLES
          dynpfields = temp_fields
        EXCEPTIONS
          OTHERS     = 0.
      LOOP AT temp_fields INTO dyn_field.
        IF dyn_field-fieldname EQ 'S_PO-LOW'.
            SELECT * INTO CORRESPONDING fields OF TABLE itab FROM ekpo
            WHERE ebeln EQ dyn_field-fieldvalue.
            EXIT.
        ENDIF.
      ENDLOOP.

  • HOW TO PASS THE DATA FROM SELECTION SCREEN TO STANDARD TRANSACTION?

    HI,
    HOW TO PASS THE DATA FROM SELECTION SCREEN TO STANDARD TRANSACTION?
    thanks,
    samba.

    By selection screen, what do you mean?   There is no selection screen in WDA as there was in classic dynpro. Do you mean you are using the Select-Options reusable component?  Are you wanting to call a standard transaction via ITS - SAPGUI for HTML?  Please provide more details to your question.

  • How to avoid the event has been repeated many times in the background

    Application, the main screen is divided into two containers:left and  right container,
    The right side of the container is divided into two containers:top and  bottom container,
    There is a button in the left container.
    Click the button, the container at lower right will using ModuleManager  load Module,  The following container load of the right of the screen  has been monitoring the container above the action.
    Problem:
    When you click the button repeatedly to load the container in the lower  right, it will create multiple instances, and can not be freed  immediately. When the above container do an action or event, there are  multiple instances of monitoring exist.
    The background will be repeat the action or event many times.
    How to avoid the event has been repeated many times in the background?
    Thanks

    Flex harUI
    multiple instances of a mxml, maybe ?

  • How to avoid the long time consuming process of settlement on periodic basi

    For investment Project(purpose of capitalisation) related expenses We would like to show it  Directly in Balance Sheet rather than P/L  A/C.Whether it is feasible or not?as per one of consultant it will be first hit the p/L and after settlement it will only be shown in B/Sheet.So how to avoid the long time consuming process of settlement on periodic basis.

    Hi, could you write down an example? And what you mean by investment project-is this an WBS?

  • How to get the index of selected values in SelectManyChoice...

    How to get the index of selected values in SelectManyChoice... the value which i get is coming when i submit the value second time

    By using the given code i get the value of the selected indices, but problem here is i get the value when it get submits at the second time... First time the length of that int array is 0.
    Second time it shows the value two times (i.e) First time submitted value and the second time submitted value. After that it works fine.. I have problem while clicking first time only..
    The Following error also raises.. One multiselect is dependent on other multiselect.
    DF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase PROCESS_VALIDATIONS 3
    java.lang.ArrayIndexOutOfBoundsException: 6
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.findObjectFromIndex(FacesCtrlListBinding.java:334)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.getInputValue(FacesCtrlListBinding.java:199)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGet(JUCtrlValueBinding.java:2416)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.internalGet(JUCtrlListBinding.java:3717)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.internalGet(FacesCtrlListBinding.java:500)
         at oracle.adf.model.binding.DCControlBinding.get(DCControlBinding.java:749)
         at javax.el.MapELResolver.getValue(MapELResolver.java:164)
         at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
         at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
         at com.sun.el.parser.AstValue.getValue(Unknown Source)
         at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)

Maybe you are looking for

  • Hibernate not working on my MacBook Pro - it just turns off

    Ive had this machine for 2 years, and it has NEVER managed to hibernate. The battery runs for about an hour, then at about 20% left it just shuts down the machine, losing all my work. I have looked everywhere for an option to change this, but cant fi

  • How do I fix this error?

    I have this pop-up as you can see in the image, but I cannot click any buttons (Allow/Deny) with my arror/mouse. I'm using Google Chrome, Windows 7, 64-bit, and the latest version of Flash. I think the problem may be because I have increased the font

  • Good practice on passing GUI information to classes?

    I'm totally new to GUI programming suing java and swing components. So far I have onlu done GUI programming with old fashoned C-style approach. Anyway, I have a GUI built upon a tabbed pane, which holds alot of information. Every pane has components

  • Quicktime 7.4 blues!! FCE won't open...

    I'm having the same problem as many others are expressing with the new Quicktime 7.4 messing up my Final Cut Express. I can't open it (FCE) since I have updated my Quicktime. I read the article about using Pacifist, but I am confused about how to do

  • Freeze columns in form

    Is there a way I could freeze panes in a tabular form. I have a form with 40 columns and by the time I reach towards the end , I forget what my initial column values were