Again select statement.

hi all
i am having a problem in result,the following query is giving me wrong result.i want the result something like this.
PLD_ID           count          TP               Compul
U01                259            3434234       37676454
U02                184             533234         76867676but the result is comming something like this which is wrong.
PLT_ID     SUM(COUNT_POL)            TP           COMPUL
U01     259                     0          0
U01     0                 77660       125507
U02     184                 0                   0
U02     0                 184943          484733here is the query.
SELECT PLT_ID,SUM(COUNT_POL),tp,compul
FROM
SELECT   pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL,
SUM(DECODE(pcd_IRS_id,55,PCD_AMOUNT_LC,0)) TP,
SUM(DECODE(PCD_IRS_ID,56,PCD_AMOUNT_LC,0)) COMPUL
FROM table1
where trunc(pcd_registry_date)=TRUNC(SYSDATE)
AND PCD_PLT_ID IN ('U01','U02')
AND PCD_IRS_ID IN (55,56)
GROUP BY PCD_PLT_ID
UNION
SELECT PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL,
0 tp,
0 compul
FROM table2
WHERE  trunc(PLM_registry_date)=TRUNC(SYSDATE)
and plm_plt_id in ('U01','U02')
GROUP BY PLM_PLT_ID)
GROUP BY plt_id,compul,tp
ORDER BY PLT_IDany help would be greatly appreciated.thanks in advance.
sarah

You can't or won't get what you desire using UNION so eliminate that
Re: how to do union.
Re: select statement,view and union.
Edited by: sb92075 on Jul 5, 2010 11:56 AM

Similar Messages

  • Getting error while executing this select statement

    Hi All,
    I am new to this community.
    I am getting error whie compiling the below code. Its telling 'Text' is invalid identifier. Also i want to know how can we obtain 'parseable' version of the below query?
    my basic intention is to create a trigger header through a select statement and show it the complete text as a single column..
    select text from
    (select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
    AFTER INSERT
    OR UPDATE
    OF '||column_name||',
    OR DELETE ON '||table_name||'
    FOR EACH ROW'
    FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
    lower(replace(t.table_name,'_A_','_')) table_name,
    lower(t.table_name) table_name1,
    c.column_id
    FROM all_tab_columns c,
    (SELECT object_name table_name
    FROM all_objects
    WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
    WHERE c.table_name(+) = t.table_name
    AND SUBSTR(column_name(+),1,2) = 'O_'))

    thanks prathamesh. it solved the problem. i have one more question.
    as of now it creates single create trigger statement for each column on a table.
    example:
    CREATE OR REPLACE TRIGGER ust_aud
    AFTER INSERT
    OR UPDATE
    OF cust_id,
    OR DELETE ON characteristic_t
    FOR EACH ROW
    however, i want to create trigger for all columns in a single statement. can you please help me how to do it?
    basically want to 'CREATE TRIGGER' for all columns in a table. i am finding difficult how to change my query to suit this!!
    i am pasting my original query again for your reference. pls advise...
    example:
    CREATE OR REPLACE TRIGGER ust_aud
    AFTER INSERT
    OR UPDATE
    OF cust_id,
    fixed_item_val,
    copy_item_val,
    rgn_id,
    txn_id,
    OR DELETE ON characteristic_t
    FOR EACH ROW
    ORIGINAL QUERY
    select text from
    (select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
    AFTER INSERT
    OR UPDATE
    OF '||column_name||',
    OR DELETE ON '||table_name||'
    FOR EACH ROW' text
    FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
    lower(replace(t.table_name,'_A_','_')) table_name,
    lower(t.table_name) table_name1,
    c.column_id
    FROM all_tab_columns c,
    (SELECT object_name table_name
    FROM all_objects
    WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
    WHERE c.table_name(+) = t.table_name
    AND SUBSTR(column_name(+),1,2) = 'O_'))

  • Increase performance of the following SELECT statement.

    Hi All,
    I have the following select statement which I would want to fine tune.
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          INTO TABLE GT_RESB 
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
    The following query is being run for a period of 1 year where the number of records returned will be approx 3 million. When the program is run in background the execution time is around 76 hours. When I run the same program dividing the selection period into smaller parts I am able to execute the same in about an hour.
    After a previous posting I had changed the select statement to
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          APPENDING TABLE GT_RESB  PACKAGE SIZE LV_SIZE
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
      ENDSELECT.
    But the performance improvement is very negligible.
    Please suggest.
    Regards,
    Karthik

    Hi Karthik,
    <b>Do not use the appending statement</b>
    Also you said if you reduce period then you get it quickly.
    Why not try dividing your internal table LT_MARC into small internal tables having max 1000 entries.
    You can read from index 1 - 1000 for first table. Use that in the select query and append the results
    Then you can refresh that table and read table LT_MARC from 1001-2000 into the same table and then again execute the same query.
    I know this sounds strange but you can bargain for better performance by increasing data base hits in this case.
    Try this and let me know.
    Regards
    Nishant
    > I have the following select statement which I would
    > want to fine tune.
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    >                       INTO TABLE GT_RESB 
    > FOR ALL ENTRIES IN LT_MARC
    >                       WHERE XLOEK EQ ' '
    > AND MATNR EQ LT_MARC-MATNR
    >                       AND WERKS EQ P_WERKS
    > AND BDTER IN S_PERIOD.
    >  
    > e following query is being run for a period of 1 year
    > where the number of records returned will be approx 3
    > million. When the program is run in background the
    > execution time is around 76 hours. When I run the
    > same program dividing the selection period into
    > smaller parts I am able to execute the same in about
    > an hour.
    >
    > After a previous posting I had changed the select
    > statement to
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    > APPENDING TABLE GT_RESB
    >   PACKAGE SIZE LV_SIZE
    >                     FOR ALL ENTRIES IN LT_MARC
    >   WHERE XLOEK EQ ' '
    >                     AND MATNR EQ LT_MARC-MATNR
    >   AND WERKS EQ P_WERKS
    >                     AND BDTER IN S_PERIOD.
    > the performance improvement is very negligible.
    > Please suggest.
    >
    > Regards,
    > Karthik
    Hi Karthik,

  • 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 use a select statement with chinese characters?

    I am currently developing a java servlet<using tomcat 4.x> which allows me to use select statement to retrieve results from the Microsoft SQL Server 2000 database. I am using a simple form to get the parameter for querying. The main problem i'm facing is that there are chinese information in the SQL database, but i can't retrieve it through the sql statement with the chinese characters input<thru the form with the help of NJ STAR>in the WHERE condition. When i execute the statement, it returns me no results even though the rows are present in the database.
    Does anyone have the solution to using chinese words in the WHERE clause of the select statement to retrieve results with columns which contains chinese characters? Please help me. Thanks everyone. :)
    PS: when i cut and paste those characters in the sql database and paste onto java.. it is ??? in questionmarks.. but when i paste them into excel 2000.. its shown as chinese chars again..
    please heelppp~~

    Greetings,
    PS: when i cut and paste those characters in thesql
    database and paste onto java.. it is ??? in
    questionmarks.. but when i paste them into excelThis is why the SELECT is not returning any results.
    You need to set the character encoding set on your
    statement and parameters for the characters to be
    properly translated. Refer to the charsetName
    parameter in the String class constructor in your API
    docs and also to
    $JDK_DOCS/guide/intl/encoding.doc.html in your JDK
    documentation.
    2000.. its shown as chinese chars again..Because Office programs are performing the same kind
    of character translation with the appropriate MS APIs.
    please heelppp~~Regards,
    Tony "Vee Schade" Cookis it possible for you to show me some coding examples? i don't really understand what is to be done in order to set the char set and what does it really do.. tried reading up but still dun understand.. :(
    pardon my shallow knowledge of java..
    ok..
    The thing is when i used an insert statement with chinese characters of GBK format hardcoded into the java servlet and then i use the insert statement to insert the chars into the database, it cannot be seen as a chinese word when i off the NJStar. and then it can be searched out with my current form of servlet.. below is my coding of the servlet..
    note: i've set my html file to charset = GBK
    //prototype of Search engine...
    //workable for GBK input and output...
    import java.io.*;
    import java.io.OutputStream;
    import java.io.IOException;
    import javax.servlet.http.*;
    import javax.servlet.ServletException;
    import java.util.*;
    import java.sql.*;
    import java.nio.charset.Charset;
    public class SearchBeta extends HttpServlet {
         private Vector musicDetails = new Vector();
         private String query = "";
         public void service (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException, UnsupportedEncodingException {
              query = req.getParameter ("T1");
              System.out.println("before:"+query);
              String type = req.getParameter ("D1");//type
              query = req.getParameter ("T1");
              //query = "������";
              System.out.println("after:"+query);
              getResults(type,query);
              System.out.println("locale = :"+req.getLocale());
              res.setContentType ("text/html;charset=GBK");
              PrintWriter out = res.getWriter();
              out.println("<html>");
              out.println("<head>");
              out.println("<body bgcolor = \"black\">");
              out.println("<font face = \"comic sans ms\" color=\"Cornsilk\">");
              if (query.length()==0)
                   out.println ("Please key in your search query.");
              else if (musicDetails.size()==0)
                   out.println ("Sorry, no results matching your search can be found.");
              else {
                   out.println("<center>");
                   out.println("<table cellspacing = \"50\">");
                   int i = 0;
                   //Display the details of the music
                   while (i<musicDetails.size()) {
                        Results details = (Results)musicDetails.get(i);
                        String dbArtist = "";
                        String dbAlbum = "";
                        String dbTitle = "";
                        String dbCompany = "";
                        dbAlbum = details.getAlbum();
                        dbTitle = details.getTitle();
                        dbCompany = details.getCompany();
                        dbArtist = details.getArtist();
                        try{
                             dbAlbum = new String(dbAlbum.getBytes("ISO-8859-1"),"GBK");
                             dbTitle = new String(dbTitle.getBytes("ISO-8859-1"),"GBK");
                             dbCompany = new String(dbCompany.getBytes("ISO-8859-1"),"GBK");
                             dbArtist = new String(dbArtist.getBytes("ISO-8859-1"),"GBK");//correct translation.
                        catch(UnsupportedEncodingException e){
                             System.out.print(e);
                             e.printStackTrace();
                        String dbImage_loc = details.getImage();
                        out.println("<tr>");
                             out.println("<td><table>");
                                  out.println("<img src=C:\\Program Files\\Apache Group\\Tomcat 4.1\\webapps\\examples\\ThumbNails\\"+dbImage_loc+">");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Artist: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbArtist+"</font></td>");
                             out.println("</tr>");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Title: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbTitle+"</font></td>");
                             out.println("</tr>");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Company: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbCompany+"</font></td>");
                             out.println("</tr>");
                             System.out.println("album: "+ dbAlbum);
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Album: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbAlbum+"</font></td>");
                             out.println("</tr>");
                             System.out.println("company: "+ dbCompany);
                             out.println("</table></td>");
                        out.println("</tr>");
                        i++;
                   out.println("</table>");
                   out.println("</center>");
              out.println("</font>");
              out.println("</body>");
              out.println("</head>");
              out.println("</html>");
              out.close();
              //to remove all the elements from the Vector
              musicDetails.removeAllElements();
         //get Searched Music Details and store in Results object which is stored in musicDetails vector
         public void getResults (String type, String searchQuery) {
              try {
                   Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                   Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=music","sa","kokkeng");
                   Statement stmt = con.createStatement();
                   String query = "SELECT * FROM MusicDetails WHERE "+type+" = '"+searchQuery+"'";
                   ResultSet rs = stmt.executeQuery(query);
                   while (rs.next()) {
                        String artist = rs.getString("Artist");
                        String title = rs.getString("Song");
                        String company = rs.getString("Company");
                        String album = rs.getString("Album");
                        String image_loc = rs.getString("Image");
                        Results details = new Results (artist,title,company,album,image_loc);
                        musicDetails.add(details);
                   stmt.close();
                   con.close();
              catch (Exception e) {
                   System.out.println(e.getMessage());
                   e.printStackTrace();
    with the above servlet i created, i can search out the data in the database which i've inserted through the insert statement. I still can't search for things i've keyed into the database directly using NJStar..
    thank you so much for helping.. really hope any one else who knows the answer to this will reply too... thank you all so much...
    -KK

  • "Check Statistics" in the Performance tab. How to see SELECT statement?

    Hi,
    In a previous mail on SDN, it was explained (see below) that the "Check Statistics" in the Performance tab, under Manage in the context of a cube, executes the SELECT stament below.
    Would you happen to know how to see the SELECT statements that the "Check Statistics" command executes as mentioned in the posting below?
    Thanks
    ====================================
    When you hit the Check Statistics tab, it isn't just the fact tables that are checked, but also all master data tables for all the InfoObjects (characteristics) that are in the cubes dimensions.
    Checking nbr of rows inserted, last analyzed dates, etc.
    SELECT
    T.TABLE_NAME, M.PARTITION_NAME, TO_CHAR (T.LAST_ANALYZED, 'YYYYMMDDHH24MISS'), T.NUM_ROWS,
    M.INSERTS, M.UPDATES, M.DELETES, M.TRUNCATED
    FROM
    USER_TABLES T LEFT OUTER JOIN USER_TAB_MODIFICATIONS M ON T.TABLE_NAME = M.TABLE_NAME
    WHERE
    T.TABLE_NAME = '/BI0/PWBS_ELEMT' AND M.PARTITION_NAME IS NULL
    When you Refresh the stats, all the tables that need stats refreshed, are refreshed again. SInce InfoCube queries access the various master data tables in quereis, it makes sense that SAP would check their status.
    In looking at some of the results in 7.0, I'm not sure that the 30 day check is being doen as it was in 3.5. This is one area SAP retooled quite a bit.
    Yellow only indicates that there could be a problem. You could have stale DB stats on a table, but if they don't cause the DB optimizer to choose a poor execution plan, then it has no impact.
    Good DB stats are vital to query performance and old stats could be responsible for poor performance. I'm just syaing that the Statistics check yellow light status is not a definitive indicator.
    If your DBA has BRCONNECT running daily, you really should not have to worry about stats collection on the BW side except in cases immediately after large loads /deletes, and the nightly BRCONNECT hasn't run.
    BRCONNECT should produce a lof every time it runs showing you all the tables that it determeined should have stats refreshed. That might be worth a review. It should be running daily. If it is not being run, then you need to look at running stats collection from the BW side, either in Process Chains or via InfoCube automatisms.
    Best bet is to use ST04 to get Explain Plans of a poor running InfoCube query and then it can be reviewed to see where the time is being spent and whether stats ate a culprit.

    Hi,
    Thanks, this is what I came up with:
    st05,
    check SQL Trace, Activate Trace
    Now, in Rsa1
    on Cube, Cube1,
    Manage, Performance tab, Check Statistics
    Again, back to st05
    Deactivate Trace
    then click on Displace Trace
    Now, in the trace display, after scanning through  the output,
    “ … how do I see the SELECT statements that the "Check Statistics" command executes …”
    I will appreciate your help.

  • What is proper syntax for using PassBack in a Report page select statement

    In my select statement I reference the passBack function using:
    onClick="javascript:passBack()"
    In my Page Header I (Typically) define the passBack function as:
    <script language="JavaScript" type="text/javascript">
    function passBack(passVal1,passVal2) {
    opener.document.getElementById("P2000_CABLE_ID").value = passVal1;
    opener.document.getElementById("P2000_CABLE_LABEL").value = passVal2;
    window.opener.location.reload(true);
    </script>
    But I have never used the passBack function from the Select statement before and cannot happen onto the proper syntax.
    The Page Items I want to pass are:
    1. :P2004_CABLE_ID
    2. :P2004_LABEL
    I want to pass them to:
    1. :P2000_CABLE_ID
    2. :P2000_CABLE_LABEL
    Can someone please help me out... Again?
    Thanks- Gary

    Let's assume column XYZ has both numbers (1), and letters (any alphabet).
    I have a case statement on SQL to turn any value that's not 1 into 0, then I am getting a sum of that column.
    I am also grouping by Row A, B etc to get aggregated sum of column XYZ for those group.
    Now on Crystal Reports function, I need to sum up values under column XYZ for all the groups.
    If I try using sum function like below, I get an error stating:
    "A number field or currency amount field is required here"
    (sum({Command.XYZ}))
    So I thought if I can use a case statement to change the non-numbers to 0 prior to sum that will probably resolve it. But I could not get the below case statement to work either (Error: A string is required). 
    SELECT {Command.XYZ}
       Case 1:
          1 
       Default:
          0;

  • Conditional Mysql select statement

    HI Folks
    can anyone point me in the right direction with a MySQL statement.
    I will try to layout my thinking here:
    I have a form with three inputs area, name and search. I am trying to write a Mysql select statement that selects records from a single table if they match the criteria. Easy for two variables but I'm lost after that.
    1. The form includes these three inputs:
    area - drop down menu (Any as default)
    name - drop down menu (Any as default)
    search box - text area (Blank as default)
    2. The form submits to itself leaving me with these three variables
    $search=$_GET['search']
    $area=$_GET['area']
    $name=$_GET['area']
    SELECT * FROM database WHERE database.description LIKE '%$search%' AND database.area LIKE '$area' AND database.name LIKE '$name'
    3. This is where I get confused. How do I get the SQL to Select everything correctly. I have tried using PHP if/else code to fix it but I end up running around in circles with six different Select statements and haven't yet got that to work.
    So I have come to the conclusion that there must be an easier way.  I see search forms with dozens of  search criteria on websites every day an d I only have 3 - so it can't be this complicated. Right?
    I know I need to start from the beginning again but can anyone let me know how to approach it before I begin?
    Cheers
    Dave

    Typically, I would build the where clause dynamically, based upon the values in your form. If the form field contains 'Any', leave it out of the where clause. So you can test each field value and either append or not to the end of the where clause.

  • Clarification on Select statement

    Hello all,
    can u please any one tell me the solution.
    In one condition.
    i am getting the data from marc mkpf and mseg
    my requirement is
    get the material number from marc based on plant on selection screen
    get some data from mkpf table based on posting date(budat) on selection screen entered .
    then
    get the material data from mseg table based on matnr = equal to point1
                                                   mblnr = equal to point2
                                                   mjahr = equal to point2.
                                here some fields is there that equal to selection screen fields.
    for that i have written the code like this
    one way:
    select matnr
           werks
      from marc
      into table out_it_marc
    where werks in s_werks.
    sort out_it_marc by matnr werks.
    delete adjacent duplicates from out_it_marc
                        comparing matnr werks.
    loop at out_it_marc into lfl_marc.
    vr_matnr-low = lfl_marc-matnr.
    vr_matnr-sign = c_in.
    vr_matnr-option = c_eq.
    append vr_matnr.
    clear : lfl_marc.
    endloop.
    FORM get_mseg_data
                   tables i_r_matnr  structure vr_matnr
                    USING  in_it_mkpf  type t_it_mkpf
                  changing out_it_mseg type t_it_mseg.
    if not in_it_mkpf[] is initial.
    select
            MBLNR    "Number of Material Document
            MJAHR   "Material Document Year
            BWART    "Movement Type (Inventory Management)
            MATNR    "Material Number
            WERKS    "Plant
            LGORT   "Storage location
            SOBKZ    "Special Stock Indicator
            LIFNR   "Vendor's account number
            KUNNR    "Account number of customer
            DMBTR    "Amount in local currency
            MENGE    "Quantity
            MEINS    "Base Unit of Measure
            EBELN    "Purchase order number
            KOSTL    "Cost Center
            AUFNR    "Order Number
            BUKRS    "company code
            PS_PSP_PNR  "Work Breakdown Structure Element (WBS Element)
            SAKTO  "G/L account number
         from mseg
          into table out_it_mseg
        for all entries in in_it_mkpf
      where mblnr eq in_it_mkpf-mblnr
        and mjahr eq in_it_mkpf-mjahr
        and bwart in s_bwart
        and matnr in vr_matnr
        and werks in s_werks
        and kostl in s_kostl
        and ps_psp_pnr in s_pspnr.
    endif.
    but its getting dump because of so many records
    so that i have written again like this.
    FORM get_mkpf_mseg_data  USING  in_it_marc type t_it_marc
                             changing out_it_mkpf_mseg type t_it_mkpf_mseg.
    if not in_it_marc[] is not initial.
    select A~mblnr
           A~mjahr
           A~budat
           A~cpudt
           A~cputm
           A~usnam
           A~xblnr
           B~BWART    "Movement Type (Inventory Management)
           B~MATNR    "Material Number
           B~WERKS    "Plant
           B~LGORT   "Storage location
           B~SOBKZ    "Special Stock Indicator
           B~LIFNR   "Vendor's account number
           B~KUNNR    "Account number of customer
           B~DMBTR    "Amount in local currency
           B~MENGE    "Quantity
           B~MEINS    "Base Unit of Measure
           B~EBELN    "Purchase order number
           B~KOSTL    "Cost Center
           B~AUFNR    "Order Number
           B~BUKRS    "company code
           B~PS_PSP_PNR  "Work Breakdown Structure Element (WBS Element)
           B~SAKTO  "G/L account number
      INTO TABLE out_it_mkpf_mseg
      from mkpf AS A INNER JOIN MSEG AS B
      ON AMBLNR = BMBLNR
      AND AMJAHR = BMJAHR
      FOR ALL ENTRIES IN IN_IT_MARC
      WHERE B~MATNR  = IN_IT_MARC-MATNR
        AND B~WERKS  = IN_IT_MARC-WERKS
        AND A~BUDAT IN S_BUDAT
        AND B~BWART IN S_BWART
       AND MATNR  = IN_IT_MSEG-MATNR
       AND WERKS  = IN_IT_MSEG-WERKS
        AND B~KOSTL IN S_KOSTL
        AND B~PS_PSP_PNR IN S_PSPNR.
      ENDIF.
    BREAK-POINT.
    ENDFORM.                    " get_mkpf_mseg_data
    but this select statement is not working properly
    is there anyway to solve it.
    please give me the solution ASAP, its urgent.
    Thanks in advance....

    Hi bs,
    you dont\'t have to build a range table vr_matnr for the selection, you just can use for all entries. See help on WHERE-clause:
    Suppose FTAB is filled as follows:
    CARRID  CONNID
    LH      2415
    SQ      0026
    LH      0400
    SELECT * FROM sflight INTO wa_sflight
        FOR ALL ENTRIES IN ftab
        WHERE CARRID = ftab-carrid AND
              CONNID = ftab-connid AND
              fldate = '20010228'.
      free = wa_sflight-seatsocc - wa_sflight-seatsmax.
      WRITE: / wa_sflight-carrid, wa_sflight-connid, free.
    ENDSELECT.
    Cheers,
    Stefan

  • Selected state issue with Menu Module V2

    OK so I am getting an issue with Menu Module V2. I have used this before with success but this time I have hit a wall. I possed this question to BC live chat and they bugged out real quick.
    The site in construction is http://www.urbanista.com.au
    What is happening is that in the top right tools nav with the headings Home, Services, People, Contact Us using Menu Module V2. The Heading Services has a drop down and this is where the issue resides. Roll over any of these nav devices and you will see they will highlight orange. Home is already auto activating its Selcted state. Click on Contact Us and it will do the same.  Roll over and click on Services and it appears to have worked. While in Services roll over the drop down again and you will see all links have activated the Selected state. This is the issue. If you view the code of the Services UL you will see only the Services state has been alocated the Slected state. See below:
    <li id="Services" class="selected">
    <a href="/services.htm">Services</a>
    <ul>
    <li id="tools-panningdev">
    <li id="tools-housing">
    <li id="tools-urban-renewal">
    <li id="tools-project-management">
    <li id="tools-feasibility-tools">
    <li id="tools-governance-systems">
    <li id="tools-communications">
    <li id="tools-projects">
    </ul>
    </li>
    The CSS that runs the nav is as follows:
    ul.dropdown {
        font-weight: normal;
        font-family: Arial, Helvetica, sans-serif;
        font-style: normal;
        text-decoration: none;
        ul.dropdown li {
        background-color: transparent;
        color: #999;
        padding-top: 5px;
        padding-right: 10px;
        padding-bottom: 5px;
        padding-left: 10px;
        font-size: 12px;
        ul.dropdown li.hover,
        ul.dropdown li:hover {
        background-color: transparent;
        color: #FFF;
        ul.dropdown a:link,
        ul.dropdown a:visited    {
        color: #FFF;
        text-decoration: none;
        ul.dropdown a:hover        { color: #ff871f; }
        ul.dropdown a:active    {
        color: #b33b00;
        /* -- level mark -- */
        ul.dropdown ul {
        width: 150px;
        margin-top: 1px;
        background-image: url(/images/nav-transparency.png);
        background-repeat: repeat;
        color: #FFF;
        ul.dropdown ul li {
        font-weight: normal;
    ul.dropdown li.selected a {
        color: #ff871f;
    The last entry 'ul.dropdown li.selected a {color: #ff871f;}' is required in order to allocate a Slected State. Without it not Selected state is active and the links al remian white.
    I have tried all manner of combinations and additonal tags with no success. Any suggestions greatly appreciated. I have not modified the default Javascript provided by BC in the system apart from allocating the required ulTagClass as specified. The Javascript in the supplied 'container.html' is as follows:
    <script type="text/javascript" >
        // ids need to be unique per page, use different ones if you are including multiple menus in the same page
        // id of the nav tag, used above
        var divTagId = "myMenu1";
        // desired id for 1st <ul> tag
        var ulTagId = "myMenu1List";
        // desired class for 1st <ul> tag
        var ulTagClass = "dropdown dropdown-vertical";
        if ((null !== ulTagId) && ("" !== ulTagId)) {
            document.getElementById(divTagId).getElementsByTagName("ul")[0].setAttribute("id",ulTagId );
        if ((null !== ulTagClass) && ("" !== ulTagClass)) {
            document.getElementById(divTagId).getElementsByTagName("ul")[0].className = ulTagClass;
        // this will set the selected state
        if ((null !== ulTagId) && ("" !== ulTagId)) {
            catSetSelectedCSSItem(ulTagId);
    </script>
    Lastly this is one of the recomended navs by BC at the following address: http://lwis.net/free-css-drop-down-menu/
    I have used these before with success but for the life of me this has stumped me big time.

    Hi Matthew,
    Having a super quick look at the code I'd say it's because of:
    ul.dropdown li.selected a {
        color: #ff871f;
    This affects all the child elements.
    To override this down the line you could do something like:
    ul.dropdown li.selected ul li a {
        color: #fff;
    This would override the parent link color when selected.
    You could probably then also add:
    ul.dropdown li.selected ul li.selected a {
        color: #ff871f;
    For the dropdown selected states.
    That's a quick look though so don't quote me too much

  • Update with a select statement

    hi experts,
    I need some help again.. :)
    I have an insert query here with a select statement.. Juz wondering how to do it in update?
    insert into newsmail_recipient
            (IP_RECIPIENTID,NF_LISTID,NF_STATUSID,D_CREATED,D_MODIFIED,C_NAME,C_EMAIL,USER_ID,NEWSMAIL_ID)
            select newsmail_recipientid_seq.nextval
              , liste
              , 1
              , sysdate
              , sysdate
              , null
              , null
              , ru.nf_userid
              , null
            from roleuser ru, unit u, userinfo ui
            where u.ip_unitid = ru.nf_unitid
            and u.ip_unitid = unit_id
            and ui.ip_userid = ru.nf_userid
            and ui.nf_statusid = 1
            and n_internal = 0
            and ui.ip_userid not in (select user_id
                                       from newsmail_recipient
                                      where user_id = ui.ip_userid
                                        and nf_listid = liste
                                        and nf_statusid = 1);let me know your thoughts.
    Regards,
    jp

    Hi,
    924864 wrote:
    ... I have an insert query here with a select statement.. Juz wondering how to do it in update?How to do what, exactly?
    MERGE can UPDATE existing rows, and INSERT new rows at the same time. In a MERGE statement, you give a table or a sub-query in the USING clause, and define how rows from that result set match rows in your destination table. If rows match, then you can UPDATE the matching row with values from the sub-query.
    Very often, MERGE is easier to use, and perhaps more efficient, than UPDATE just for changing existing rows. That is, while MERGE can do both INSERT and UPDATE, it doesn't have to . You can tell MERGE just to do one or the other if you wish.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Since you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Can't concatonate more than three items in a portal select statement ?

    I'm running a Report from SQL query
    as Far as I can tell you can't do;
    select 'blah1'||name||'blah3'||'blah3'
    from scott.emp
    as soon as you put in a 4th item it fails.
    It also fails using select concat (,)
    I'm trying to run a report which selects a web address stored in a database table ie. http://www.yahoo.com and wrap it in html tags so it will appear as a link.
    I've got to do it with more than three items because the only way to display the < in <ahref is to quote it seperately.
    ie
    '< '||'ahref='||ADDRESS FROM DATABASE||etc.etc.
    anyone any ideas?
    should i do it another way?

    Let me explain a bit further.
    If I want to display;
    www.yahoo.com as a link I need add the html tags
    Yahoo
    www.yahoo.com is an entry in a database.
    I want to select the entry www.yahoo.com from the database and concatonate it with the html tags.
    ideally;
    select 'Visit
    This does not work
    To concatonate characters like > in a select statement within portal you need to concat. seperately;
    select '< '||'a href="'||ADDRESS FROM DATABASE||'"> '||'Visit< '||'/a> '
    This does not work as you can't concat more than three items.
    Could I write a trigger to add in the html tags to the data stored in the database, when data is entered via a portal form?
    Again my problem is In need to add text to the start and end of the data being stored ie.
    user enters www.yahoo.com in a form
    a trigger or two converts that into;
    Visit

  • Select Statement Blocking Delete Operation

    Hi Experts,
    In a Single table am trying to do delete operation but it has been blocked by simple select query.
    Database setting : Read Committed Snapshot already set to ON for that database.
    Any Idea why SELECT blocking DELETE.
    FYI : Before Select statement I could noticed the following setting "set transaction isolation level  read committed".
    Kindly Advise
    Regards,
    Nandhu

    FYI : Before Select statement I could noticed the following setting "set transaction isolation level  read committed".
    Hi NandhuJana,
    1. Did you read
    Uri Dimant's response?
    Please try to remove this statement and check again
    2. When we ask you for DDL+DML , the idea is to let us the option to (1) reproduce the issue in some cases, (2) get the best information which is the real database structure, queries, etc'. In this case for example I do not see the isolation level statement
    in your code and we need it to understand what is happening :-) The order and structure (nested transactions for example) of statements is what important here.
    3. you can check your isolet level using one of those options to make sure what is going in your script:
    SELECT TRANSACTION_ISOLATION_LEVEL = CASE transaction_isolation_level
    WHEN 0 THEN 'Unspecified'
    WHEN 1 THEN 'ReadUncommitted'
    WHEN 2 THEN 'ReadCommitted'
    WHEN 3 THEN 'Repeatable'
    WHEN 4 THEN 'Serializable'
    WHEN 5 THEN 'Snapshot'
    END
    FROM sys.dm_exec_sessions
    where session_id = @@SPID
    GO
    DBCC USEROPTIONS WITH NO_INFOMSGS
    GO
    I hope this is helpful :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • How to : rownum and order by in select statement

    Say I have a select statement with additional 'order by' clause.
    The result set I want prepended by the rownum column.
    But, and here comes the flaw, I want the rownum for the already ordered result set
    not the unordered.
    An example:
    select firstname, lastname from myTable order by lastname;
    When I add the rownum to the select clause,
    'select rownum, firstname, lastname from myTable order by lastname;'
    I might get something like:
    20 Mike Adams
    13 Nina Bravo
    1 Tom Charlie
    But I want the following result:
    1 Mike Adams
    2 Nina Bravo
    3 Tom Charlie
    I could now
    'Select rownum, lastname, firstname from (select firstname, lastname from myTable order by lastname);
    But I guess there is a better way!?!
    which is the best way to accomplish that?
    Thanks for your advice!

    >
    'Select rownum, lastname, firstname from (select firstname, lastname from myTable order by lastname)
    >
    Well if you ask me there is very little difference between this query and the above query
    select rownum, lastname, firstname from mytable;Because rownum is assigned before the order by. The difference is in your query you are assigning a rownum to an ordered resultset but still there is no guarantee oracle is going to read the data in an ordered fashion. In the second query rownum is assigned to an unordered resultset. Again it is the samething. So if you want to guarantee it then I will go for the following option
    select row_number() over(order by lastname) rn, lastname, firstname from mytable
    order by lastnameAlso check this link.
    http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
    Regards
    Raj
    Edited by: R.Subramanian on Jan 13, 2009 6:20 AM

  • Select statement takes very long to run with order by clause.

    Hi all,
    I have a select statement which when I run without the order by clause takes arround 2 minutes to run. But with the order by clause it goes on for ever. I am trying to access the database server through a network which is not too fast.
    The select statement is based on 9 views which are again based on some views. It also has inline views and outer joins. These views and inline views can not be done away with.
    When selected without the order by clause it gives 3215 records.
    Anything like 2 to 3 minutes will be Ok.
    Thanks.
    --Malay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    The select statement is as follows :-
    SELECT f.system_name,
    a.signal_type,
    f.sys_signal_name,
    a.bus_desc,
    b.vl_ident,
    b.vl_name,
    b.src_mac,
    b.src_mac_addr,
    b.dest_mac,
    b.dest_mac_addr,
    b.network,
    bb.bufr_size_in_bytes,
    bb.bag_in_ms,
    bb.is_rma_used,
    bb.is_ic_used,
    bb.sub_vl_cnt,
    bb.skew_max_in_ns,
    cc.msg_name,
    c.src_ip,
    c.src_ip_addr,
    c.src_port,
    c.dest_ip,
    c.dest_ip_addr,
    c.dest_port,
    cc.rate_in_ms,
    cc.tx_mode,
    cc.protocol,
    cc.port_type,
    cc.msg_length_in_bytes,
    d.mnemonic,
    d.start_addr32,
    d.lsb,
    d.end_addr32,
    d.msb,
    d.format,
    d.init_value,
    d.fs_mnemonic,
    d.fs_afdx_data_id,
    d.digital_data_id,
    DECODE(
    d.digital_datatype,
    NULL, '',
    'UNUSED', '',
    api$util.concat_column_data(
    'api_'
    || d.digital_datatype,
    'digital_data_id',
    d.digital_data_id,
    bool.FALSE
    ) AS data_details,
    f.connection_id
    || '_'
    || a.digital_bus_id
    || '_'
    || b.afdx_vl_id
    || '_'
    || bb.afdx_output_id
    || '_'
    || c.afdx_frame_id
    || '_'
    || cc.afdx_msg_id
    || '_'
    || d.afdx_data_id AS KEY
    FROM api_afdx a,
    api_afdx_vl b,
    api_afdx_output bb,
    api_afdx_frame c,
    api_afdx_msg cc,
    api_afdx_data d,
    vf_signal e,
    (SELECT DISTINCT aa.signal_id,
    cc.system_name,
    bb.connection_id,
    bb.sys_signal_name
    FROM vf_nodes aa,
    vf_connections bb,
    vf_system cc
    WHERE aa.connection_id = bb.connection_id
    AND bb.system_id = cc.system_id) f
    WHERE e.signal_id = f.signal_id(+)
    AND e.digital_bus_id = a.digital_bus_id
                   AND a.digital_bus_id = bb.digital_bus_id(+)
    AND bb.afdx_output_id = b.afdx_output_id(+)
                   AND b.afdx_vl_id = c.afdx_vl_id(+)
    AND bb.afdx_output_id = cc.afdx_output_id(+)
    AND cc.afdx_msg_id = d.afdx_msg_id(+)
    ORDER BY f.system_name,
    a.signal_type,
    f.sys_signal_name,
    b.vl_name,
    cc.msg_name,
    d.start_addr32,
    d.lsb;
    Where api_afdx ,
    api_afdx_vl ,
    api_afdx_output ,
    api_afdx_frame ,
    api_afdx_msg ,
    api_afdx_data ,
    vf_signal ,
    vf_nodes ,
    vf_connections ,
    vf_system
    are all views.

Maybe you are looking for

  • How do I exit or eliminate the album cover screen in the music player?

    THe music app on iPhone6 has a screen with pictures of album covers of the music on the phone.  Once that screen appears how do I exit that screen to control the music?  Better eliminate that screen altogether as it seems useless.

  • Counter logic  in Function module of the generic extraction

    Hi, I had like to add this counter field which can be used in reporting.. As this extraction logic is bit different, i cannot include it in transformations with 1 as a constant.. so i am wrtiting this logic in Function Module.. in the main table loop

  • Draft Document Question - Credit Memo

    Hopefully one fo the experts will come through for me again!!! I have yet another challange.  When printing a Draft Credit memo,  I do not want to print the DRAFT water mark across the document.  I know how to shut that feature off.  Instead,  I woul

  • How do i uninstall adobe cs6 from windows 8

    Dear Sir/Madame, Due to I got the old one windows 8 (genuine license) notebook from my brother and it's install pirate adobe cs6 include this notebook but I don't use this program suite and I prefer to recover disk space. I try to uninstall in every

  • [svn:osmf:] 10134: Improvements to the VAST document object model.

    Revision: 10134 Author:   [email protected] Date:     2009-09-10 15:08:05 -0700 (Thu, 10 Sep 2009) Log Message: Improvements to the VAST document object model. Modified Paths:     osmf/branches/briggs-prototype/libs/VAST/.flexLibProperties     osmf/b