Wrong Select statement being generated

The problem is to do with querying an object (db table) in an inheritance. The main comment is at the end.
A. Here is the base class:
@javax.persistence.Table(name = "DATA_PROFILE", schema="LPDS")
@javax.persistence.Entity
@javax.persistence.Inheritance(     strategy = javax.persistence.InheritanceType.JOINED)
@javax.persistence.DiscriminatorColumn(name="DOMAIN_TYPE" , discriminatorType=javax.persistence.DiscriminatorType.STRING)
public abstract class DataProfileEntity implements java.io.Serializable{
B. And here is the sub class being queried:
@javax.persistence.Table(name = "DATA_CONSTRAINT", schema="LPDS")
@javax.persistence.Entity
@javax.persistence.DiscriminatorValue("DataConstraint")
@javax.persistence.PrimaryKeyJoinColumn(name="ID", referencedColumnName="ID")
public class DataConstraintEntity extends DataProfileEntity implements java.io.Serializable, Cloneable{
C. Here is my DAO using the Eclipselink API:
@javax.ejb.TransactionAttribute(javax.ejb.TransactionAttributeType.NOT_SUPPORTED)
public java.util.Collection<T> queryByExample(T entity) {
     if (type == null) {
          throw new UnsupportedOperationException("The type must be set to use this method.");
     if (entity == null) {
throw new java.lang.NullPointerException(DAOExceptionMessageBuilder.buildMessage("param.value.empty", new Object[] { entity}));
     try{
ReadAllQuery readAllQuery = new ReadAllQuery(type);
readAllQuery.setExampleObject(entity);
return (java.util.Collection<T>) getUnitOfWork().executeQuery(readAllQuery);
} catch (org.eclipse.persistence.exceptions.DatabaseException dbe) {
dbe.printStackTrace();
throw new DAOException(DAOExceptionMessageBuilder.buildMessage("object.find.exception"), dbe);
} catch (java.lang.RuntimeException rte) {
rte.printStackTrace();
throw new DAOException(DAOExceptionMessageBuilder.buildMessage("object.find.exception"), rte);
D: When I do the following:
     DataConstraintEntity entity = new DataConstraintEntity();
     entity.setParentTable("User");
     entity.setCrudMode("All");
dao.queryByExample(entity);
The log message shows the following:
2009-11-20 20:43:11,671 INFO [STDOUT] (http-127.0.0.1-8080-1) Begin profile of{ReadAllQuery(referenceClass=DataConstraintEntity )
2009-11-20 20:43:11,689 INFO  [STDOUT] (http-127.0.0.1-8080-1) [EL Fine]: 2009-11-20 20:43:11.68--ServerSession(25760263)--Connection(32815217)--Thread(Thread[http-127.0.0.1-8080-1,5,jboss])
--SELECT t0.ID, t0.DOMAIN_TYPE, t0.IS_LOCKOUT, t0.VERSION, t0.UPDATED_BY, t0.HITS, t0.CREATED_BY, t0.DESCRIPTION, t0.NAME, t0.DATE_LAST_UPDATED, t0.DATE_CREATED, t0.NOTES, t0.owner, t1.ID, t1.DATA_TYPE, t1.READ_ONLY, t1.ENABLED_ON_USER_ROLE, t1.RENDERED_ON_USER_ROLE, t1.CRUD_MODE, t1.PARENT_TABLE, t1.DATA_NAME FROM ODMS.DATA_PROFILE t0, ODMS.DATA_CONSTRAINT t1 WHERE ((((t0.DOMAIN_TYPE = ?) AND (t1.CRUD_MODE = ?)) AND (t1.PARENT_TABLE = ?)) AND ((t1.ID = t0.ID) AND (t0.DOMAIN_TYPE = ?)))
     bind => [DataProfile, All, User, DataConstraint]
2009-11-20 20:43:12,412 INFO [STDOUT] (http-127.0.0.1-8080-1) Profile(ReadAllQuery,
     class=com.xoftsystems.odms.domain.bean.DataConstraintEntity,
     total time=736,
     local time=736,
     profiling time=1,
     connect=1,
     logging=10,
     query prepare=5,
     sql prepare=1,
     sql execute=716,
     sql generation=3,
}End profile
In "bind => [DataProfile, All, User, DataConstraint]", I don't know why Eclipselink is passing "DataProfile" as a value to the query or even why the two "(t0.DOMAIN_TYPE = ?)" in the statement. t0.DOMAIN_TYPE cannot be "t0.DOMAIN_TYPE = 'DataProfile'" and "t0.DOMAIN_TYPE = 'DataConstraint'". It should only be "t0.DOMAIN_TYPE = 'DataConstraint'".
Testing the above Select statement directly on my database fails but succeeds when I remove the first "(t0.DOMAIN_TYPE = ?)" and run it.
Questions:
1. Could this be a bug in Eclipselink?
2. How do I get rid of the first "(t0.DOMAIN_TYPE = ?)" in the Select statement?
3. What am I doing wrong?
Thanks in advance.

Hello,
First question should really be where is the "'DataProfile" DOMAIN_TYPE value coming from? I don't see a descriminatorValue annotation set with this value, so do you have it set through a mapping some where?
Best Regards,
Chris

Similar Messages

  • JDBC Sender - Wrong SELECT statement (Oracle driver)

    Hi,
    3 days ago I was having a problem with my JDBC Sender adapter [JDBC Sender adapter is reading but then there isn't the message in SXMB_MON; .
    Finally I discovered what's wrong but I can't understant why is not working. When I deleted the "WHERE" condition in my SELECT statement all worked OK (except that I need the WHERE statement...).
    Why that statement is not working in my JDBC Sender:
    SELECT * FROM MATERIALES WHERE LEIDO<>'X'
    and that statement works:
    SELECT * FROM MATERIALES
    The field "LEIDO" is my flag that I must set to X when I read with the UPDATE statement, so I need the where condition...

    Thanks Christopher but still not working
    I tried two new statements:
    1 - Escaping:    SELECT * FROM MATERIALES WHERE LEIDO <> 'X'
    2 - Changing the operator symbol: SELECT * FROM MATERIALES WHERE LEIDO != 'X'
    The nº1 gives me an error of invalid character
    The nº2 has the same effect than the other symbol, the adapter reads from the DB but no XML message is generated and no payload to check what's happening... just a message ID without information and without a message generated in SXMB_MONI

  • Icorrect table creation statements being generated for DB2

    Hi,
    I am using JDeveloper 903 and I have a datsource of IBM DB2 ver 7.3 type. I am creating a CMP2.0 beans Person and Address. When I try running these beans from JDeveloper on the embedded OC4J, I get the following exception :
    AAuto-creating table: create table Person_current_workspace_app__vkk_AmsNTO_Project1_classes_ (id BIGINT not null primary key, firstName VARGRAPHIC(255) null, lastName VARGRAPHIC(255) null, middleName VARGRAPHIC(255) null)
    Auto-creating table: create table Address_current_workspace_app__vkk_AmsNTO_Project1_classes_ (id BIGINT not null primary key, address1 VARGRAPHIC(255) null, address2 VARGRAPHIC(255) null, city VARGRAPHIC(255) null, state VARGRAPHIC(255) null, zip VARGRAPHIC(255) null, type VARGRAPHIC(255) null, Address_addresses BIGINT null)
    Auto-creating table: create table Address_addresses_Address_Address_addresses_current_workspace_app__vkk_AmsNTO_Project1_classes_ (Address_id BIGINT not null)Error creating table: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "," was found following "VARGRAPHIC(255) null". Expected tokens may include: "<references_spec>". SQLSTATE=42601Error creating table: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "," was found following "VARGRAPHIC(255) nu[i]Long postings are being truncated to ~1 kB at this time.

    Thanks wildmight for the reply.
    You're right on with the tip you provided -- I figured that this had to be related to some DB object setting in the Physical Layer. As I've never been able to find any documentation from Oracle on the definition of the "Features" tab settings, I just began trial-and-error troubleshooting with the settings to see what I could find. I actually tested it by selecting every "Value" checkbox in the 'Features" tab to see what I'd get. :D
    Apparently, when I selected "DB2/AS400" as the database object's data source type in the "General" tab, the "Features" tab also got updated to default DB2 features that OBIEE thinks are appropriate. HOWEVER, there is one +slightly+ important feature is then automatically deselected (and also not listed as "default") in the list:
    *DERIVED_TABLES_SUPPORTED*
    Once I put a check in the "Value" column of the "Features" tab and re-ran my query, it actually submitted one unified query to the DB as I had hoped!
    I have a fact table with about 30 million rows and when I would ask for only a month's worth of data, it previously would return ALL 30M records and then filter down on my month. That query was taking about 15 minutes. After I got the view to work properly, the same query took 19 seconds. :)
    Cheers,
    Jeremy

  • Creating xml file using select statement

    Hi,
    when i run a select statement to generate Xml file in - oracle Db - 10.2.0.4.0
    i'm getting,
    SELECT XMLELEMENT("Emp", XMLATTRIBUTES(e.empno AS "ID")) AS "Emp Element" FROM emp e WHERE row
    num=1
    Emp Element()
    XMLTYPE()
    But, in 10.2.0.3.0 , i'm getting,
    Emp Element
    <Emp ID="7369"></Emp>
    could anyone tell me whey this difference , is it version realted itself or i need to change any settings
    thanks
    Jodus

    for 10.2.0.3.0 DB the client is 10.2.0.3.0
    for 10.2.0.4.0 DB the client is 10.1.0.4.2 - Upgraded the client to 10.2.0.3.0 and it is working fine. Thanks.
    the same select statement Executing from SqlPlus
    Edited by: Jodus on Jul 30, 2009 1:47 PM

  • 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

  • How a select statement generates redo logs

    Can some one explain how a select statement generates redo logs
    Naveen

    Redo with a select statement happens when dirty blocks get written to the database, and are then "cleaned up" when next read of that data block. This could happen when a large DML statement does not commit before the DB Writer needs to write modified blocks to disk. The next time the blocks are read by a select statement they get modified, hence REDO is generated by the select statement.
    Read the following for more and better understandings.
    http://www.dbspecialists.com/specialists/specialist2003-10.htm
    Jaffar

  • AppManifest.xml is being generated with the wrong version number

    I am having a interesting problem which is preventing me from submitting an update to my app to the Windows Phone Store. I have done this 100 times and something is wrong with visual studio building the .xap file. Steps I am taking:
    Update all version references in project settings and appmanifestWM to 1.4.0.0
    Build Release version
    Copy .xap from /bin/release
    Upload as an app update to windows phone dev site
    What happens is that the current version of the app (1.3.1.0) is still listed as the version of the app that the submission page is parsing out of the version (1.4.0.0) .xap file. I unzipped the xap file and looked at the appmanifest files and found that
    the AppManifest.xaml has the correct version number but the AppManifest.xml still has version 1.3.1.0. If anyone could help me resolve this issue it would be greatly appreciated.

    Thanks for your reply. I believe it is a bug with my solution because I have now tried all of these steps on two computers and uploaded using two different browsers and I still get a AppManifest.xml file that has version 1.3.1.0. I will copy and paste the
    unzipped code from the AppManifest.xml file.
    <?xml version="1.0" encoding="utf-8"?>
    <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:build="http://schemas.microsoft.com/developer/appx/2012/build" IgnorableNamespaces="build">
    <!--
    THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS.
    Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file.
    For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727
    -->
    <Identity Name="50523CameronStair.MyDebts" Publisher="CN=FA4BA529-B82F-4A0F-A35C-6700BC51B3E1" Version="1.3.1.0" ProcessorArchitecture="neutral" />
    <mp:PhoneIdentity PhoneProductId="c805a27c-951f-4c0d-a831-1126f9a70563" PhonePublisherId="51beaec0-db37-4002-81de-5e138a756b34" />
    <Properties>
    <DisplayName>MyDebtsApp</DisplayName>
    <PublisherDisplayName>Cameron Stair</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
    </Properties>
    <Prerequisites>
    <OSMinVersion>6.3.1</OSMinVersion>
    <OSMaxVersionTested>6.3.1</OSMaxVersionTested>
    </Prerequisites>
    <Resources>
    <Resource Language="EN-US" />
    </Resources>
    <Applications>
    <Application Id="App" Executable="AGHost.exe" EntryPoint="MainPage.xaml">
    <m3:VisualElements DisplayName="My Debts" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="A debt tracker app." ForegroundText="light" BackgroundColor="#464646" ToastCapable="false">
    <m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png"></m3:DefaultTile>
    <m3:SplashScreen Image="Assets\SplashScreen.png" />
    </m3:VisualElements>
    <Extensions>
    <Extension Category="windows.backgroundTasks" EntryPoint="AgHost.BackgroundTask">
    <BackgroundTasks>
    <Task Type="systemEvent" />
    </BackgroundTasks>
    </Extension>
    </Extensions>
    </Application>
    </Applications>
    <Extensions>
    <Extension Category="windows.activatableClass.inProcessServer">
    <InProcessServer>
    <Path>AgHostSvcs.dll</Path>
    <ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
    </InProcessServer>
    </Extension>
    </Extensions>
    <Capabilities>
    <m3:Capability Name="contacts" />
    </Capabilities>
    <build:Metadata>
    <build:Item Name="TargetFrameworkMoniker" Value="WindowsPhone,Version=v8.1" />
    <build:Item Name="VisualStudio" Version="12.0" />
    <build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Professional 2013" />
    <build:Item Name="OperatingSystem" Version="6.3.9600.16384 (winblue_rtm.130821-1623)" />
    <build:Item Name="Microsoft.Build.AppxPackage.dll" Version="12.0.31101.0" />
    <build:Item Name="ProjectGUID" Value="{C805A27C-951F-4C0D-A831-1126F9A70563}" />
    <build:Item Name="MSAdvertising" Version="6.1" />
    <build:Item Name="MakePri.exe" Version="6.3.9600.17298 (winblue.141024-1500)" />
    </build:Metadata>
    </Package>
    As you can see the package version being generated is wrong. Can you explain where exactly in the solution that value is taken from? I thought it was from WMAppManifest but I could be wrong. 
    Edit: In looking at the code above and then rereading what I wrote I realized my blaring error. I completely forgot that Silverlight 8.1 apps have an appxmanifest as well and that data is drawn from that as well as WMAppManifest. I never updated the version
    in that appxmanifest. Thank you for the help and I apologize for my stupidity.

  • Excessive flashback log generates with select statement

    Hi everyone;
    We have some extractions taken from a "flashback on" database.
    Extractions are just select statements but when they are run, database produces excessive flashback logs.
    What may be the reason database produce flashback logs with just select statements?
    (It's certain that there are no insert-update-delete operations)
    Version: 10.2.0.4.3
    Thanks...

    Do you do heavy update/delete before you select the statements ?
    I am not very sure if delayed block cleanout also have the same effect on flashback logs but the output below is leading me to think that way
    HR@ORACOS> select * from v$flashback_database_stat;
    BEGIN_TIME        END_TIME          FLASHBACK_DATA    DB_DATA  REDO_DATA ESTIMATED_FLASHBACK_SIZE
    20100527 15:32:53 20100527 15:50:16      875266048 1207132160 2038729728                        0
    20100527 14:32:50 20100527 15:32:53      248160256  127295488  450139648               1.3215E+10
    20100527 13:32:48 20100527 14:32:50       10452992   15646720    4400640               1.5549E+10
    20100527 12:32:43 20100527 13:32:48      745693184  948461568 1311620608               2.2789E+10
    20100527 11:25:56 20100527 12:32:43     1262026752 1984741376 2358546432               2.7212E+10
    HR@ORACOS> set autotrace traceonly statistics
    HR@ORACOS>  update base_table_np set y='INVALID';
    commit;
    4021808 rows updated.
    Statistics
           2512  recursive calls
        8341430  db block gets
        4069140  consistent gets
         120569  physical reads
    1908471980  redo size
            848  bytes sent via SQL*Net to client
            793  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
        4021808  rows processed
    HR@ORACOS> set autotrace off;
    HR@ORACOS> select * from v$flashback_database_stat; 
    HR@ORACOS>
    BEGIN_TIME        END_TIME          FLASHBACK_DATA    DB_DATA  REDO_DATA ESTIMATED_FLASHBACK_SIZE
    20100527 15:32:53 20100527 16:00:36     1236664320 2021974016 4019910656                        0
    20100527 14:32:50 20100527 15:32:53      248160256  127295488  450139648               1.3215E+10
    20100527 13:32:48 20100527 14:32:50       10452992   15646720    4400640               1.5549E+10
    20100527 12:32:43 20100527 13:32:48      745693184  948461568 1311620608               2.2789E+10
    20100527 11:25:56 20100527 12:32:43     1262026752 1984741376 2358546432               2.7212E+10
    HR@ORACOS> set autotrace traceonly statistics
    HR@ORACOS> select * from base_table_np;
    4021808 rows selected.
    Statistics
            139  recursive calls
              0  db block gets
          53908  consistent gets
           4404  physical reads
        1652384  redo size                                                  ------->delayed block cleanout effect
      175008833  bytes sent via SQL*Net to client
          88996  bytes received via SQL*Net from client
           8045  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
        4021808  rows processed
    HR@ORACOS> set autotrace off
    HR@ORACOS> select * from v$flashback_database_stat;    ----flashback data size increases
    HR@ORACOS>
    BEGIN_TIME        END_TIME          FLASHBACK_DATA    DB_DATA  REDO_DATA ESTIMATED_FLASHBACK_SIZE
    20100527 15:32:53 20100527 16:01:11     1305264128 2054594560 4021728256                        0
    20100527 14:32:50 20100527 15:32:53      248160256  127295488  450139648               1.3215E+10
    20100527 13:32:48 20100527 14:32:50       10452992   15646720    4400640               1.5549E+10
    20100527 12:32:43 20100527 13:32:48      745693184  948461568 1311620608               2.2789E+10
    20100527 11:25:56 20100527 12:32:43     1262026752 1984741376 2358546432               2.7212E+10Basically what I do is I update a 4 million table big redo generated with flashback logs
    When I do select after the update I still see the redo generated because of delayed block cleanout but what I also see is the slight increase in flashback data size (check the first row of flashback_database_stat) which suits what you asking for. Select statement generates flashback log
    Tested on 11.2.0.1 with single active session on the db
    Coskan Gundogar
    Blog: http://coskan.wordpress.com
    Twitter: http://www.twitter.com/coskan
    Linkedin: http://uk.linkedin.com/in/coskan
    ---------

  • Index not being used in Select statement

    Friends
    I have the following SQL statement:
    SELECT
    a.acct,
    a.date_field,
    UPPER(b.feegroup) feegrp,
    SUM (a.fee1) fee1,
    SUM (a.fee2) fee2,
    SUM (a.fee3) fee3
    FROM table1 a, table2 b
    WHERE 1 = 1
    AND a.fee_id = b.fee_id
    GROUP BY a.acct, a.date_field, b.feegroup;
    Both the tables have index on fee_id column. When I run the explain plan for this statement, I am getting the following output:
    Operation | Option | Object Name | Position
    SELECT STATEMENT | | | 560299
    HASH | GROUP BY| |1
    TABLE ACCESS | FULL| table2 | 1
    TABLE ACCESS | FULL| table1 | 2
    Why Oracle is not using the index?
    Edited by: darshilm on Dec 10, 2009 3:56 PM

    The proposed plan is the optimal according to your current conditions in the "where clause" where you have only the equality join condition and therefore the CBO can use HASH JOIN. Using any kind of index access would just increase the amount of required work unless you would add some very restrictive conditions which will select rows from relatively small amount of blocks. Here I have to mention that what really counts in the CBO cost calculation is the amount of blocks accessed and not the number of rows. The "currency" for I/O in Oracle is a block and not a row. CBO always uses an assumption that there is nothing in the buffer cache and it will have to perform a physical read for every block.
    How many blocks will actually be accessed depends on the data distribution. It can happen that every single row that you have to retrieve resides in a different block and although you access only 1000 rows out of a million row table you would have to visit almost every block of that table. For such a situation a FULL TABLE SCAN is the best access path and Oracle will use multiblock I/O for that. On the other side you can have those 1000 rows only in a few blocks and then the index access would be the most appropriate one. For index access Oracle uses single block I/O. Usually the actual situation is somewhere between this two extreme situations. But you can run some tests by yourself and see when an index access will be replaced by a full table scan while you will make your predicates less selective.
    HTH, Joze
    Co-author of the forthcoming book "Expert Oracle Practices"
    http://www.apress.com/book/view/9781430226680
    Oracle related blog: http://joze-senegacnik.blogspot.com/
    Blog about flying: http://jsenegacnik.blogspot.com/
    Blog about Building Ovens, Baking and Cooking: http://senegacnik.blogspot.com

  • Problem with SELECT statement. What is wrong with it?

    Why is this query....
    <cfquery datasource="manna_premier" name="kit_report">
    SELECT Orders.ID,
           SaleDate,
           Orders.UserID,
        Distributor,
        DealerID,
        Variable,
        TerritoryManager,
        US_Dealers.ID,
           DealerName,
        DealerAddress,
        DealerCity,
        DealerState,
        DealerZIPCode,
        (SELECT SUM(Quantity)
         FROM ProductOrders PO
         WHERE PO.OrderID = Orders.ID) as totalProducts,    
    FROM Orders, US_Dealers
    WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
    </cfquery>
    giving me this error message...
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
    The error occurred in D:\Inetpub\mannapremier\kit_report2.cfm: line 20
    18 :              WHERE PO.OrderID = Orders.ID) as totalProducts,        
    19 : FROM Orders, US_Dealers
    20 : WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
    21 : </cfquery>
    22 :
    SQLSTATE
      42000
    SQL
       SELECT Orders.ID, SaleDate, Orders.UserID, Distributor, DealerID, Variable, TerritoryManager, US_Dealers.ID, DealerName, DealerAddress, DealerCity, DealerState, DealerZIPCode, (SELECT SUM(Quantity) FROM ProductOrders PO WHERE PO.OrderID = Orders.ID) as totalProducts, FROM Orders, US_Dealers WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN {d '2009-10-01'} AND {d '2009-10-31'} AND Variable = 'Chick Days pre-book'
    VENDORERRORCODE
      -3504
    DATASOURCE
      manna_premier
    Resources:
    I copied it from a different template where it works without error...
    <cfquery name="qZVPData" datasource="manna_premier">
    SELECT UserID,
           TMName,
        UserZone,
              (SELECT COUNT(*)
               FROM Sales_Calls
               WHERE Sales_Calls.UserID = u.UserID) as totalCalls,
        (SELECT COUNT(*)
         FROM Orders
         WHERE Orders.UserID = u.UserID) as totalOrders,
        (SELECT SUM(Quantity)
         FROM ProductOrders PO
         WHERE PO.UserID = u.UserID AND PO.NewExisting = 1) as newItems,
        (SELECT SUM(NewExisting)
         FROM  ProductOrders PO_
         WHERE PO_.UserID = u.UserID) as totalNew,
        SUM(totalOrders)/(totalCalls) AS closePerc
    FROM Users u
    WHERE UserZone = 'Central'
    GROUP BY UserZone, UserID, TMName
    </cfquery>
    What is the problem?

    It's hard to say: what's your request timeout set to?
    700-odd records is not much of a fetch for a decent DB, and I would not expect that to case the problem.  But then you're using Access which doesn't fit the description of "decent DB" (or "fit for purpose" or "intended for purpose"), so I guess all bets are off one that one.  If this query is slow when ONE request is asking for it, what is going to happen when it goes live and multiple requests are asking for it, along with all the other queries your site will want to run?  Access is not designed for this.  It will really struggle, and cause your site to run like a dog.  One that died serveral weeks ago.
    What else is on the template?  I presume you're doing something with the query once you fetch it, so could it be that code that's running slowly?  Have you taken any steps to isolate which part of the code is taking so long?
    How does the query perform if you take the subquery out of the select line?  Is there any other way of getting that data?  What subquery will be running once for every row of the result set... not very nice.
    Adam

  • How to generate mutiple Results for multiple SQL SELECT statements

    I just downloaded SQL Developer 1.5 and play around with it.
    On a daily basis, I need run 4 different SELECT statements and dump the output of each SELECT into an CSV file and send to some users. In SQL Navigator, I can select all 4 SELECT statements and execute them at same time. Once all complete, I will see 4 tabs, each represent the output for each SELECT statement. Then I can export output from each tab into a CSV file.
    It seems that SQL Developer 1.5 still can't run mutiple SELECT statements and display the output of each statement into a separate "Results" tab so that I can export the data into multiple CSV files easily.
    Right now, I have to hightlight each SELECT statement and press F9, then export the output data into CSV.
    I wish I can execute 4 SELECT statements all in once on SQL Developer and get all the output data and export 4 times into 4 CSV files.
    Thanks!
    Kevin

    How about doing it as a set of tabs within the Resuls Tab?
    So you would have your Top row of tabs:
    Results, Script Output, Explain, AutoTrace, DBMS Output and OWA Output
    Then When you have the Results tab selected you could have a row of tabs beneath the Top row with one tab for each result set. Switching between result sets should switch which section of SQL is highlighted as the "Current SQL".
    A similar mechinism could be employed for each of the top level tabs where it makes sense to have multiple output tabs.
    A further refinement of this feature might be to allow the result tabs to be dockable within the parent tab so that multiple result tabs can be viewed simultaneously. This way 2 or more explain plans (for example) could be visually compared without requiring the code to exist in two separate code panes.

  • Error "SELECT statement includes a reserved word"

    Dear Sir,
    I am developing Ms Access 2010 and XP is the operating system.
    I have placed a combobox on a form, but when I tired to update new string value in the same combobox, it generates  an error "The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is
    incorrect." .
    I have debuged "Not In List" event and find  this error generates soon after completing the "Not In List" event. I tried to find out any help on the internet but failed.
    I shall be ever grateful if some one could help this regards.
    Kazim

    I think you need to do some homework on how relational databases work. 
    The following is my short description of the database relational model, but I emphasise the word 'short'. 
    The subject is a complex one with a huge body of academic and technical literature, so I can only hope to touch upon the basic principles of the model:
    "The database relational model was originally proposed by E F Codd in a paper in 1970 in the journal 'Communications
    of the Association for Computing Machinery'.  Since then there has been a vast amount of further theoretical work, and the relational model has shown itself to be a robust one. 
    Without going too deeply into the theoretical basis, which can be quite abstract, a relational database in essence models a part of the real world in terms of its entity types and the relationship types between them. 
    Note the inclusion of the word 'type' in both cases here. 
    While its almost always used in the former case, its often omitted in the latter case. 
    This is a little bit sloppy but not too important.  When one talks about a 'relationship' it really refers to a relationship value. 
    As an example 'marriage' is a relationship type, but my being married to my wife Fiona is a relationship value, represented by our names on the marriage certificate, which is the physical equivalent of a row in a Marriages table with columns Husband
    and Wife, each referencing the primary key of a table People. 
    This is a many-to-many relationship type (I've been married twice so would be in two rows, my first wife would also be in two rows as she remarried too). 
    It is resolved into two one-to-many relationship types, People to Marriages in each case, in one case via the Husband column in the other via the Wife column.
    In a relational database tables model Entity Types. 
    In the above example People is an entity type, modelled by the People table. 
    Marriage is also an entity type, modelled by the Marriages table. 
    As we've seen it's also a relationship type.  In fact a relationship type is just a special kind of entity type.
    Each column in a table represents an attribute type of each entity type, so attribute types of People might be FirstName,
    LastName, DateOfBirth etc.  This table would also have a PersonID numeric column (usually an autonumber) as its primary key as names are not distinct. 
    Each row in a table represents one instance of the entity type, and the attributes of each instance are represented by values at column positions in the row. 
    This is the only way that data can be legitimately stored in a relational database.
    It's important that there is no redundancy in the information content of the database. 
    This is achieved by the process of 'normalization'.  Normalization is based on a set of 'normal form's ranging from First Normal Form (1NF) to Fifth Normal Form (5NF) and beyond, though the higher normal forms are of a rather 
    different nature and we need not concern ourselves unduly with them. 
    There is also a Boyce/Codd Normal Form (BCNF) which was inserted when it was found that the original Third Normal Form was deficient; it didn't cater satisfactorily for tables with two or more candidate keys where the keys were composite and overlapped,
    i.e. Had a column in common.  I won't go into the details of normalization here; you'll find it written up in plenty of places.
    To see an example of redundancy and therefore a table which is not properly normalized take a look at the Customers table
    in the sample Northwind database which comes with Access.  You'll see that it includes City, State/Region and Country columns. 
    If you look at its data you'll see for instance that we are redundantly told twice that Boston is in Massachusetts, and that this is in the USA 
    twice.  This is not just inefficient, it is dangerous as it leaves the table open to inconsistent data being entered. 
    There is nothing to stop somebody putting Boston in the Massachusetts in one row and Milwaukee 
    in another, or putting Milwaukee  in the UK in one row and the USA in another. 
    To normalize the table it should be decomposed into Customers, Cities, Regions and Countries tables, each of the first three with a foreign key referencing the primary key of the next table up in the hierarchy."
    In your case you say a book can have more than one publisher. 
    This is true if you regard the entity as the book as a single 'work', not as a title. 
    I have two copies of Jane Austen's Mansfield Park for instance, each by a different publisher. 
    It is a single 'work' however.  I've no idea if anyone else has written a book called Mansfield Park, but there is no reason why not, so let's assume that one exists.
     This is not the same 'work' as Jane Austen's book, so conceptually is a different entity of type Books, and would be represented by a separate row in a table Books.
    In the above context there is a many-to-many relationship type between Books and Publishers. 
    There is only one way to model such a relationship type, which is by a table which resolves the relationship type into two one-to-many relationship types. 
    So the model would, diagrammatically be:
    Books----<BookPublishers>----Publishers
    Title is a non-key column of Books. 
    The same title may appear in different rows, as with our hypothetical Mansfield Park by another author. 
    The primary key of books is a numeric BookID, usually an autonumber. 
    The BookPublishers table would have foreign keys BookID and PublisherID referencing the primary keys of the two referenced tables. 
    It would also have columns representing any attributes of the relationship type between the book and the publisher. 
    The primary key of this table is a composite one of BookID and Publisher.
    To record multiple editions of a book published by a publisher requires another table along the following lines:
    BookEditions
    ....PublisherID 
    (FK)
    ....BookID 
    (FK)
    ....EditionNumber
    ....EditionDate
    .....ISBN
    In this table PublisherID and BookID are a composite foreign key referencing the primary key of BookPublishers. 
    Note that ISBN is a column in this table as it applies to each edition of a book. 
    In the language of the relational model it is said to be functionally determined by the key of BookEditions.
    Hopefully my short stock description of the relational model above, and my brief description of how it applies to the reality
    which you are attempting to model will give you an insight into how to build a database, but I would strongly recommend that you first do some background work on how the database relational model works and how to apply its principles in Access.
    I'll leave you with my own four, not altogether serious but nevertheless valid, ground rules for designing a relational database:
    1. 
    KISS (Keep it simple, stupid!).
    2. 
    When in a hole the first thing to do is stop digging.
    3. 
    Always take account of Murphy's Law: 'If something can go wrong, it will go wrong'
    4. 
    Always follow the advice given by Richard Feynman to his students: 'Don't write it down until you understand it'.
    Ken Sheridan, Stafford, England

  • Traces are not being generated

    hi,
    I have 9.1.0.8 database on windows 2003 (32 bit). I am suing following statement to start system wide tracing but i don't see any tarces being generated at user_dump_dest location. any idea what is going wrong and what thing i am missing?
    ALTER SYSTEM SET EVENTS '10046 trace name context forever, level 8';
    Timed_statistics is set to true
    Salman

    Strange - what you have done should work, it works on my 10G database OK.
    Sorry but dont have much else to add ...
    I presume that if you just do it at session level it works ok?
    ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';

  • For update in select statement

    i have a table which store data in a clob. sometimes user forget to add and extra carriage return after last line. so i am doing the following to modify the clob
    SELECT file_content INTO lv_lob FROM files WHERE id = p__id FOR UPDATE;
    dbms_lob.writeappend(lv_lob,2,C_NEW_LINE);
    C_NEW_LINE CONSTANT VARCHAR2(2) := Chr(13)||Chr(10);
    'for update' should only lock that specific row since id is a pk key in the table.
    i have two front end screen where people upload file. a unique id is generated for each file and the data with id inserted in the table. user can upload file from the two different screen at same time.
    the problem is that i am getting a 'resource busy and acquire with NOWAIT specified' error. i don't know why if every file i upload belongs to different row.
    anybody knows why i would get this error and how can i solve it?

    How are you generating the unique ID? Are you using a sequence? Or are you using something that forces serialization?
    Where in the program flow are you adding the extra carriage return?
    Is it this SELECT statement that is throwing the error? Or is it being thrown somewhere else?
    Justin

  • Can we use is null in our select statement in ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.

    Hi,
    I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
    For a list of forums please see here:
    http://forums.sdn.sap.com/index.jspa
    Kind Regards,
    Owen

Maybe you are looking for

  • What's the best way to do this........?

    We have an apple tv, G5 Power PC running 10.5, an iPhone, and a nanno. This is what I'm trying to achieve... 1.Have the Apple TV sync to my wife's iTunes library as well as our iPhoto library. 2. Have my iphone sync to my itunes library, iphoto libra

  • Puzzle: TRY_CAST in Azure SQL, TRY_CONVERT in SS 2012?

    For a while I thought Azure SQL T-SQL is a subset of SQL Server 2012 T-SQL. Not so.... It has its own individuality! Related blog: http://raresql.com/category/sql-server-2012/built-in-functions/conversion-function/ Kalman Toth Database & OLAP Archite

  • Convert from ISO 8859-1 encoding to UTF-8

    Hi My Os name is 'SunOS ut51109 5.10 Generic_144500-19 sun4v sparc SUNW,T5440'. I want to change the encoding of the existing .bcp file from ISO 8859-1 to UTF-8 with out using any temp files as these .bcp file will be pointed by an external table. he

  • I updated to maverick and now I cant rent films from itunes store to my apple tv.

    I updated to Maverick and now I cant download rentals from the itune store. I received the bill but no film. I rented on Apple TV but it can't download. I have a MacBook Air, Apple TV and Iphone 5 What is happening?

  • IPad 2 won't get past apple logo and various other problems...

    I knew I shouldn't have updated to iOS 8, my iPad was getting increasingly slower with each software update since I bought it a few years ago. A few weeks ago the first problem arose - the home button suddenly became unresponsive. Initially it would