Select in From-Clause with JPQL

Hey,
I'm new to JPA development. How can I transform the following SQL-Statement:
select a from
Gpsj a,
(select c.tsid, c.wsid, max(c.gdat1) maxgdat from Gpsj c where c.tsid = '901' group by tsid, wsid) b
where a.tsid = b.tsid
and a.wsid = b.wsid
and a.gdat1 = b.maxgdat
I can't find any expression for using a (select-statement in a from-clause)
thanks
Nikolai

JPQL does not support sub-selects in the from clause. You can use a native SQL query for this in JPA.
James : http://www.eclipselink.org

Similar Messages

  • SELECT OID FROM clause not working

    The following statements gets ORA-00904: "OID": invalid identifier.
    The SELECT OID FROM clause is intended to pull in a REF to the MANAGER with MGR_ID= 000001.
    Oracle seems to think there are no OIDs for the entries in the MANAGERS table.
    INSERT INTO STORES VALUES (
    100001,
    ADDRESS(888, 'Main_Street', 'Rancho_Alegre', 'CA', '94049'),
    COF_ARRAY('Colombian', 'French_Roast', 'Espresso', 'Colombian_Decaf', 'French_Roast_Decaf'),
    (SELECT OID FROM MANAGERS WHERE MGR_ID = 000001)
    Here is how the MANAGER, MANAGERS, ans STORES were defined.
    CREATE TYPE MANAGER AS OBJECT (
    MGR_ID INTEGER,
    LAST_NAME VARCHAR(40),
    FIRST_NAME VARCHAR(40),
    PHONE char(10)
    CREATE TABLE MANAGERS OF MANAGER OBJECT IDENTIFIER IS SYSTEM GENERATED;
    CREATE TABLE STORES (
    STORE_NO INTEGER,
    LOCATION ADDRESS,
    COF_TYPES COF_ARRAY,
    MGR REF MANAGER
    My questions:
    1. I don't see any OIDs when I display the MANAGERS table with the Object Browser. That is normal it isn't it? Aren't they always hidden?
    2. Can anyone tell me what I am doing wrong?

    [Documentation Says....|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjdes.htm]
    The object identifier column is a hidden column that Oracle uses to construct references to the row objects. *Oracle provides no access to the internal structure of object identifiers*. This structure can change at any time. Applications are only concerned with using object references for fetching and navigating objects.
    In the above mentioned link is a link to what i think you're attempting...
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjint.htm#i458258

  • Save the selected value from listbox with its respective tab control dropdown selcted values in another listbox

    Hi all,
    I am making a vi where I have to save the selected value from listbox with its respective tab control dropdown selcted values in another listbox.Whenever I select Item1 then the heading change and respective tab will open for that item.But Now I just want to save the selection and put it in another ListBox.SO that I can renmove or add according to my wish. Plz help me.
    Solved!
    Go to Solution.
    Attachments:
    my_vi.png ‏83 KB

    Hi, I successfully make the vi to insert itmes from listbox1 to listbox2.Whenever I select itmes 1 in listbox 1 it display same elected item in listbox2 , but it not appending the items in listbox2.Like If 1 is selected in listbox1 then 1 will display , next time after saving when I selct next item like 3 then in listbox 2, 1 is replaced by 3,it dont come in second row of listbox2.Hope I am able to explain.\
    Plz help me to resolve this.
    Attachments:
    listbox_update.vi ‏11 KB

  • How to get selected values from datatable with paging

    hi all
    here is my problem
    I have a datatable with paging size of 2 and first column as checkbox.
    now i have total record of 5 data,2 row on each page.
    Now i m selecting 1-1 row from each page.
    When i m clicking Command button to display all the selected row from different page ,i m only able to display values selected from last page.
    Through debug i can see that only last page value is set to TRUE OR FALSE and every other value is neither true nor false.
    any help???
    thanks

    <f:facet name="footer">
    <h:panelGroup binding="#{Page1.groupPanel1}" id="groupPanel1"
    style="display: block; text-align: center" styleClass="list-paging-footer">
    <h:commandButton action="#{Page1.dataTable1_firstPageAction}" binding="#{Page1.dataTable1FooterFirstButton}" id="dataTable1FooterFirstButton" image="resources/paging_first.gif" immediate="true"/>
    <h:commandButton action="# Page1.dataTable1_previousPageAction}" binding="#{Page1.dataTable1FooterPreviousButton}"
    id="dataTable1FooterPreviousButton" image="resources/paging_previous.gif" immediate="true"/>
    <h:commandButton action="#{Page1.dataTable1_nextPageAction}" binding="#{Page1.dataTable1FooterNextButton}"
    id="dataTable1FooterNextButton" image="resources/paging_next.gif" immediate="true"/>
    <h:commandButton action="#{Page1.dataTable1_lastPageAction}" binding="#{Page1.dataTable1FooterLastButton}"
    id="dataTable1FooterLastButton" image="resources/paging_last.gif" immediate="true"/>
    </h:panelGroup>
    </f:facet>
    Above is the code which i m using for paging which is command button
    Any problem with it.???
    thanks

  • *Dynamic* Table Name in From Clause with input from cursor

    Hello
    I have a cursor say...
    select table_name from dba_tables where <blah>
    The result is
    row1:: emp
    rwo2:: emp_1 ---> Both the tables have same structure and entirely different data... please dont ask why... that's the way it is and we cant change it..
    Now we need to run an Insert...
    insert into tableX (col1,col2,...) select a,b,... from <o/p of the cursor> where <blah> ...
    Note: The table name changes and it the cursor can o/p emp,emp_a and emp_b.
    Am looking to do it parallel instead of doing it serially and with best performance ....no sql injection issues.
    By parallel i mean
    insert into tableX (col1,col2,...) select a,b,... from emp where <blah>
    and insert into tableX (col1,col2,...) select a,b,... from emp_1 where <blah> statements to fire parallel/at the same time to the database. If you can share procedure if you guys already have with you.. is really appreciated
    Thanks a lot for your time....
    Edited by: user007009 on Apr 27, 2013 8:33 PM

    Hello thanks for your time..
    I tried to implement the chunk by sql parallel execution approach and it took 3.1 seconds to complete.. while the SP took around 0.042 seconds and the parallel process didn't throwed any errors and it didn't insert any data either... I am not sure what I am doing wrong... can you please let me know your thoughts...
    Sample Data Creation::::::::::::::*
    drop table table_ASERCARE purge;
    drop table table_MEDCARE purge;
    DROP TABLE TABLE_XYCARE PURGE;
    DROP TABLE TABLE_TIME PURGE;
    DROP TABLE TABLE_LOCATION PURGE;
    drop table table_group purge;
    drop table tablex purge;
    -- select distinct TABLE_NAME from ALL_TAB_COLS where TABLE_NAME like 'EMP%';
    create table table_asercare (time number(30), location_number number(5), value number(5),catg_id number(5));
    insert into table_asercare values  (20110111, 01, 55, 1200);
    insert into table_asercare values  (20110131, 01, 31, 1223);
    insert into table_asercare values  (20120131, 15, 24,1224);
    insert into table_ASERCARE values  (20130131, 03, 555,1200);
    -- Truncate table table_MEDCARE
    create table table_medcare (time number(30), location_number number(5), value number(5),catg_id number(5));
    insert into table_medcare values  (20110113, 01, 23, 1200);
    insert into table_medcare values  (20110128, 02, 78, 1223);
    insert into table_medcare values  (20110130, 03, 100, 1224);
    insert into table_medcare values  (20120111, 04, 57, 1200);
    insert into table_medcare values  (20120221, 05, 64, 1223);
    insert into table_MEDCARE values  (20130321, 15, 48, 1224);
    create table table_xycare (time number(30), location_number number(5), value number(5),catg_id number(5));
    insert into table_xycare values  (20100113, 01, 99, 1200);
    insert into table_xycare values  (20110128, 02, 90, 1223);
    insert into table_XYCARE values  (20130128, 03, 24, 1224);
    create table table_LOCATION ( LOCATION_NUMBER number(5), LOCATION_NAME varchar2(50));
    insert into table_LOCATION values  (01, 'atlanta1');
    insert into table_LOCATION values  (02, 'atlanta2');
    insert into table_LOCATION values  (03, 'atlanta3');
    insert into table_LOCATION values  (04, 'atlanta4');
    insert into table_LOCATION values  (05, 'atlanta5');
    insert into table_location values  (15, 'atlanta15');
    create table table_category (catg_id number(5), catg_name varchar2(30));
    insert into table_category values (1200, 'EMS');
    insert into table_category values (1223, 'LJM');
    insert into table_category values (1224, 'LIO');
    create table table_TIME (YEAR_MONTH_DATE number(30), YEAR_VAL number(4), MONTH_VAL number(2),DATE_VAL number(2));
    insert into table_TIME values  (20110111, 2011, 01,11 );
    insert into table_TIME values  (20110131, 2011, 01,31);
    insert into table_TIME values  (20120131, 2012, 01,31);
    insert into table_TIME values  (20130131, 2013, 01,31);
    insert into table_TIME values  (20110128, 2011, 01,28 );
    insert into table_TIME values  (20110130, 2011, 01,30 );
    insert into table_TIME values  (20120111, 2012, 01,11 );
    insert into table_TIME values  (20120221, 2012, 02,21 );
    insert into table_TIME values  (20130321, 2013, 03,21 );
    insert into table_TIME values  (20100113, 2010, 01,13 );
    insert into table_TIME values  (20130128, 2013, 01,28 );
    --Truncate table table_group
    CREATE TABLE table_group (group_key number,table_name VARCHAR2(30), group_name VARCHAR2(30), catg_name varchar2(30));
    insert into table_group values (1,'table_ASERCARE', 'GROUP_ONE','EMS');
    insert into table_group values (2,'table_MEDCARE', 'GROUP_ONE','LJM');
    INSERT INTO TABLE_GROUP VALUES (3,'table_XYCARE', 'GROUP_TWO','LIO');
    create table TABLEX (YEAR_VAL number(4) ,LOCATION_NAME varchar2(50),tablename VARCHAR2(30), cnt number ); --> Proc data will be inserted into this...
    Stored Procedure++++++++_
    CREATE OR REPLACE
    PROCEDURE ABC(
        GROUP_NAME_IN IN VARCHAR2 )
    is
    type c1 is ref cursor;
        sql_stmt VARCHAR2(200);
        v_sql    VARCHAR2(30000);
        c1_cv c1;
        table_name_f VARCHAR2(30);
        c1_rec TABLE_GROUP%rowtype;
      BEGIN
        SQL_STMT := 'SELECT * FROM TABLE_GROUP WHERE GROUP_NAME = :i';
        OPEN c1_cv FOR SQL_STMT USING GROUP_NAME_IN ;
        loop
          fetch c1_cv  INTO c1_rec;
        exit when c1_cv%notfound;
    --    forall i in c1_rec.FIRST ..c1_rec.last loop
        table_name_f := c1_rec.table_name;
    --      END LOOP;
       EXECUTE immediate
       'INSERT  INTO tablex (YEAR_VAL,LOCATION_NAME, tablename, cnt)
    SELECT
    t.YEAR_VAL,l.location_name, :table_name, count(*) as cnt
    FROM '
        ||table_name_f||
        ' variable_table
    ,table_time t
    , table_location l
    ,table_group g
    ,table_category ctg
    WHERE t.year_month_date = variable_table.TIME
    and variable_table.location_number = l.location_number
    and ctg.catg_id = variable_table.catg_id
    --and ctg.catg_name = g.catg_name
    GROUP BY t.YEAR_VAL,l.location_name,g.catg_name' USING table_name_f;
        --dbms_output.put_line ( 'The SQL is'|| v_sql);
        COMMIT;
        --dbms_output.put_line ( c1_rec.table_name||','||c1_rec.group_name );
        --dbms_output.put_line ( 'The table name is '|| c1_rec.table_name );
      end loop;
        CLOSE c1_cv;
      --null;
    END ABC;
    Parallel Execution Code++++++++++_
    begin
    begin
    DBMS_PARALLEL_EXECUTE.DROP_TASK(task_name => 'TASK_NAME');
    exception when others then null;
    end;
    DBMS_PARALLEL_EXECUTE.CREATE_TASK(task_name => 'TASK_NAME');
    DBMS_PARALLEL_EXECUTE.CREATE_CHUNKS_BY_SQL(task_name => 'TASK_NAME', sql_stmt =>'select distinct group_key, group_key from table_group', by_rowid => false);
    end;
    begin
    DBMS_PARALLEL_EXECUTE.RUN_TASK (task_name => 'TASK_NAME',
    sql_stmt =>'declare
    s varchar2(16000); vstart_id number := :start_id; vend_id number:= :end_id;
    table_name varchar2(30);
    begin
    select table_name into table_name from group_table where group_key=vstart_id;
    s:=''INSERT  INTO tablex (YEAR_VAL,LOCATION_NAME, tablename, cnt)
    SELECT
    t.YEAR_VAL,l.location_name, :table_name, count(*) as cnt
    FROM ''||table_name||'' variable_table
    ,table_time t
    , table_location l
    ,table_group g
    ,table_category ctg
    WHERE t.year_month_date = variable_table.TIME
    and variable_table.location_number = l.location_number
    and ctg.catg_id = variable_table.catg_id
    and ctg.catg_name = g.catg_name
    and g.group_key =:vstart_id
    GROUP BY t.YEAR_VAL,l.location_name,g.catg_name'';
    execute immediate s using vstart_id;
    commit;
    end;',
    language_flag => DBMS_SQL.NATIVE, parallel_level => 2 );
    end;
    / thanks in advance for your time.
    Edited by: user007009 on Apr 28, 2013 12:25 PM

  • Select in FROM clause not working

    Hello,
    I have three tables with one table containing the name of the other two tables and i want to select dynamically the two selects based on their ID that matches in the first table.
    CREATE TABLE_NAMES (ID NUMBER, TableName VARCHAR(2) )
    CREATE TRADE (activites VARCHAR(2), TRADE_ID )
    CREATE CONTRACT(activites VARCHAR(2), TRADE_ID )
    INSERT INTO TABLE_NAMES ( 101, 'TRADE' );
    INSERT INTO TABLE_NAMES ( 202, 'CONTRACT' );
    INSERT INTO TRADE ('TRADE 1' , 101 )
    INSERT INTO CONTRACT ('CONTRACT 1' , 202 )
    What I wanted to do is select the table name dynamically based up on the id in TABLE_NAMES
    and I failed when doing this
    SELECT SELECTED_TABLE.activites FROM ( SELECT TABLE_NAME FROM TABLE_NAMES WHERE ID = 101 ) SELECTED_TABLE
    OR a more generic form with JOIN statement also did not work
    SELECT SELECTED_TABLE.activities FROM TABLE_NAMES SELECTION JOIN ( SELECT TABLE_NAME FROM TABLE_NAMES) SELECTED_TABLE
    ON SELECTION.ID = SELECTED_TABLE.TRADE_ID
    Thanks in advance

    What you are trying to do will not work. To accomplish your requirement you would have to use dynamic SQL.
    However, I want to stress that this is probably not a good design decision because:
    1. Maintainability of the code may be jeopardized
    2. Dynamic SQL could be laden with SQL injection vulnerabilities
    3. Dynamic SQL generally does not perform as well as static SQL.
    HTH!

  • Select user from dual with oid + oss ?

    Implementing a solution for global user administration, authentication and application schema mapping, will it break the simple but efficient possibility to do a 'select user from dual' ?
    If it is possible which value will we get, a global user identifier from the directory or something else ?
    Thanks in advance for your help

    Actually we authenticate user using internal database users. Each user depending on his enterprise role will have a set of synonyms deployed to map the application schema. It is complex to handle a large set of users schema. With OSS it seem to be possible to authenticate user using an external LDAP directory (OID) and to map this user to an application schema switch user's enterprise role.
    But I want to evaluate the impact of deployeing such solution, because our application use some 'select user from dual' single query to track user activity in some manner (this can be done using triggers or pl/sql api that do this job). If it is possible to have an unique user identifier in the database session context, even using external authentication and schema mapping of OSS we'll have less impact on the application. Else we'll have to change some API signatures to handle this user identifier.
    Context is :
    - use LDAP external functionalities provided with OSS to increase user management at an enterprise level ... single sign-on is our goal ,-)
    - use schema mapping to reduce our complexity of schema management. One schema foreach role rather than one schema per user.
    So, will we be able to individually know which user have the session in the database, rather than the shared schema name. If it is possible, the impact on our application will be really minor ...
    Thanks in advance for your help. If someone who read this lines have such system deployed and can try the 'select user from dual', I'll be glad on the answer that the database will give ,-)

  • Bug report select statement nested select in FROM Clause on Oracle 10g

    The SELECT statement below does not return the appropriate result; it used to work on Oracle 8, but it does not on 10g (10.2).
    Here is the table
    create table T (
    A numeric(4),
    B numeric(4)
    Some data
    insert into T (A,B) VALUES (1,null);
    insert into T (A,B) VALUES (2,1);
    insert into T (A,B) VALUES (3,1);
    insert into T (A,B) VALUES (3,2);
    The select statement returning the worng result
    select totals.A, totals.totalBbyA
    from (
    select t1.A, sum(t1.B) totalBbyA
    from T t1
    group by A
    ) totals
    where
    totals.totalBbyA >= all
    select sum(nvl(t2.b,0)) from T t2 group by t2.a
    it returns "no rows selected"
    An equivalent select that does return the good result
    select t1.A, sum(t1.B) totalBbyA
    from T t1
    group by A
    having
    sum(t1.B) >= all
    select sum(nvl(t2.b,0)) from T t2 group by t2.a
    It returns
    A TOTALBBYA
    3 3
    Best regards

    910893 wrote:
    but it does not on 10g (10.2).Works fine in:
    SQL> select  *
      2    from  v$version
      3  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select  *
      2    from  t
      3  /
             A          B
             1
             2          1
             3          1
             3          2
    SQL> select totals.A, totals.totalBbyA
      2  from (
      3  select t1.A, sum(t1.B) totalBbyA
      4  from T t1
      5  group by A
      6  ) totals
      7  where
      8  totals.totalBbyA >= all
      9  (
    10  select sum(nvl(t2.b,0)) from T t2 group by t2.a
    11  )
    12  ;
             A  TOTALBBYA
             3          3
    SQL> SY.

  • How to select value from list with multiple selections ?

    HI,
    i have a list with multiple selections where i show email address retrieved from database.
    what i want to do is to send the selected email address to the invoiceedit.jsp.
    please look at the following code which gives you the better idea.
    <td class='smalltext'><select name="email" size="3" multiple="multiple">
       <% 
       Connection conn = null;
       Statement stmt = null;
       Statement stmt_contactperson = null;
       Statement stmt_address = null;
       try{
          conn = getREConnection();
           stmt = conn.createStatement();
       ResultSet rs = null;
       rs = stmt.executeQuery("SELECT PROPERTYID, VALUE FROM PROPERTIES WHERE ENTITYID="+ g_strGroupID+" AND NAME = 'invoice_default_email'");
       int numofrows = 0;
       while(rs.next())
               %>
       <option value="<%= rs.getString("VALUE") %>" selected="selected"> <%= rs.getString("VALUE")  %> </option>
        <%
           }//end of while
          %>
         </select>
        <a href="invoiceedit.jsp?entityid=<%=g_strGroupID%>&add=1"><font color="#000000">Add</font></a>
         <a href="invoiceedit.jsp?entityid=<%=g_strGroupID%>&email_to="><font color="#000000"> Edit</font></a> </td>thanks

    Use a form button instead of a link so that you can send it as a request parameter to the server. In the server side just use HttpServletRequest#getParameterValues() to obtain all values for the given parameter name. If you really need a link rather than a button, then use Javascript to submit the form on click of the link.
    That said, your design is bad. Java code belongs in Java classes, not in JSP files. Database access logic belongs in a DAO class. Business and controlling logic belongs in a Servlet class. Only presentation logic belongs in the JSP file. Avoid scriptlets as much as possible and use JSP EL and/or JSTL instead.

  • ORA-01446 when selecting ROWID from View with Union

    I have a View that uses a Union to select from 3 tables. I would like the View to return the ROWID for the record that is returned so that I can update it in my form. The View compiles fine but when I select from the View I get ORA-01446 error.
    Example of my view:
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_a
    UNION ALL
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_b
    UNION ALL
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_c
    I need the ROWID because my tables do not contain UNIQUE/PRIMARY key constraints. In my form I want to update the view with an underlying INSTEAD OF database trigger.
    Any suggestions?

    I think it will work if you give the column an alias (ie a name after the first rowid) and select that instead.
    You will probably also need another column in your view indicating which table the row came from if you want to update it.

  • ORA-01446: cannot select ROWID from view with DISTINCT, GROUP BY, etc.

    Hi,
    I have created view by joining two tables...And it is like this...
    Create view Test_Data as
    Select t.column1, t.column2, t.rowid from table1 t
    union s.column1,s.column2, s.rowid from table2 s
    with read only...
    Now I executed the following stmt...
    Select * from Test_Data where rowid = objid_ where I am passing the objid_ value...But it gave me the above error...can not I run this select stmt using the rowid ?
    Any input is highly appreciated...
    Thanks And Best Regards,
    /Dinesh...
    Hi All Again,
    I created the view in the following way...Just to check...
    CREATE VIEW my_view AS
    SELECT t.col1 col1,
    t.col2 col2,
    t.rowid objid
    FROM table1 t
    WHERE rownum < 400
    UNION
    SELECT q.col1 col1,
    q.col2 col2,
    q.rowid objid
    FROM table2 q
    WITH read only;
    Then I executed the following stmt...
    Select * from my_view where rowid = objid_
    Then I did not get that Oracle Error ORA-01446, Does anybody have any clue regarding this matter, i.e. how the use of rownum solve this prob...
    Thanks And Best Regards,
    /Dinesh...
    Edited by: user521478 on Aug 9, 2010 4:46 PM

    Check this:
    SQL> create view my_view as select rowid rd from dual;
    View created.
    SQL> select * from my_view;
    RD
    AAAACsAABAAAAGiAAA
    SQL> select * from my_view where rd = 'AAAACsAABAAAAGiAAA';
    RD
    AAAACsAABAAAAGiAAA
    SQL> So your create view statement should be:
    Create view Test_Data as
    Select t.column1, t.column2, t.rowid rd from table1 t
    union s.column1,s.column2, s.rowid from table2 s
    with read onlyThen try:
    Select * from Test_Data where rd = objid;Edited by: AP on Jul 28, 2010 2:19 AM

  • Using Select in from clause involving Remote connections.

    The query below is using a remote link namely SBUP. The tables
    involved contain Gigabytes of information. it is taking forever
    to return since the inner query doing a full table scan.
    Is there any alternate way to do this query.
    SELECT DISTINCT REGISTER_DATE,POL_NO FROM (
    SELECT DISTINCT CURRENT_POL.REGISTER_DATE,
    CURRENT_POL.POL_NO
    FROM CURRENT_POLICY@SBUP CURRENT_POL,CUST_PART@SBUP
    CUST_PART,PTY_KEY_MAP@SBUP KEY_MAP
    WHERE KEY_MAP.NEW_PTY_ID = CUST_PART.PTY_ID AND
    CUST_PART.POL_NO
    = CURRENT_POL.POL_NO AND CUST_PART.CUST_PART_END_DT
    IS NULL
    AND INSTR('+136688330+','+' || KEY_MAP.PSNID || '+' )
    != 0
    ORDER BY CURRENT_POL.REGISTER_DATE,CURRENT_POL.POL_NO
    ) WHERE ROWNUM <= 6

    I believe that the usage of DISTINCT in the inner query may be
    preventing the usage of indexes. If you use DENSE_RANK in the
    inner query, which is a fast analytic function, then you can
    eliminate the DISTINCT from the inner query and just use
    DISTINCT in the outer query. However, the usage of INSTR may
    still slow things down somewhat. Please see if the following is
    any faster and let us know:
    SELECT   DISTINCT register_date, pol_no
    FROM     (SELECT current_pol.register_date,
                     current_pol.pol_no,
                     DENSE_RANK () OVER
                     (ORDER BY current_pol.reigster_date,
                      current_pol.pol_no) AS rk
              FROM   current_policy@sbup current_pol,
                     cust_part@sbup cust_part,
                     pty_key_map@sbup key_map
              WHERE  key_map.new_party_id = cust_part.pty_id
              AND    cust_part.pol_no = current_pol.pol_no
              AND    cust_part.cust_part_end_dt IS NULL
              AND    INSTR ('+136688330+', '+'
                     || key_map.psnid || '+') != 0)
    WHERE    rk <= 6
    ORDER BY register_date, pol_no

  • Dual Case Column names fail in select ORDER BY clause

    This one is solved, but I thought someone might be able to explain why it happens.
    I'm a newbie, since I just downloaded Oracel XE last night, and am trying it out.
    I set up a trivial table with 4 text columns. As it happened, I used dual case for some of my column names, such as 'Nickname'.
    When trying out the Query Builder, the Select statement failed whenever I added a sort.
    After some head scratching and back-and-forth with the sample data base (HR), I finally renamed all the columns to upper case. (e.g. column 'Nickname' became 'NICKNAME'). Then it works.
    Seems like a bug, but maybe it's just a feature. Here's the code generated by the Query Builder. As you can see, there are no quotes around the Table name or column names in the ORDER BY clause (and the dual case version of the column name works if I put the quotes in manually and run it with SQL command.) Seems quirky.
    select     "TEAMS"."NICKNAME" as "NICKNAME",
         "TEAMS"."CITY" as "CITY",
         "TEAMS"."DIVISION" as "DIVISION",
         "TEAMS"."CONFERENCE" as "CONFERENCE"
    from     "TEAMS" "TEAMS"
    order by TEAMS.NICKNAME ASC

    Welcome to forum. :)
    Now, answering your question - no i don't think this is a bug.
    It is your code - which create this bug.
    Now, question is - what happen?
    Just check your select and from clause. You put all the names are in double quote. When you put anything within double quotes - it become a case sensitive. So, the problem occurs there.
    Let's see ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.11
    satyaki>
    satyaki>create table s_otn
      2      (
      3        id    number(4)
      4      );
    Table created.
    Elapsed: 00:00:02.14
    satyaki>
    satyaki>set lin 80
    satyaki>
    satyaki>desc s_otn;
    Name                                      Null?    Type
    ID                                                 NUMBER(4)
    satyaki>
    satyaki>desc S_OTN;
    Name                                      Null?    Type
    ID                                                 NUMBER(4)
    satyaki>
    satyaki>desc s_OtN;
    Name                                      Null?    Type
    ID                                                 NUMBER(4)
    satyaki>
    satyaki>drop table s_otn;
    Table dropped.
    Elapsed: 00:00:05.22
    satyaki>
    satyaki>
    satyaki>create table "S_otn"  
      2       (
      3         id     number(4)
      4       );
    Table created.
    Elapsed: 00:00:00.12
    satyaki>
    satyaki>
    satyaki>desc S_otn;
    ERROR:
    ORA-04043: object S_otn does not exist
    satyaki>
    satyaki>desc S_OTN;
    ERROR:
    ORA-04043: object S_OTN does not exist
    satyaki>
    satyaki>desc s_otn;
    ERROR:
    ORA-04043: object s_otn does not exist
    satyaki>
    satyaki>desc "S_OTN";
    ERROR:
    ORA-04043: object "S_OTN" does not exist
    satyaki>
    satyaki>desc "S_otn";
    Name                                      Null?    Type
    ID                                                 NUMBER(4)
    satyaki>Got me?
    Regards.
    Satyaki De.

  • Selection criteria from table PLMZ for component allocation

    Hello All,
    I need to produce a report for the componenet allocation, my issue is after knowing that i hve to fetch data from plmz, i m stuck,
    reason is when i select entries from plmz with criteria plnnr and plnty it gives me more entries then those found when i do a ca03, can anyone please guide, wat i m looking for is exact number of entries and then the material and bom info, please point me to the right direction,
    thnaks,
    Hitesh

    Hi Hitesh,
    As Mr.Prasobh u have to join MAPL-PLMZ-PLPO tabls with matarial, Plant combination where LOEKZ is not equal X
    For BOM ITEM , Name u have to add to More table STPO, MAKT. The flow is as follows,
    1.First u can start with MAPL.
    input Field: MATNR - your Header  Material
                     WERKS -  your BOM plant
    Outfield for Next Table. PLNTY,PLNNR,PLNAL,LOEKZ (Not equal X).
    2. TABLE: PLMZ
        Input Field:  PLNTY,PLNNR,PLNAL,LOEKZ,WERKS ( from previous tables)
        output Field :  STLTY,STLNR,STLKN, PLNFL.
    3. Table: PLPO
         Input Field:  PLNTY,PLNNR,PLNAL,LOEKZ,WERKS.
       output field :VORNR,MEINH,BMSCH,
    4.Table: STPO
        Input Field:STLTY,STLNR,STLKN  (From table PLMZ )
        output field: IDNRK,POSNR,POSTP.
    5.Table MAKT.
        Input Field: IDNRK
         output field : MAKTX.
    what i have given is a flow to fetch the data.  Try it with  abab`rs  to develop report.
    i hope the above tables give  most of fields which you need   in  ca03 (com all view).
    plz reward point all of them if u found usefull.
    regards
    r.pradeep

  • SELECT statement in FROM clause - syntax help

    Hi,
    I want to have a SELECT statement in the FROM clause. I get syntax error when doing this and since I am new to ABAP I need som help.
    I want to do the following, (and if anyone has any SELECT statement from their own system which you know there is no syntax error in please post it here so I can analyze the syntax):
    *I leave the INTO itab clause out, since I only want to demonstrate the functionality
    I am trying to get.
    <b>SELECT</b> tableOne~someField
    <b>FROM</b> tab <b>AS</b> tableOne (<b>SELECT</b> someField
                                         <b>FROM</b> tab
                                         <b>WHERE</b> someFiled > 1) <b>AS</b> tableTwo
    <b>WHERE</b> tableOnesomeField > tableTwosomeField
    like I said, the problem is that the select statement in the parenthesis in the from clause seems to be incorrect because I get "wrong expression" when trying to compile. Is this because I cannot have a select statement in the from clause or is it because of a minor syntax error, such as I forgot a dot, or some other sign?
    thanks and regards
    Baran

    sorry i am not enough familiar with sub queries but some error i can see which i will state here.
    1> you have to use sub queries i.e. select in ( ) after where clause because here you are fulfilling a where clause by another select statement.
    like this
    SELECT * FROM SFLIGHT
        INTO WA
        WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
    2> you cannot specify field name without into clause either you have to use
    select *  or select f1 into tab-f1  like this...
    but if you are using select * without into you have to define
    tables : dbtab.
    selec * from dbtab. like that.
    regards
    shiba dutta

Maybe you are looking for

  • Looping particles in motion 4 don't loop in 5

    This is a little hard to explain so bear with me. I've long been creating looping particle emitters in Motion 4 using the trick where you set a constant birth rate that suddenly drops to 0 final keyframe at the end, duplicate the element, slide the d

  • How to reboot an imac to new.

    I am selling my imac to a friend and i want to reboot it so its like new but i dont have the disks to do it. does anyone know if you can do it another way or where i can get a disk from ? Thanks Dan

  • Database size history on Java instance

    Hello, Does anybody know how to get the database size history (db02) on a Java only instance. The system is portal 7 running on SQL 2005 and windows 2003. Thanks

  • Adobe Audition 6.0 is Crashing Auto Heal

    Has anyone experienced this with MAC version of Adobe Audition 6.0?  When using the Auto Heal tool, the software constantly crashes after applying an edit with tool.  Is there a patch or fix?  This happens often, in fact everytime I use the software.

  • Can I consolidate photo libraries in iphoto'11

    It appears my iPhoto files are in 3 different libraries.  Is it possible in iPhoto 11 to consolidate them?  Running Snow Leopard.