Toplink Essentials creates not usable select statement

My problem is the following:
I have the following NamedQuery statement in an JPA Entity Class:
@NamedQuery(name = "Leasingteilvertrag.findSearch",
query = "select distinct o " +
" from Leasingteilvertrag o " +
" left outer join o.sachbearbeiterList s " +
" where (:wtvStatusBearb1 is null or :wtvStatusBearb2 = -1 or o.wtvStatusBearb =
:wtvStatusBearb3)" +
" and (:wtvStatusVerwert1 is null or :wtvStatusVerwert2 = -1 or o.wtvStatusVerwert = :wtvStatusVerwert3)" +
" and (:wtvAdressNr1 is null or :wtvAdressNr2 = -1 or o.wtvAdressNr =
:wtvAdressNr3)" +
" and (:wtvEingangsdatum1 is null or o.wtvEingangsdatum >= :wtvEingangsdatum2)" +
" and (:wtvEingangsdatumBis1 is null or o.wtvEingangsdatum <= :wtvEingangsdatumBis2)"
+
" and (:wtvLlvNr1 is null or o.wtvLlvNr = :wtvLlvNr2)" +
" and (:wtvFirma1 is null or o.wtvFirma = :wtvFirma2)" +
" and (:wsbId1 is null or :wsbId2 = -1 or s.wsbSbId = :wsbId3)")
Oracle Toplink translates this (according to to opmn log of the Application Server)
to:
SELECT DISTINCT t0.WTV_ID, t0.WTV_SL_PLUS_KNZ, t0.WTV_ABGESCHLOSSENDATUM, t0.WTV_SL_TECHNIK_DATE, t0.WTV_ADRESS_POOL, t0.WTV_SL_TECHNIK_KNZ,
t0.WTV_AKTENZEICHEN_RA, t0.WTV_SONDERAFA_OBJEKTE_AKTUELL,
t0.WTV_ANZAHLRUECKSTAENDIGERRATEN, t0.WTV_SONDERAFA_OBJEKTE_GEBUCHT,
t0.WTV_BANKAUSKUNFT_KNZ, t0.WTV_STATUS_BEARB, t0.WTV_EINGANGSDATUM,
t0.WTV_STATUS_BEARB_DATUM, t0.WTV_EINSCHAETZUNG_BONI, t0.WTV_STATUS_VERWERT,
t0.WTV_EWB_DATUM_ERFASSUNG, t0.WTV_STATUS_VERWERT_DATUM, t0.WTV_EWB_GEBUCHT,
t0.WTV_STATUS_FREIGABE, t0.WTV_EWB_SB_ERFASSUNG, t0.WTV_STATUS_FREIGABE_DATUM,
t0.WTV_FIRMA, t0.WTV_VERBLEIB_AKTE, t0.WTV_WAEHRUNG_AUSFALL,
t0.WTV_KUENDIGUNGSFORDERUNG, t0.WTV_WAEHRUNG_EWB, t0.WTV_LLV_NR,
t0.WTV_WAEHRUNG_RUECKST_ANR, t0.WTV_LTV_NR, t0.WTV_WAEHRUNG_SONDERAFA_OBJEKTE,
t0.WTV_PROZESSKOSTEN_RISIKO, t0.WTV_WAE_EINSCHAETZUNG_BONI,
t0.WTV_RUECKST_ANRECHNUNG_GEBUCHT, t0.WTV_WAE_KUENDIGUNGSFORDERUNG,
t0.WTV_SL_KASKO_DATE, t0.WTV_WIEDERGESUNDUNGSDATUM, t0.WTV_SL_PLUS_DATE,
t0.WTV_ABGESCHLOSSEN_KNZ, t0.WTV_AKTENZEICHEN_FAV, t0.WTV_TEILRISIKO_KNZ,
t0.WTV_AUSFALL, t0.WTV_BETRUG_KNZ, t0.WTV_EINGANGSDATUM_ALT,
t0.WTV_CHANGE_USER, t0.WTV_EWB_DATUM_FREIGABE, t0.WTV_CHANGE_DATE,
t0.WTV_EWB_SB_FREIGABE, t0.WTV_FREIGABE_KOMMENTAR, t0.WTV_KUENDIGUNGSDATUM,
t0.WTV_ADRESS_NR, t0.WTV_ALTFALL_KNZ, t0.WTV_OPERATIONELLES_RISIKO,
t0.WTV_BEMERKUNG, t0.WTV_SACHSTAND, t0.WTV_EWB_AKTUELL,
t0.WTV_LLV_NR_UMFINANZIERUNG, t0.WTV_EWB_KORREKTUR, t0.WTV_SL_KASKO_KNZ,
t0.WTV_FIRMA_UMFINANZIERUNG, t0.WTV_RUECKST_ANRECHNUNG_AKTUELL,
t0.WTV_KUENDIGUNGSFORDERUNG_ALT, t0.WTV_LEASINGVERTRAG_ID,
t0.WTV_RUECKST_ANRECHNUNG_BUC_ID, t0.WTV_EWB_BUC_ID,
t0.WTV_SONDERAFA_OBJEKTE_BUC_ID FROM VWDB_LEASINGTEILVERTRAG t0,
VWDB_LEASINGTEILVERTRAG t2, VWDB_SACHBEARBEITER t1 WHERE (((((((((((? IS NULL)
OR (? = (? - ?))) OR (t0.WTV_STATUS_BEARB = ?)) AND (((? IS NULL) OR (? = (? -
?))) OR (t0.WTV_STATUS_VERWERT = ?))) AND (((? IS NULL) OR (? = (? - ?))) OR
(t0.WTV_ADRESS_NR = ?))) AND ((? IS NULL) OR (t0.WTV_EINGANGSDATUM > ?))) AND
((? IS NULL) OR (t0.WTV_EINGANGSDATUM < ?))) AND ((? IS NULL) OR (t0.WTV_LLV_NR
= ?))) AND ((? IS NULL) OR (t0.WTV_FIRMA = ?))) AND (((? IS NULL) OR (? = (? -
?))) OR (t1.WSB_SB_ID = ?))) AND (t1.WSB_LTV_ID (+) = t0.WTV_ID))
The Problem is the "VWDB_LEASINGTEILVERTRAG t2" entry in the FROM clause of the generated select statement. This causes the select to generate the cartesian product.
Has anyone had such a problem before? How can this be solved?

Hello,
I have exactly the same problem (with a simpler query though). I'm running my webapp on a GlassFish V2 (build b09d-fcs), Toplink Essentials JPA impl. and a MySQL 6.0.4 database server.
I'm trying to run the following JPQL query: select f from Foo f where (1=1) and f.title = :title
After having set persistence log levels to FINE, the following SQL is displayed:
select t0.XXX, t0.YYY from Foo t0, Foo t1 where ((?=?) and (t0.title= ?))
bind => [1, 1, Bar]
(1 = 1) is used because of dynamic query generation (application code)
The problem is that the additional from clause is generating a cartesian product on my Foo table, which causes many duplicated results to be returned.
I have simplified the select part of the query but the actual query is of the same kind: no join, only 1 entity, no inheritance, a single N:1 lazy-initialized entity (*Foo-1FooParent). The only "exotic" facet of my Foo mapping is the use of an @Enumerated column.
Is it the expected behavior?
-Titix

Similar Messages

  • Creating a record group not via select statement

    Normally a record group is created via a select statement
    (f.e. Querystr='Select deptno,dname from dept
    populate_group_with_query( GroupId, QueryStr )
    Is it possible to create it via a package procedure sending a
    refcursor / array

    FIND_GROUP(groupname);
    CREATE_GROUP_FROM_QUERY(groupname, qry);
    POPULATE_GROUP_WITH_QUERY(rgid, qry);
    Add_Group_Column(...);
    Add_Group_Row(...);

  • Order by column not in select statement

    Want to select multiple columns from a single table, and order by a column on the same table, but that is not in the select statement, or simply not shown in the output of the statement..
    Any help appreciated..

    Hi,
    In most cases, you can ORDER BY any column in the table(s) used, whether it is in the result set or not.
    Otherwise, include the column. Your front-end tool may be able to suppress the display, if you really don't want to see it.
    For example, in SQL*Plus
    COLUMN  dont_show  NOPRINTcauses any column named (or aliased) dont_show not to appear in the output.
    In Oracle9 (and up) sub-queries with ORDER BY return their results in order, so you can say things like:
    SELECT  col_a
    ,       col_b
    FROM    (
            SELECT    col_a
            ,         col_b
            ,         col_x   -- Not included in final output
            ORDER BY  col_x
            );

  • Using ORDER BY for column that's not in SELECT statement of select list?

    Hi all.
    I have a select list on an APEX page at apex.oracle.com, and I would like to order this by the value of column UnitOrder.
    The SQL is as follows:
    SELECT DISTINCT foodunit.name AS display_value, foodunit.foodunitid AS return_value
    FROM foodunit, food
    WHERE foodunit.foodid = :P18_FOODID
    ORDER BY foodunit.unitorder ASC;Off course, this code won't work. And since it's a select list, I can't just add foodunit.unitorder to the SELECT statement. Also, I can't get rid of the DISTINCT, because then for some reason it tends to display an infinite amount of the same row...
    The point of ordering it by UnitOrder is that all units who begin with gram, ml, mg, kg,... etc, will be shown on top of the select list. All other food units will be shown on the second place and so on.
    The column UnitOrder holds either 1 or 2 as a value. 1 is the value for all rows that should be displayed at the top of the select list, 2 is the value for all the rest.
    So, what I want is that all rows in which the UnitOrder is 1, get displayed on top of the select list. Usually only 2 list items get shown in the select list at a time, depening on which food item a user has selected. The select list then refines to certain rows that match the foodid etc etc..
    If anyone has an idea, I'd be very happy to hear about it.

    Thanks! I didn't think about using a join. Code works now, and is as follows:
    SELECT foodunit.name AS display_value, foodunit.foodunitid AS return_value
    FROM foodunit
    INNER JOIN food
    ON food.foodid = foodunit.foodid 
    WHERE foodunit.foodid = :P18_FOODID
    ORDER BY foodunit.unitorder ASC;

  • Create table as select statement.

    Hello Oracle Gurus,
    I am trying to create a table using select * from other table.
    The procedure that I am following is this:-
    I have a temp table whose signature is on commit delete rows.
    I insert records in this table.
    when I do select * from temp_table,perm_table I get some rows.
    then I try to create a result_table using this
    CREATE TABLE result_table
    AS SELECT * FROM temp_table,perm_table;
    I see the table in created but number of records in 0. Can anyone please explain where commit takes place while sequence in this query occurs.
    Thanks
    Edited by: user10696492 on Nov 10, 2009 8:47 AM

    Create table statement is a ddl - so an implicit commit is performed before the create statement begins. The implicit commit will delete all the rows from the temp table. If it is feasible change the definition of the temp table to on commit preserve rows.

  • Create table as select (CTAS)statement is taking very long time.

    Hi All,
    One of my procedure run a create table as select statement every month.
    Usually it finishes in 20 mins. for 6172063 records and 1 hour in 13699067.
    But this time it is taking forever even for 38076 records.
    When I checked all it is doing is CPU usage. No I/O.
    I did a count(*) using the query it brought results fine.
    BUT CTAS keeps going on.
    I'm using Oracle 10.2.0.4 .
    main table temp_ip has 38076
    table nhs_opcs_hier has 26769 records.
    and table nhs_icd10_hier has 49551 records.
    Query is as follows:
    create table analytic_hes.temp_ip_hier as
    select b.*, (select nvl(max(hierarchy), 0)
    from ref_hd.nhs_opcs_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
    secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
    secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
    secondary_procedure_9, secondary_procedure_10,
    secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
    (select nvl(max(hierarchy), 0) from ref_hd.nhs_icd10_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_diagnosis, secondary_diagnosis_1,
    secondary_diagnosis_2, secondary_diagnosis_3,
    secondary_diagnosis_4, secondary_diagnosis_5,
    secondary_diagnosis_6, secondary_diagnosis_7,
    secondary_diagnosis_8, secondary_diagnosis_9,
    secondary_diagnosis_10, secondary_diagnosis_11,
    secondary_diagnosis_12, secondary_diagnosis_13,
    secondary_diagnosis_14)) as hd_diagnosis_hierarchy
    from analytic_hes.temp_ip b
    Any help would be greatly appreciated

    Hello
    This is a bit of a wild card I think because it's going to require 14 fill scans of the temp_ip table to unpivot the diagnosis and procedure codes, so it's lilkely this will run slower than the original. However, as this is a temporary table, I'm guessing you might have some control over its structure, or at least have the ability to sack it and try something else. If you are able to alter this table structure, you could make the query much simpler and most likely much quicker. I think you need to have a list of procedure codes for the fiscal year and a list of diagnosis codes for the fiscal year. I'm doing that through the big list of UNION ALL statements, but you may have a more efficient way to do it based on the core tables you're populating temp_ip from. Anyway, here it is (as far as I can tell this will do the same job)
    WITH codes AS
    (   SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            primary_PROCEDURE       procedure_code,
            primary_diagnosis       diagnosis_code,
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_1    procedure_code,
            secondary_diagnosis_1    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_2    procedure_code ,
            secondary_diagnosis_2    diagnosis_code     
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_3    procedure_code,
            secondary_diagnosis_3    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_4    procedure_code,
            secondary_diagnosis_4    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_5    procedure_code,
            secondary_diagnosis_5    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_6    procedure_code,
            secondary_diagnosis_6    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_7    procedure_code,
            secondary_diagnosis_7    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_8    procedure_code,
            secondary_diagnosis_8    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_9    procedure_code,
            secondary_diagnosis_9    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_10  procedure_code,
            secondary_diagnosis_10    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_11  procedure_code,
            secondary_diagnosis_11    diagnosis_code
        FROM
            temp_ip    
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_12  procedure_code,
            secondary_diagnosis_12    diagnosis_code
        FROM
            temp_ip
    ), hd_procedure_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_procedure_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_opcs_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.procedure_code
        GROUP BY
            a.fiscal_year
    ),hd_diagnosis_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_diagnosis_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_icd10_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.diagnosis_code
        GROUP BY
            a.fiscal_year
    SELECT b.*, a.hd_procedure_hierarchy, c.hd_diagnosis_hierarchy
      FROM analytic_hes.temp_ip b,
           LEFT OUTER JOIN hd_procedure_hierarchy a
              ON (a.fiscal_year = b.hd_spell_fiscal_year)
           LEFT OUTER JOIN hd_diagnosis_hierarchy c
              ON (c.fiscal_year = b.hd_spell_fiscal_year)HTH
    David

  • Optimizing a Select Statement

    Hi,
    I have recently been asked to generate a program that reports of payroll postings to FI.  This involves creating a giant select statement from the ppoix table to gather all the postings.  My select statement is as follows:
      SELECT pernr                       "EE Number
             seqno                       "Sequential number
             actsign                     "Indicator: Status of record
             runid                       "Number of posting run
             postnum                     "Number
             tslin                       "Line number of data transfer
             lgart                       "Wage Type
             betrg                       "Amount
            waers                       "Currency
            anzhl                       "Number
            meins                       "Base unit of measure
             spprc         "Special processing of posting items
            momag         "Transfer to FI/CO:EE grouping for acct determi
            komok         "Transfer to FI/CO: Symbolic account
            mcode                       "Matchcode search term
            koart                       "Account assignment type
            auart                       "Expenditure type
            nofin         "Indicator: Expenditure type is not funded
               INTO CORRESPONDING FIELDS OF TABLE i_ppoix
               FROM ppoix
               FOR ALL ENTRIES IN run_doc_xref
               WHERE runid  = run_doc_xref-runid
                 AND tslin  = run_doc_xref-linum
                 AND spprc  <> 'A'
                 AND lgart IN s_lgart
                 AND pernr in s_pernr.
    where s_pernr is a select option that holds personnel nummbers and s_lgart is a select option that holds wagetypes.  This statement works fine for a certain amount of personnel numbers and a certain amount of wagetypes, but once you exceed a certain limit the Database does not allow you to perform a select statement this large.  Is there a better way to perform such a large select such as this one) ie: FM, or some other method I am not aware of.  This select statement comes from the standard SAP delivered cost center admin report and this report dumps as well when too much data is passed to it.
    any ideas would be much appreciated.
    thanks.

    The problem here is with the select-options.
    For a select statement, you cannot have more that certain amount of data.
    The problem with your select becomes complex because of the FOR ALL ENTRIES in and the huge s_pernr and the 40 million records :(.
    I am guessing that the s_lgart will be small.
    How many entries do you have in internal table "run_doc_xref"?
    If there are not that many, then I would suggest this:
    TYPES:
      BEGIN OF ty_temp_ppoix,
       pernr   TYPE ppoix-pernr,
       lgart   TYPE ppoix-lgart,
       seqno   TYPE ppoix-seqno,
       actsign TYPE ppoix-actsign,
       runid   TYPE ppoix-runid,
       postnum TYPE ppoix-postnum,
       tslin   TYPE ppoix-tslin,
       betrg   TYPE ppoix-betrg,
       spprc   TYPE ppoix-spprc,
      END OF ty_temp_ppoix.
    DATA:
    i_temp_ppoix TYPE SORTED TABLE OF ty_temp_ppoix
       WITH NON-UNIQUE KEY pernr lgart
       INITIAL SIZE 0
       WITH HEADER LINE.
    DATA:
      v_pernr_lines TYPE sy-tabix,
      v_lgart_lines TYPE sy-tabix.
    IF NOT run_doc_xref[] IS INITIAL.
      DESCRIBE TABLE s_pernr LINES v_pernr_lines.
      DESCRIBE TABLE s_lgart LINES v_lgart_lines.
      IF v_pernr_lines GT 800 OR
         v_lgart_lines GT 800.
    * There is an index on runid and tslin. This should be ok
    * ( still bad because of the huge table :(  )
        SELECT pernr lgart seqno actsign runid postnum tslin betrg spprc
    * Selecting into sorted TEMP table here
          INTO TABLE i_temp_ppoix
          FROM ppoix
          FOR ALL ENTRIES IN run_doc_xref
          WHERE runid = run_doc_xref-runid
          AND   tslin = run_doc_xref-linum
          AND   spprc <> 'A'.
    * The sorted table should make the delete faster
        DELETE i_temp_ppoix WHERE NOT pernr IN s_pernr
                            AND   NOT lgart IN s_lgart.
    * Now populate the actual target
        LOOP AT i_temp_ppoix.
          MOVE: i_temp_ppoix-pernr TO i_ppoix-pernr.
    *  and the rest of the fields
          APPEND i_ppoix.
          DELETE i_temp_ppoix.
        ENDLOOP.
      ELSE.
        SELECT pernr seqno actsign runid postnum tslin lgart betrg spprc
    * Selecting into your ACTUAL target here
          INTO TABLE i_ppoix
          FROM ppoix
          FOR ALL ENTRIES IN run_doc_xref
          WHERE runid = run_doc_xref-runid
          AND   tslin = run_doc_xref-linum
          AND   spprc <> 'A'
          AND   pernr IN s_pernr
          AND   lgart IN s_lgart.
      ENDIF.
    ELSE.
    * Error message because of no entries in run_doc_xref?
    * Please answer this so a new solution can be implemented here
    * if it is NOT an error
    ENDIF.
    Hope this helps.
    Regards,
    -Ramesh

  • Error by using database procedure in select statement

    hi ,
    I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
    i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
    plz help me how i can use a procedure in select statement. or can i do it or not.

    plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
    The simply call this function in your select which internally calls the procedure.

  • Select statement in if/else condition

    Hi i need to write a select statement in the if condition in pl/sql how can i write this
    example :
    if field_name not in (select statement) then
    Is this type of if condition is possible in pl/sql?
    thanks in advance for help.

    Qwerty wrote:
    here pick a job example salesman for ename ward, now i want to compare this job that is "salesman" with all the jobs which are before it. that is clerk in line 1 and salesman in line 2Define "before it". There is no order in relational tables. Only ORDER BY means ordered sets. Therefore there is no before/after without ORDER BY. Assuming ORDER BY empno, job count of same job title before empno:
    select  ename,
            job,
            count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
      from  emp
    ENAME      JOB       SAME_JOB_COUNT_BEFORE_EMPNO
    SCOTT      ANALYST                             0
    FORD       ANALYST                             1
    SMITH      CLERK                               0
    ADAMS      CLERK                               1
    JAMES      CLERK                               2
    MILLER     CLERK                               3
    JONES      MANAGER                             0
    BLAKE      MANAGER                             1
    CLARK      MANAGER                             2
    KING       PRESIDENT                           0
    ALLEN      SALESMAN                            0
    ENAME      JOB       SAME_JOB_COUNT_BEFORE_EMPNO
    WARD       SALESMAN                            1
    MARTIN     SALESMAN                            2
    TURNER     SALESMAN                            3
    14 rows selected.To find job count of same job title as Ward has before Ward (by empno):
    SELECT  same_job_count_before_empno
      FROM  (
             select  ename,
                     count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
               from  emp
      WHERE ename = 'WARD'
    SAME_JOB_COUNT_BEFORE_EMPNO
                              1SY.

  • Select statement of severals tables with the same structure

    Does anybody know - how to create a single select statement to count entries of several tables. These tables have the same structure and are connected by a foreign key to a - I would call master table. So in this master table - I have the names of all these others tables and what I want should look like this:
    name__________ # entries
    table_1_________100
    table_2_________150
    table_3__________80
    Select table_name, count(table1.column1), count(table2.column1), count(table3.column1) from master, table1, table2, table3 Where master.id=table1.id OR master.id=table2.id OR master.id=table3.id Group By table_name
    Thanks in advance
    remo

    If I understood your question correctly, this is what you (probably) need:
    Select table_name, (select count(column1) from table1 Where master.id=table1.id), (select count(column1) from table2 Where master.id=table2.id), (select count(column1) from table3 Where master.id=table3.id)
    from master

  • Dynamic in SELECT statement

    Hi,
    I have a SELECT statement where I need the year to be dynamic. The user select a range of months where the script should execute and based on the input I would like to create a dynamic SELECT statement.
    My SELECT statement looks like:
    *SELECT(%TIME1%, "[ID]", TIME,[YEAR]="2010" AND [MONTHNUM]="1")
    I would like to replace the hardcode year (2010) with a dymamic string. I have tried to use %YEAR% but I couldn't make it work.
    Thanks
    Lars Johansen
    Edited by: Lars Johansen on Aug 18, 2011 10:26 AM

    Hi,
    Basically, the %YEAR% is a dynamic variable which is picked from the YEAR property of the CATEGORY dimension. So, for example, you run the package for the category as actual, and if in the category dimension, the year property of actual is set to 2010. then %YEAR% will be 2010.
    So, if the user selects a time member in the prompt, you can select the year from that member using:
    *SELECT(%MY_YEAR%, "[YEAR]", TIME, [ID]=%TIME_SET%)
    Hope this helps.

  • Execute an string as select statement

    Hi,
    I have a problem:
    I'm working with an older oracle verion (7.x??). I want to create a dynamic select statement. I create a string, e.g. v_sql_string, and want the database to execute it. What possibilities do I have to do this?
    Thanks in advance
    Mathias

    Yes,
    I went through the documentation, but it's only working with cursors.
    For better comprehension:
    This is the string:
    'select count(*) from invoice where sup_no ' || op_sup_no || ' v_sup_no and trpt_code ' || op_trpt_code || ' v_trpt_code and ship_no ' || op_ship_no || ' v_ship_no'
    I want to set the operators (op_xxx) dynamiclly. Isn't there something like RUN or EXECUTE, where I only have to pass a string, and the statement is executed ...
    But I don't know how ...
    Mathias

  • Lazy fetching problem with TopLink essentials

    [TopLink Warning]: 2008.08.02 08:56:14.656--ServerSession(29131495)--Ignoring LAZY fetch type on element [public byte[] org.mayhem.mail.entity.Message.getRawBytes()] within entity class [class org.mayhem.mail.entity.Message]. All basic mappings default to use EAGER fetching.This is what I get when I start TopLink essesntials based JavaEE server. Why is that ?
    No, no..... I knooow that lazy fetching is not required to be supported by a JPA implementor.
    The question is why ?
    I mean, isnt Toplink the official implementation, and arent all features "supposed" to be implemented?
    How can I address this issue ?
    I dont want to fetch the bytes on each accessed message ...... ;(

    TopLink Essentials does not support this optional feature.
    EclipseLink 1.0 does, (JPA 2.0 reference impl). EclipseLink is basically the full open sourcing of the TopLink product, where as TopLink Essentials only included "Essential" features.
    -- James : [http://www.eclipselink.org]

  • Toplink Essentials: how can I not to auto persist computed/virtual column

    Tags: Toplink Essentials, JPA, virtual columns
    Hi All,
    This appears to be a newbie question. But I cannot get it solved.
    First, my system is Eclipse + TOPlink essentials.
    My relational db table has a computed column. It is derived from a column of the same table.
    create table WINE(
    WINE_NAME VARCHAR2(25),
    WINE_STORAGE_DATE DATE,
    VINTAGE AS (EXTRACT(YEAR FROM WINE_STORAGE_DATE))
    In my JAVA entity, I would like to map VINTAGE into a "auto-generated" field. In this way, when I update relational db table, VINTAGE won't be in the JPA generated INSERT statement, but I can query the VINTAGE into my java entity/object.
    I tried the following JPA annotation in my java entity class.
    @Entity
    public class Wine implements Serializable {
    @GeneratedValue private Integer VINTAGE;
    I can query db table -- VINTAGE flows from db table to my java object. But when I update table ( I left VINTAGE un-specified ), I get the following error:
    Internal Exception: java.sql.SQLException: ORA-54013: INSERT operation disallowed on virtual columns
    Error Code: 54013
    Call: INSERT INTO WINE(WINE_NAME, WINE_STORAGE_DATE, VINTAGE) VALUES (?, ?, ?)
         bind => PinotNoir, 2003-01-05 00:00:00.0, null
    Any suggestions on what annotation tage I should use to tell the JPA Provider not to include VINTAGE in the auto-generated INSERT statement?
    Thank you very much.
    Jing
    Edited by: user11935396 on Sep 25, 2009 1:36 PM
    Edited by: user11935396 on Sep 25, 2009 1:37 PM

    I am not sure if your annotation @GeneratedValue is proper. According to javadoc "Provides for the specification of generation strategies for the values of primary keys. The GeneratedValue annotation may be applied to a primary key property or field of an entity or mapped superclass in conjunction with the Id annotation."
    I would rather try to annotate VINTAGE as @Column(insertable=false, updatable=false)

  • Create Dynamic table name in the select statement.

    I use oracle reports 6i to make myrep.rdf , this report created using certain select query Q1, I created a formula column in this report,
    in the formula column  I write pl/sql block statements to select the data from certain table depends on the output of a column in Q1,
    I want to make the pl/sql block dynamically enough to change the user which I select the data from depends on the connected user
    Ex: if I connected with user = 'KAM14'
    the pl/sql block will be
    select x into v_value from kam13.bil_file where .....;
    and if  I connected with user = 'KAM13'
    the pl/sql block will be
    select x into v_value from kam12.bil_file where .....;
    and so on
    how can I do this in the pl/sql block ...
    Thanks in Advance.

    I am not sure I understood properly, but I think you should create bil_file table under a different user and create synonyms  under KAM1x users.
    Regards

Maybe you are looking for