Evaluated order of Pivot and UnPivot in select statement

My research which evaluated order of select statement is below.
1 from
2 where (Join condition)
3 start with
4 connect by
5 where (filter of rows)
6 group by
7 having
8 model
9 select
10 order byMy question is Where Pivot clause and UnPivot clause ?
http://download.oracle.com/docs/cd/E16338_01/server.112/e10592/statements_10002.htm

Provided that you can specify columns created by the PIVOT clause both in the select and in the Order By clause, I think the pivot must be executed before them:
SQL> r
  1  select job, d10,d20,d30 from emp
  2  pivot (sum(sal) for deptno in (10 as D10, 20 as d20, 30 as d30))
  3* order by d20
JOB              D10        D20        D30
CLERK                       800
CLERK                      1100
MANAGER                    2975
ANALYST                    3000
ANALYST                    3000
SALESMAN                              1600
PRESIDENT       5000
MANAGER         2450
SALESMAN                              1500
SALESMAN                              1250
CLERK           1300
MANAGER                               2850
SALESMAN                              1250
CLERK                                  950
Selezionate 14 righe.
Piano di esecuzione
Plan hash value: 1739977809
| Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT     |      |    14 |   518 |     5  (40)| 00:00:01 |
|   1 |  SORT ORDER BY       |      |    14 |   518 |     5  (40)| 00:00:01 |
|   2 |   HASH GROUP BY PIVOT|      |    14 |   518 |     5  (40)| 00:00:01 |
|   3 |    TABLE ACCESS FULL | EMP  |    14 |   518 |     3   (0)| 00:00:01 |
-----------------------------------------------------------------------------Max

Similar Messages

  • Lock Table and permit only SELECT-Statement

    Hi all,
    can I lock a Table and permit only SELECT-statements on a Table?
    Regards
    Leonid

    Hi Kamal,
    I would like to configure it in such a way that if I implement the SELECT statement, another user can't insert
    a data into the table.
    If it is possible, I even the LOCK would like in such a way to configure the fact that the entry of the user arrives into the buffer and if the table is unlocked, all lines from the Buffer again into the table.
    I make it in such a way:
    SQL Script script_test.sql:
    set echo off
    set verify off
    set pagesize 0
    set termout off
    set heading off
    set feedback off
    lock table mytable in share row exclusive mode;
    spool c:\Temp\script_info.lst
    select id||'|'||dae||'|'||name||'|'||name1||'|'||hiredate
    ||'|'||street||'|'||nr||'|'||plznum||'|'||city
    ||'|'||email||'|'||telephon||'|'||cddfeas||'|'||number
    ||'|'||why||'|'||fgldwer||'|'||wahl||'|'||adress
    ||'|'||las
    from mytable
    where las is null
    spool off
    spool c:\Temp\select_from_all_tables.lst
    select *
    from all_tables
    order by owner
    spool off
    spool c:\Temp\select1_from_all_tables.lst
    select *
    from all_tables
    order by owner
    spool off
    update mytable
    set las = 'x';
    commit;
    set feedback on
    set heading on
    set termout on
    set pagesize 24
    set verify on
    set echo on
    Afterwards I start another session:
    insert into briefwahl
    values(38,'11.06.2003 09:37','Test','Test','01.01.1990',
    'Test','12','90000','Test',
    '[email protected]','12345657','test','123',
    'test','test','test','test',
    null);
    Then I go into the first session and start script. And I go immediately into the second session and do commit; And although I have the table closed, the new entries are spent also with spool into the .lst-File. Why, I do not understand. And in the table all lines become updated.
    Regadrs
    Leonid
    P.S. Sorry for my English. I have write with translator.

  • PIVOT and UNPIVOT

    I have a column called Qty and AMt
    QTY     AMT
    1          2
    1           1
    2           2
    I need to pivot/unpivot this in such a way that I need a collumn called Measurecode and Measure
    MeasureCode         Measure
    QTY                            1
    AMT                             2
    QTY                             1
    AMT                              1
    QTY                              2
    AMT                              2
    How do I do this?
    SPPandey

    You must have a column that uniquely identifies each row in the original table. Otherwise, after unpivot shuffle rows may occur. For example, if you need sorting by Measure column.
    -- code #1
    ;with QA as (
    SELECT ID, 1 as Seq, QTY, AMT
    from table
    union all
    SELECT ID, 2, QTY, AMT
    from table
    SELECT ID,
    MeasureCode= case when Seq=1 then 'QTY' else 'AMT' end,
    Measure= case when Seq=1 then QTY else AMT end
    from QA
    order by ID, MeasureCode desc;
    or
    -- code #2
    SELECT ID, MeasureCode, Measure
    from table
    unpivot (Measure for MeasureCode in (QTY, AMT)) as U;
    If there is no column that identifies the rows, you can create temporary column with sequence before the unpivot:
    -- code #2 v2
    SELECT Seq, MeasureCode, Measure
    from (SELECT Seq= row_number() over (order by (SELECT 0)), QTY, AMT from table) as S
    unpivot (Measure for MeasureCode in (QTY, AMT)) as U;
    José Diz     Belo Horizonte, MG - Brasil

  • Are Pivot and Unpivot supported in SSRS

    We're upgrading from SSRS 2005 to 2008 R2.  I'm rewriting some of my reports and using Unpivot. In SQL it works fine when I run it against the database.  But in SSRS (BIDS 2008) when I paste the working SQL statement into the Query Builder, I get
    an error that "The UNPIVOT SQL construct or statement is not supported".  If i click OK and preview my report, it does run.  So, I'm not sure why I'm getting this error.  Has anyone had experience with this?
    Milissa Hartwell

    Thats a known issue with query designer in SSRS. You dont need to worry much on it as report still works fine. If you're so concerned on the pop up make query into a stored procedure and call stored procedure from SSRS dataset query. Then you wont get
    any of these issue.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Pivot and Unpivot in Oracle 10g

    Hi,
    This is my table structure
    CREATE TABLE TESTTABLE
    REVENUE1 NUMBER,
    REVENUE2 NUMBER,
    REVENUE3 NUMBER,
    YEAR DATE
    insert into testtable(revenue1, revenue2, revenue3, year) values(100,200,300,'1-Jan-2009') ;
    insert into testtable(revenue1, revenue2, revenue3, year) values(250,350,450,'1-Jan-2010') ;
    insert into testtable(revenue1, revenue2, revenue3, year) values(300,400,500,'1-Jan-2011') ;
    The resultant should be on oracle 10g.
    The result should be like
    1-Jan-2009 1-Jan-2010 1-Jan-2011
    Revenue1 100 250 300
    Revenue2 200 350 400
    Revenue3 300 450 500
    Thanks in advance

    Hi,
    Naveen wrote:
    ...Thanks for the reply but this will not make the year as the column header it will be shown as a row in the result set.That's exactly what I thought you wanted, based on your first message:
    Naveen wrote:
    The result should be like
    1-Jan-2009 1-Jan-2010 1-Jan-2011
    Revenue1 100 250 300
    Revenue2 200 350 400
    Revenue3 300 450 500It would have been clearer if you had said: "The result set should be like these 3 rows:
    {code}
    Label 1-Jan-2009 1-Jan-2010 1-Jan-2011
    Revenue1 100 250 300
    Revenue2 200 350 400
    Revenue3 300 450 500
    {code}
    When posting formatted text (such as results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Column names are hard-coded into the query.  To get variable data, such as '1-Jan-2009' as a column header, you must use dynamic SQL.  This is probably best done in your front-end.  SQL*Plus, for example, has substitution variables, that you can define with data from your table at run-time using the COLUMN ... NEW_VALUE command.  (SQL*Plus also has a COLUMN ... HEADING command that can do what you want, , but it doesn't simplify this particular problem.)
    What front-end tool are you using?  Can you use SQL*Plus?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to use 'OR'  & 'AND' together in SELECT statement.

    Hi All,
    I am a BW person. Dont know much about ABAP. But i m trying to write a start routine in BW Transfer Rules.
    I m stuck at one point where i need to check multiple values using a slect statement.
    My requirement is like
    SELECT single * into wa_MEMPLOYEE from /BI0/QEMPLOYEE
      where EMPLOYEE eq L_S_DATAPAK_LINE-PERNR AND
        EMPLGROUP EQ ('1 OR '2' OR '7') AND
       CNTRCTTYPE EQ ('01' OR '05' OR '09' OR '50' OR '60').
    I tried using 'IN' .But this works only partially.
    EMPLGROUP IN ('1', '2', '7') AND
        CNTRCTTYPE IN ('01' , '05' , '09' , '50' , '60').
    when i use 'IN', the code checks the EMPLHROUP properly.But it will allow all other CONTRACT TYPE records to be written to the internal table.
    Can any one tell me how can i achieve this please.
    Cheers
    POPS

    Hi,
    You can do as below:
    "Create ranges for EMPLGROUP  AND CNTRCTTYPE
    ranges : gr_empgrp for <tablename-fieldname>,
                 gr_cntrtype for <tablename-fieldname>.
    initialization.
    gr_empgrp-sign = 'I'.
    gr_empgrp-option = 'EQ'.
    gr_empgrp-low = '1'.
    append gr_empgrp.
    gr_empgrp-sign = '2'.
    gr_empgrp-option = 'EQ'.
    gr_empgrp-low = '1'.
    append gr_empgrp.
    gr_empgrp-sign = '7'.
    gr_empgrp-option = 'EQ'.
    gr_empgrp-low = '1'.
    append gr_empgrp.
    gr_cntrtype-sign = 'I'.
    gr_cntrtype-option = 'EQ'.
    gr_cntrtype-low = '1'.
    append gr_cntrtype.
    gr_cntrtype-sign = 'I'.
    gr_cntrtype-option = 'EQ'.
    gr_cntrtype-low = '05'.
    append gr_cntrtype.
    gr_cntrtype-sign = 'I'.
    gr_cntrtype-option = 'EQ'.
    gr_cntrtype-low = '09'.
    append gr_cntrtype.
    gr_cntrtype-sign = 'I'.
    gr_cntrtype-option = 'EQ'.
    gr_cntrtype-low = '50'.
    append gr_cntrtype.
    gr_cntrtype-sign = 'I'.
    gr_cntrtype-option = 'EQ'.
    gr_cntrtype-low = '60'.
    append gr_cntrtype.
    SELECT single * into wa_MEMPLOYEE from /BI0/QEMPLOYEE
      where EMPLOYEE eq L_S_DATAPAK_LINE-PERNR AND
        EMPLGROUP in gr_empgrp AND
       CNTRCTTYPE in cntrtype.
    Thanks,
    Sriram Ponna.

  • Order of records in o/p  of select statement

    Hi all
    I have doubt regarding the select statement. I need to execute a select statement (with out any order ie with out "order by") which searchs a table. I want to know whether in any
    circumstances the order of the records of the select statement is different.
    sample select statement which I need to execute
    select emp_no from emplyees where designation = 'programer'
    in one word order of records of in the o/p of a select statement will be unique ?
    (provided same query same, table,)
    can u plz quote the link to get more information
    regards
    Renjith

    Hi,
    YES, you can
    Do Order By Without Using Order By Clause
    in your select statement.
    I assume that you have unique data ( e.g. emp_no in Emp Table ) and you you do not want to use Order by clause.
    Solution 1:
    Select Emp_no
    from Emp
    group by Emp_no;
    the o/p will be in the sorted in the Ascending order.
    Solution 2: ( Only for columns holding Numeric Values )
    Select Emp_No
    From Emp
    Where 99999 - Emp_no in ( Select 99999 - Emp_no from Emp );
    Again this will sort the result will be in the Descending Order. you can use any big number instead of 99999 but it should be greater than Emp_no value.
    Note: You Should only use this method on not very large tables coz of performance issue.
    Hope this will solve your problem.
    Any Comment on this, any body.
    Thanks and Regards
    There is always a solution to the problem, And if there is no solution of a problem then problem is not a problem.

  • HOW CAN I  USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?

    HI,
    I AM SHABEER AHMED,
    I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA  BASED ON HEADER DATA .
    THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
    BYE

    Hi,
    1.Just see this:
    SELECT * INTO CORRESPONDING FIELD OF TABLE itab
    FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
    INNER JOIN t3 ON t2f5 EQ t3f5 AND
    t2f6 EQ t3f6 AND
    t2f7 EQ t3f7.
    2.But better to use for all entries.It increases the performance.
    FOR ALL ENTRIES
    Tabular Conditions
    The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
    SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
    <cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
    The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
    You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
    Example for ALL ENTRIES
    DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
    TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
    WITH UNIQUE KEY TABLE LINE,
    WA LIKE LINE OF TAB_SFLIGHT.
    SELECT CARRID CONNID
    INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
    FROM SPFLI
    WHERE CITYFROM = 'NEW YORK'.
    SELECT CARRID CONNID FLDATE
    INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
    FROM SFLIGHT
    FOR ALL ENTRIES IN TAB_SPFLI
    WHERE CARRID = TAB_SPFLI-CARRID AND
    CONNID = TAB_SPFLI-CONNID.
    LOOP AT TAB_SFLIGHT INTO WA.
    AT NEW CONNID.
    WRITE: / WA-CARRID, WA-CONNID.
    ENDAT.
    WRITE: / WA-FLDATE.
    ENDLOOP.
    INNER JOINS
    In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
    SELECT...
    FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
    where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
    A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
    The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
    The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
    Example for INNER JOINS
    REPORT demo_select_inner_join.
    DATA: BEGIN OF wa,
    carrid TYPE spfli-carrid,
    connid TYPE spfli-connid,
    fldate TYPE sflight-fldate,
    bookid TYPE sbook-bookid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY carrid connid fldate bookid.
    SELECT pcarrid pconnid ffldate bbookid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( spfli AS p
    INNER JOIN sflight AS f ON pcarrid = fcarrid AND
    pconnid = fconnid )
    INNER JOIN sbook AS b ON bcarrid = fcarrid AND
    bconnid = fconnid AND
    bfldate = ffldate )
    WHERE p~cityfrom = 'FRANKFURT' AND
    p~cityto = 'NEW YORK' AND
    fseatsmax > fseatsocc.
    LOOP AT itab INTO wa.
    AT NEW fldate.
    WRITE: / wa-carrid, wa-connid, wa-fldate.
    ENDAT.
    WRITE / wa-bookid.
    ENDLOOP.
    Regards,
    Shiva Kumar(Reward if helpful).

  • Problem with select statement using Ranges

    Hi Guys,
                   I have used Ranges and used a select statement for selecting those ranges but I am facing a problem.
    RANGES: r_doctyp for EDIDC-DOCTYP.
    r_doctyp-sign = 'I'.
    r_doctyp-option = 'EQ'.
    r_doctyp-low  = 'DEBMAS'.
    append r_doctyp.
    r_doctyp-sign = 'I'.
    r_doctyp-option = 'EQ'.
    r_doctyp-low  = 'MATMAS'.
    append r_doctyp.
    r_doctyp-sign = 'I'.
    r_doctyp-option = 'EQ'.
    r_doctyp-low  = 'PRICAT'.
    append r_doctyp.
    r_doctyp-sign = 'I'.
    r_doctyp-option = 'EQ'.
    r_doctyp-low  = 'ORDERS'.
    append r_doctyp.
    r_doctyp-sign = 'I'.
    r_doctyp-option = 'EQ'.
    r_doctyp-low  = 'INVOIC'.
    append r_doctyp.
    Select DOCNUM                                " IDoc number
           DOCTYP                                " IDoc Type
                 from  EDIDC into table IT_ZEDIDC
                 where CREDAT EQ s_credat-low
                 and   DOCTYP EQ r_doctyp        " IDOC Types
                 and   DIRECT EQ '1'.
    Here my select statement is only taking INVOIC.
    But my statement should take any document type.
    Thanks,
    Prasad.

    Hi...,
    Your following select statement is correct.
    Select DOCNUM                                " IDoc number
                DOCTYP                                " IDoc Type
                from  EDIDC into table IT_ZEDIDC
                where CREDAT IN s_credat
                and   DOCTYP IN r_doctyp        " IDOC Types
                and   DIRECT EQ '1'.
    Why you are not getting result..
    1. structure of the IT_ZEDIDC is having two fields DOCNUM , DOCTYP  with same data lengths. If not it should be...
    2. Order in the database table is must be similer to the order you maintained in the select statement.
    3. As you are hard coding the input ranges make sure about every letter.
    4. take a look at other where condition fields too.
    5. check the table of the ranges in debugging mode.
    6. why can't you declare separate work area and table for ranges...?
      like .... data: r_tab type range of <field>
                 data: wa_tab like line of r_tab.
    7. Use clear work area statement after the append statment.
    --Naveen Inuganti.

  • Regarding select statement for this requirement

    Hi................
    good evening
    here is a requirement.
    i want to retrieve data from the following table.but how to join these table is my dought.
    tables  fields
    t001w--werks " plant id
    t001w--name1 " pl;ant name
    t001w--regio " plant address
    ekko--ebeln " purchase  order
    ekko-erdat : creation date
    ekko-ernam "name of the person
    ekpo-ebelp " item
    ekpo-bstyp "purchase order type
    eket-erdat " delivery date
    mara-matnr " material number
    these are the tables and fields.now we want to retrive data from these tables
    how we have to code select statement.
    selection-screen is
    plant id
    order type
    delivery date
    please provide select statement for this requirement.
    thanks and regards.
    k.swaminath  reddy.

    Is this what you are looking for?
    SQL> CREATE OR REPLACE FUNCTION f_team
      2  RETURN VARCHAR2
      3  IS
      4    s_return VARCHAR2(500);
      5  BEGIN
      6    FOR i IN ( select team from t_team order by 1) LOOP
      7      s_return := s_return || i.team || ', ';
      8    END LOOP;
      9   
    10    RETURN substr(s_return, 1, length(s_return) - 2);
    11  END;
    12  /
    Function created.
    SQL>  SELECT f_team FROM dual;
    F_TEAM
    Australia, Bangladesh, England, India, Kenya, Pakistan, South Africa, UAE, USA, West Indies, Zimbabwe
    SQL>

  • Retrieving multiple values from one column in SELECT statement

    Hi,
    I have a slight dilemma in that I'm trying to pull down all the values from a column from a select statement that includes some JOINS in it.
    If I run the query at the SQL Plus prompt, it pulls back all the values/rows.
    When I run the select (and prepared ) statement in my JSP, it only pulls back one of the 4 values I'm trying to retrieve.
    e.g.
    at the DB level :
    SELECT role_name, CC_ID FROM votetbl a
    INNER JOIN APPROVERS b ON
    a.BUSVP = b.BUSVP AND
    a.BRANCH = b.BRANCH
    WHERE CC_ID = 1688this will return:
    ROLE_NAME CC_ID
    ops 1688
    ops 1688
    comply 1688
    legal 1688
    comply 1688
    When run in my JSP, like so:
    String primID3a = request.getParameter("primID");
    Statement stmtovoter = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    String prepvotSQL = "SELECT role_name, CC_ID FROM votetbl a INNER JOIN APPROVERS b ON a.BUSVP = b.BUSVP AND " +
                         "a.BRANCH = b.BRANCH WHERE CC_ID = ?";
    PreparedStatement prepvotstmt = connection.prepareStatement(prepvotSQL);
    prepvotstmt.setString(1, primID3a);
    ResultSet rest3 = prepvotstmt.executeQuery();
    rest3.next();
    String votecat = rest3.getString(1);
    out.println("Vote category: "+votecat);I only get ops returned.
    Do I need to run an enumerator? Or reqest.getParameterValues or use a while statement around the results set?
    Any feedback and direction here is welcomed!
    Thanks!

    Actually, I tried looping and still only get 1, but returned several times.
    i.e.
    PreparedStatement prepvotstmt = connection.prepareStatement(prepvotSQL);
    prepvotstmt.setString(1, primID3a);
    ResultSet rest3 = prepvotstmt.executeQuery();
    rest3.next();
    String votecat = rest3.getString(1);
    while (rest3.next()) {
    out.print("category roles "+votecat);
    }then I get returned the following:
    admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admincategory roles admin
    like so.
    Where as at the DB level I get
    ROLE_NAME CC_ID
    admin 1688
    ops 1688
    ops 1688
    ops 1688
    ops 1688
    ops 1688
    ops 1688
    ops 1688
    risk 1688
    comply 1688
    legal 1688
    legal 1688
    ops 1688
    comply 1688
    Maybe the while should go around the getString(1) designation? But I was thinking I'd tried that and gotten invalid cursor error
    Something is definitely amiss, between the prepared statement in the servlet and the SELECT statement at the DB level.
    I can totally hardcode the statement in the servlet or JSP and it will return one value potentially several times, but only one.
    Other times, it will not return a value at all, even though one resides in the db.
    Yet go to the DB/SQL Plus prompt and it returns perfectly. I can simply copy and paste the SELECT statement from the out.print line I made and it works like a champ in SQL Plus. Any ideas why the same exact thing cannot return the proper values within the servlet/JSP?
    Yeeeeeeesh!!! : (
    Message was edited by:
    bpropes20

  • Executing a stored procedure containing multiple Select statements

    Post Author: Beverly
    CA Forum: General
    I am using Crystal  10.0 against a MS SQL 2000 server.
    I am trying to create a report based on a stored procedure that contains multiple select statements.  The sp requires a single parameter (Claim number) and contains 17 Select statements that produce results.
    I am able to use the Add command and execute the sp with the parameter, but I am only getting the results of the first select statement in the sp back in my data set.  Is there a way to have the data from each Select statement returned to my report?
    I have used Crystal for a while, but pretty much for straight-forward reporting.  I am familiar with the basics of SQL.
    I would appreciate any help anyone can offer.
    Thanks.

    Post Author: BISoftware
    CA Forum: General
    I believe Crystal Reports can only handle one recordset at a time, which means it can only handle a single select statement.  The only way I can see around this would be to break up your stored procedure into multiple stored procedures, so that each only contains a single select statement.  Then, use subreports to report on each individual sp. Hope this helps. - Davewww.BusinessSoftwareResource.com

  • Internal table -Select statement -2nd plant is not being filled

    Hi,
    Second field for plant WERKD is not getting filled in this table.I am using into corresponding fields of table ITAB statement.
    I need both plants and in single select statement.
    Any ideas?
    DATA: BEGIN OF T_STOF OCCURS 0,
        VBELN LIKE LIPS-VBELN,
        ERNAM LIKE LIPS-ERNAM,
        WERKS LIKE LIPS-WERKS,
        NTGEW LIKE LIPS-NTGEW,
        GEWEI LIKE LIPS-GEWEI,
        EBELN LIKE EKKO-EBELN,
        WERKD LIKE EKPO-WERKS,
        LGORT LIKE EKPO-LGORT,
        EBELP LIKE EKPO-EBELP,
        MATNR LIKE EKPO-MATNR,
        TXZ01 LIKE EKPO-TXZ01,
        AEDAT LIKE EKPO-AEDAT,
        KNUMV LIKE EKKO-KNUMV,
        END OF T_STOF.
      SELECT  LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
      EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
      INTO CORRESPONDING FIELDS OF TABLE T_STOF
      FROM LIKP
      INNER JOIN LIPS
      ON LIKPVBELN EQ LIPSVBELN
      INNER JOIN EKKO
      ON LIPSVGBEL EQ EKKOEBELN
      INNER JOIN EKPO
      ON EKKOEBELN EQ EKPOEBELN
      WHERE LIKP~VBELN IN S_VBELN
      AND LIKP~ERNAM IN S_ERNAM
      AND LIPS~WERKS IN S_WERKS
      AND EKKO~EBELN IN S_EBELN
      AND EKPO~WERKS IN S_WERKD
      AND EKPO~LGORT IN S_LGORT
      AND EKPO~MATNR IN S_MATNR
      AND EKPO~AEDAT IN S_AEDAT
      AND BSART = 'UB'.
    Or am i doing in wrong?
    Regards
    Praveen

    Hi,
    If you use INTO CORRESPONDING then the fieldname in the internal table has to match the selecting field name..
    To avoid this you can use INTO TABLE...
    SELECT LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
    EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
    <b>INTO TABLE T_STOF</b>
    Thanks,
    Naren

  • JDBC: Dynamic select statement

    Hi,
    I am working on a JDBC to SAP integration. I am trying to SELECT data from table for a specific time interval.
    In the JDBC configuration i am using the Query SQL Statement
    For example: select * from X where time='20080808'
    Now is it possible to use for example the system date and time of the server where pi is installed or any other dynamic data?
    Maybe like this: select * from X where time =@sysdate
    If it is possible how? If not why?
    I appreciate your help.
    Thanks in advance...

    Hi,
    In case of receiver JDBC you can map todays date to the select statement and make the select statement dynamic, however in the sender it can't be done. The work around may be to call the stored procedure from the sender adapter and using the stored procedure construct the select query dynamically.
    Thanks
    SaNv...

  • Select Statement takes more time after immediate insert statement..

    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.
    Thanks in Advance
    Sach

    sach09 wrote:
    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.Are you running the query in the other session after running it from the first?
    Aman....

Maybe you are looking for