SQL Expression returning too many results

I am trying to display the value of a field in one table as a caption in the report header. This  caption is above a u2018descriptionu2019 field in the details section. When I run my report, I get  the description field displaying 832 times; which is the number of rows found in my caption table. Here is the structure of the two tables:
Table 1: Code, Description
Table 2: Table, Name, Field Name, Caption
Here are the SQL Expressions that I have tried:
(SELECT Caption FROM Table2
    WHERE Table2.FieldName='Description'
          AND Table2.TableName='Code')
(SELECT DISTINCT Caption FROM Table2
    WHERE Table2.FieldName='Description'
          AND Table2.TableName='Code')
And
(SELECT TOP 1 Caption FROM Table2
    WHERE Table2.FieldName='Description'
          AND Table2.TableName='Code')
If I run these directly in my Db, I get correct results. If in Crystal, incorrect results. I have tried the following suppress on the Details: Table1.Code= previous (Table1.Code) which works UNLESS I have any summaries. Once I include a summary, my total ALWAYS factors in the suppressed, duplicate records.
I have now moved to try using parameters and a sub report for each caption; however my existing reports have sub reports that also need caption changes and I am not aware of a way to add a subreport to a subreport
Any ideas?

can you use select distinct on all the queries,
crystal tends to duplicate
create a group for your distinct value
place the records in the group header and it will return the first unique value it hits.

Similar Messages

  • ExecuteQueryForObject returned too many results jdbc error

    Hi All,
    I am getting the following error on running the tomcat 6.0 and I have Oracle 11g installed.
    08 Dec 2010 16:23:41 ERROR [QUARTZ_Worker-5] org.quartz.core.JobRunShell - Job DCTM.DCTMServerPipe threw an unhandled Exception:
    org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error: executeQueryForObject returned too many results.; nested exception is java.sql.SQLException: Error: executeQueryForObject returned too many results.
         at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:121)
         at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
         at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
         at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:271)
         at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:265)
         at com.emc.documentum.bpm.daos.impl.AbstractIbatisBaseDaoImpl.queryForObject(AbstractIbatisBaseDaoImpl.java:119)
         at com.emc.documentum.bpm.bamengine.daos.impl.ServerConfigDaoImpl.getDBCurrentTime(ServerConfigDaoImpl.java:28)
         at com.emc.documentum.bpm.bamengine.services.server.factory.impl.ServersFactoryImpl.updatePipeServerTimezoneOffset(ServersFactoryImpl.java:56)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
         at $Proxy50.updatePipeServerTimezoneOffset(Unknown Source)
         at com.emc.documentum.bpm.bamengine.services.sharedservices.impl.TaskManagerServiceImpl.executePipe(TaskManagerServiceImpl.java:341)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
         at $Proxy52.executePipe(Unknown Source)
         at com.emc.documentum.bpm.bamengine.scheduler.impl.PipeJobImpl.execute(PipeJobImpl.java:17)
         at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
         at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
    Caused by: java.sql.SQLException: Error: executeQueryForObject returned too many results.
         at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:124)
         at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
         at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
         at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
         at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:273)
         at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
         ... 23 more
    How can this be resolved? Please help !!
    Thanks, T
    Edited by: 805903 on Dec 9, 2010 3:00 AM

    Error executeQueryForObject returned too many results
    Typical Error msg:
    “SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error: executeQueryForObject returned too many results.; nested exception is java.sql.SQLException: Error: executeQueryForObject returned too many results”
    The error is caused for using queryForObject (for a single result) instead of queryForList (when expecting multiple results).
    Example of correct solution
    In DAO:
    public List<UpdatedContractRateDO> getUpdatedCtrctRate(Map paramMap) throws DataAccessException {
    return (List<UpdatedContractRateDO>) getSqlMapClientTemplate().queryForList("charge.getUpdatedCtrctRate", paramMap);
    }

  • ExecuteQueryForObject returned too many results.

    Hi,
    My servlet accesses an Oracle db, it works fine most of the time except for when I search for one particular entry.
    When I do this the following error message is displayed:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Error: executeQueryForObject returned too many results.
         org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    java.sql.SQLException: Error: executeQueryForObject returned too many results.
         com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:108)
         com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
         com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
         com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
         com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70)
         com.bmw.urt3fms.cardata.ctrl.SearchCarAction.execute(Unknown Source)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    This is really strange as all the other searches I have done all worked except this one.
    Any ideas as to why it would display this??
    Nick

    Error executeQueryForObject returned too many results
    Typical Error msg:
    “SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error: executeQueryForObject returned too many results.; nested exception is java.sql.SQLException: Error: executeQueryForObject returned too many results”
    The error is caused for using queryForObject (for a single result) instead of queryForList (when expecting multiple results).
    Example of correct solution
    In DAO:
    public List<UpdatedContractRateDO> getUpdatedCtrctRate(Map paramMap) throws DataAccessException {
    return (List<UpdatedContractRateDO>) getSqlMapClientTemplate().queryForList("charge.getUpdatedCtrctRate", paramMap);
    }

  • SQL subquery returning too many rows with Max function

    Hello, I hope someone can help me, I been working on this all day. I need to get max value, and the date and id where that max value is associated with between specific date ranges. Here is my code , and I have tried many different version but it still returning
    more than one ID and date
    Thanks in advance
    SELECT
      distinctbw_s.id, 
    avs.carProd,cd_s.RecordDate,
    cd_s.milkProductionasMilkProd,
    cd_s.WaterProductionasWaterProd
    FROMtblTestbw_s
    INNERJOINtblTestCpcd_sWITH(NOLOCK)
    ONbw_s.id=cd_s.id   
    ANDcd_s.recorddateBETWEEN'08/06/2014'AND'10/05/2014'
    InnerJoin
    (selectid,max(CarVol)ascarProd
    fromtblTestCp
    whererecorddateBETWEEN'08/06/2014'AND'10/05/2014'
     groupby 
    id)avs
    onavs.id=bw_s.id
    id RecordDate carProd       MilkProd WaterProd
    47790 2014-10-05   132155   0 225
    47790 2014-10-01   13444    0 0
    47790 2014-08-06   132111    10 100
    47790 2014-09-05   10000    500 145
    47790 2014-09-20   10000    800 500
    47791 2014-09-20   10000    300 500
    47791 2014-09-21   10001    400 500
    47791 2014-08-21   20001    600 500
    And the result should be ( max carprod)
    id RecordDate carProd       MilkProd WaterProd
    47790 2014-10-05   132155  0 225
    47791 2014-08-21   20001    600 500

    Help your readers help you.  Remember that we cannot see your screen, do not know your data, do not understand your schema, and cannot test a query without a complete script.  So - remove the derived table (to which you gave the alias "avs")
    and the associated columns from your query.  Does that generate the correct results?  I have my doubts since you say "too many" and the derived table will generate a single row per ID.  That suggests that your join between the first
    2 tables is the source of the problem.  In addition, the use of DISTINCT is generally a sign that the query logic is incorrect, that there is a schema issue, or that there is a misunderstanding of the schema. 

  • Pl/Sql block returning too many values

    Hi
    Below is simple pl/sql block.while excecuting this i'm getting too many values exception
    declare
    attrib QW_ACCT_ATTR%ROWTYPE;
    begin
    SELECT ATTR_END_DATE, ATTR_NM, ATTR_VAL INTO attrib FROM (SELECT ATTR_END_DATE, ATTR_NM, ATTR_VAL FROM QW_ACCT_ATTR where CUST_ACCT_ID='5158660414' AND ATTR_NM = 'SS' ORDER BY ATTR_END_DATE DESC) where rownum = 1;
    DBMS_OUTPUT.PUT_LINE('end daate is...'||attrib.ATTR_END_DATE);
    end;
    could anybody please help me how to rewrite this qwery to get only one record.
    we are not supposed to use cursors here,
    thanks

    I am just changing your logic,
    declare
    attrib QW_ACCT_ATTR%ROWTYPE;
    begin
    SELECT ATTR_END_DATE, ATTR_NM, ATTR_VAL INTO attrib FROM (SELECT ATTR_END_DATE, ATTR_NM, ATTR_VAL FROM QW_ACCT_ATTR where CUST_ACCT_ID='5158660414' AND ATTR_NM = 'SS' ORDER BY ATTR_END_DATE DESC where rownum = 1) ;
    DBMS_OUTPUT.PUT_LINE('end daate is...'||attrib.ATTR_END_DATE);
    end;

  • JDO: Query returns too many results.

    Hello,
    I want to get some DO-Entities from an empty table. When I execute the query I retrieve more than 2 000 000 000 results what is definitly too much for an empty table. The DO has an one-to-many relationship to another class and a many-to-one relationship to another one.
    The .map and .jdo files of the class and the classes in relation made accordng to the explanations in the Development Manual chapter "Mapping Persistent Classes to Database Tables" (so including DFG- and embedded- attributes). Enhancing is successfull and the work with the classes that doesn't have relationships also.
    The query looks like this:
                   manager = getPersistenceFactory().getPersistenceManager();
                   String filter = "version == \"" + version + "\" && postingLevel == \"" + postingLevel +
                                       "\" && closingPeriod == " + closingPeriod + " && bunit== \"" + bunit + "\"";
                   Query query = manager.newQuery(AD_DO_Protocol.class, filter);
                   Collection col = (Collection) query.execute();
    I also tried to use the extent with the same result.
    Any ideas?
    Regards,
    Jan

    Hi Guru,
    first of all in that certain method of the DAO I'm not able to use the primary key because I implement a check if an entity with the given attributes allready exists.
    Second I don't want (and as I think don't have) to write the mentioned java function for the following reason: There must be max one result for the given query. Thats a constraint implied by our business logic.
    In fact at the given moment there must not be a single result because the table IS EMPTY!!!
    Any other ideas?
    Thx and regards,
    Jan

  • Query returns too many results

    I have this query that returns 118,900 records when I try to
    add
    or oth_tchname_ssn like '%123456789%'
    at the end of the query.
    When I remove the or oth_tchname_ssn like '%123456789%' it
    returns 32 records which seems about right.
    Any ideas as to where my cfquery statement is wrong?
    Thanks
    Emmanuel

    This was solved by adding parent tags.

  • Texts keep getting returned--too many digits error, pls help

    Hi, everyone!
    I upgraded to 4.3.3, yesterday so far no problems, except this morning my phone started to send me an error message every time I send a text and says "this message could not be sent, you've entered too many digits." How do I fix this? And the number it shows is an 11-digit number because it adds the 1...
    Does anyone know what I can do?

    Error executeQueryForObject returned too many results
    Typical Error msg:
    “SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error: executeQueryForObject returned too many results.; nested exception is java.sql.SQLException: Error: executeQueryForObject returned too many results”
    The error is caused for using queryForObject (for a single result) instead of queryForList (when expecting multiple results).
    Example of correct solution
    In DAO:
    public List<UpdatedContractRateDO> getUpdatedCtrctRate(Map paramMap) throws DataAccessException {
    return (List<UpdatedContractRateDO>) getSqlMapClientTemplate().queryForList("charge.getUpdatedCtrctRate", paramMap);
    }

  • Unable to create report. Query produced too many results

    Hi All,
    Does someone knows how to avoid the message "Unable to create report. Query produced too many results" in Grid Report Type in PerformancePoint 2010. When the mdx query returns large amount of data, this message appears. Is there a way to get all
    the large amount in the grid anyway?
    I have set the data Source query time-out under Central Administration - Manager Service applications - PerformancePoint Service Application - PerformancePoint Service Application Settings at 3600 seconds.
    Here Event Viewer log error at the server:
    1. An exception occurred while running a report.  The following details may help you to diagnose the problem:
    Error Message: Unable to create report. Query produced too many results.
            <br>
            <br>
            Contact the administrator for more details.
    Dashboard Name:
    Dashboard Item name:
    Report Location: {3592a959-7c50-0d1d-9185-361d2bd5428b}
    Request Duration: 6,220.93 ms
    User: INTRANET\spsdshadmin
    Parameters:
    Exception Message: Unable to create report. Query produced too many results.
    Inner Exception Message:
    Stack Trace:    at Microsoft.PerformancePoint.Scorecards.Server.PmServer.ExecuteAnalyticReportWithParameters(RepositoryLocation analyticReportViewLocation, BIDataContainer biDataContainer)
       at Microsoft.PerformancePoint.Analytics.ServerRendering.OLAPBase.OlapViewBaseControl.ExtractReportViewData()
       at Microsoft.PerformancePoint.Analytics.ServerRendering.OLAPBase.OlapViewBaseControl.CreateRenderedView(StringBuilder sd)
       at Microsoft.PerformancePoint.Scorecards.ServerRendering.NavigableControl.RenderControl(HtmlTextWriter writer)
    PerformancePoint Services error code 20604.
    2. Unable to create report. Query produced too many results.
    Microsoft.PerformancePoint.Scorecards.BpmException: Unable to create report. Query produced too many results.
       at Microsoft.PerformancePoint.Scorecards.Server.Analytics.AnalyticQueryManager.ExecuteReport(AnalyticReportState reportState, DataSource dataSource)
       at Microsoft.PerformancePoint.Scorecards.Server.PmServer.ExecuteAnalyticReportBase(RepositoryLocation analyticReportViewLocation, BIDataContainer biDataContainer, String formattingDimensionName)
       at Microsoft.PerformancePoint.Scorecards.Server.PmServer.ExecuteAnalyticReportWithParameters(RepositoryLocation analyticReportViewLocation, BIDataContainer biDataContainer)
    PerformancePoint Services error code 20605.
    Thanks in advance for your help.

    Hello,
    I would like you to try the following to adjust your readerquotas.
    Change the values of the parameters listed below to a larger value. We recommend that you double the value and then run the query to check whether the issue is resolved. To do this, follow these steps:
    On the SharePoint 2010 server, open the Web.config file. The file is located in the following folder:
    \Program Files\Microsoft Office Servers\14.0\Web Services\PpsMonitoringServer\
    Locate and change the the below values from 8192 to 16384.
    Open the Client.config file. The file is located in the following folder:
    \Program Files\Microsoft Office Servers\14.0\WebClients\PpsMonitoringServer\
    Locate and change the below values from 8192 to 16384.
    After you have made the changes, restart Internet Information Services (IIS) on the SharePoint 2010 server.
    <readerQuotas
    maxStringContentLength="2147483647"
    maxNameTableCharCount="2147483647"
    maxBytesPerRead="2147483647"
    maxArrayLength="2147483647"
                  maxDepth="2147483647"
    />
    Thanks
    Heidi Tr - MSFT
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • "Bad Data, too many results for shortname"

    Every 10 minutes since October 13 the wikid error log has recorded the following error message:
    *"Bad Data, too many results for shortname: username"*, always naming the same user, who is not actually doing anything.
    Coinciding with that message at the same time every 10 minutes, the system log records 13 or 14 of the following:
    *"Python\[15645\]: ••• -\[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release)."*
    15645 is a process owned by _teamserver, which would appear to confirm the connection between the python and wikid error messages.
    Last clue: The messages (I have determined in hindsight) started while I was setting up the server to do vacation messages. The user named in the "Bad data" messages was the user who wanted to (and did) set up a vacation message at that time. They worked, too.
    Anyone have any ideas about what is going on and how to fix it? BTW, google does not find even one page where this "Bad data" error message is mentioned.

    Thanks for your response. To answer your questions:
    +Are you using AD for your directory?+ No. OD master only.
    +Are there users with duplicate shortnames in your directory system?+ No, and to double check, I searched with WGM and only the one came up.
    +As a bit of background, the wiki server keeps an private index of user and group information so we can track user preferences, and the "Bad Data, too many results for shortname: username" error is triggered when we do a lookup in that index for a particular user and we (unexpectedly) hit duplicate entries. Are you seeing an issue with using the software, or just an annoying log message?+ It's hard to say (for me) what might be related. The directory or wiki related issues with the server include:
    • A memory issue with slapd that eventually causes it to crash. (preceded by lots of "bdbdbcache: db_open(+various: sn, displayname, givenname, mail, maybe others+) failed: Cannot allocate memory (12)" and "logging region out of memory" and "index_param failed" errors.
    • The wiki is slow, despite very light use.
    • Wake from sleep (network clients with authentication required) can be very slow. Several minutes even.
    Any suggestions you may have would be appreciated.

  • Dimension Filter LOV - Too many results; Refine your search

    Hi,
    I am using Dimension filter in Design Studio which uses the hierarchy dimension. In the preview mode the filter is not showing any members instead its asked to use the search functionality. I understand there is a limit in retrieving the LOV. Is anyway i can increase the number of LOV?
    I need to have this functionality work, The user want to navigate the hierarchy in the filter. Please any help highly appreciated
    Thanks
    VJ

    Hi,
    same question here: DS 1.2 - Too many results; refine your search
    Regards,
    David

  • PL/SQL: ORA-00913: too many values

    I don't find out why i'mg getting an "ORA-00913: too many values" Error
    This Example works fine:
    DECLARE
    TYPE session_type IS TABLE OF v$session%ROWTYPE ;
    blocking_sessions session_type;
    BEGIN
    select * bulk collect into blocking_sessions from v$session where blocking_session is not null;
    END;
    But in this Example i'm getting an ORA-00913. Can anybody tell me what i'm doing wrong?
    DECLARE
    TYPE session_type IS TABLE OF v$session%ROWTYPE ;
    blocking_sessions session_type;
    BEGIN
    select distinct blocking_session bulk collect into blocking_sessions from v$session where blocking_session is not null;
    END;
    select distinct blocking_session bulk collect into blocking_sessions from v$session where blocking_session is not null;
    ERROR at line 7:
    ORA-06550: line 7, column 70:
    PL/SQL: ORA-00913: too many values
    ORA-06550: line 7, column 1:
    PL/SQL: SQL Statement ignored

    OK this one works also:
    DECLARE
    TYPE session_type IS TABLE OF NUMBER ;
    blocking_sessions session_type;
    BEGIN
    select distinct blocking_session bulk collect into blocking_sessions from v$session where blocking_session is not null;
    END;
    But when i'm selecting for about 20 columns of a table with 30 columns. Do I have to declare every single column?

  • Help with an SQL Expression - Return field value where Datetime is Min or First datetime

    Hello,
    I'm extracting results for a patient population.
    I have 6 SQL expressions that pull back the first date for specific procedures or Medications being ordered.
    These Expressions work perfect - One of the expressions return the first time a lab was ordered.
    I'm using SQL that return
    Min(OrderDatetime)
    From OrderTable
    Where
    LABCode = XXX
    I've now been ask to return the value of this lab result.
    Question: How do I write an SQL expression that return the Lab value of the Min(OrderDatetime)
    Example Data
    PATID* LABID * OrderDatetime * ResultValue
    Pat1*133 * 12/12/2013 11:00:pm * 77
    Pat1*145 * 12/12/2013 11:45:pm * 45
    Pat1*147 * 12/13/2013 12:10:AM * 78
    I was to return 77
    Thanks
    Steve

    Here is what I came up with but I'm getting an error -
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <,>,>= or when the subquery is used as an expression.
    Any thoughts on what I'm doing wrong?
    SELECT LABRESULTS.ORDER_VALUE as LabResult
      FROM   LABRESULTS, ORDERS_PROD, PATIENT_HSP
      WHERE
    "ORDERS_PROD"."CSN_ID" = "LABRESULTS"."CSN_ID" AND
    "ORDERS_PROD"."ORDER_PROC_ID" = "LABRESULTS"."ORDER_PROC_ID" AND
    ORDERS_PROD.ORDER_INST IN     (
                                  SELECT Min(ORDERS_PROD.ORDER_INST)
                                  FROM   ORDERS_PROD
                                  WHERE "PATIENT_HSP"."CSN_ID" = "ORDER_PROD"."CSN_ID" AND
                                  ("ORDERS_PROD"."ORDER_STATUS_C"<>4 OR
                                  "ORDERS_PROD"."ORDER_STATUS_C"<>9) AND
                                  "ORDERS_PROD"."FUTURE_OR_STAND" IS  NULL AND
                                  "ORDERS_PROD"."REASON_FOR_CANC_C" IS  NULL AND
                                  ("ORDERS_PROD"."PROC_CODE" = 'LAB7764' OR
                                  "ORDERS_PROD"."PROC_CODE" = 'LAB7765' OR
                                  "ORDERS_PROD"."PROC_CODE" = 'LAB7766' OR
                                  "ORDERS_PROD"."PROC_CODE" = 'LAB7767')

  • SQL query runs too many times in SQL server Profiler

    Hi Experts
    I have designed a report using SQL database.Report is based on Add Command Object, View and Table.Which are link and gives desired output.
    However it takes long time. In the SQL Sever profiler it shows that query is executing too many times.
    When in the Add Command object I edit the query Say I write TOP 5000 then it executes once however if I write Add 5001 then I face the same behavior.
    I have checked "Grouping on server" option in options.
    Please Advice.
    Regards
    Asha.

    Thanks Raghavendra for reply
    How adding group will help? I have to link this command objects with view and table.Also  When I add "TOP 5000" in add command query it executes only 1 time in SQL query Profiler hower if edit that query to "TOP 5001" then it again it executes several time which is impacting the performance.
    Please advice?
    Regards
    Asha.

  • Issue with Oracle Merge statements (PL/SQL: ORA-00913: too many values)

    Hi All,
    I am using the below merge statement and I am getting too many rows issues when I am compiling.
    BEGIN
    FOR te_rec IN ( SELECT /*+ parallel(ts,4) */ te.dtv_acct_num FROM telcos_eligible te, telcos_setup ts, telcos_partners tp
    WHERE tp.telcos_name = UPPER((p_telcos_name))
    AND ts.partner_id = tp.partner_id
    AND te.ts_id = ts.ts_id ) LOOP
    MERGE INTO tcs_accounts
    USING (
    SELECT /*+ DRIVING_SITE(a) */account_id, a.subscriber_id, status, account_type FROM account@tcs_to_paris a WHERE a.subscriber_id = te_rec.dtv_acct_num
    ) paris_accounts
    ON (tcs_accounts.subscriber_id = paris_accounts.subscriber_id)
    WHEN MATCHED THEN
    UPDATE SET
    account_type = paris_accounts.account_type,
    subscriber_id = paris_acounts.subscriber_id,
    status = paris_accounts.status
    WHEN NOT MATCHED THEN
    INSERT(account_id, subscriber_id, status_account_type)
    VALUES(paris_accounts.account_id, paris_accounts.subscriber_id, paris_accounts.status, paris_accounts.account_type);
    END LOOP;
    END;
    Can you let me know what is the issue here.
    Thanks,
    MK.

    Hi,
    Maddy wrote:
    ... WHEN NOT MATCHED THEN
    INSERT(account_id, subscriber_id, status_account_type)
    VALUES(paris_accounts.account_id, paris_accounts.subscriber_id, paris_accounts.status, paris_accounts.account_type);This is one of the many times when a little formatting can really help you. Anybody can forget a column (or have an extra one, or type a _ when they mean ,) but if you write code like this
    INSERT (               account_id,                 subscriber_id,                                  status_account_type)
    VALUES (paris_accounts.account_id,  paris_accounts.subscriber_id,  paris_accounts.status,  paris_accounts.account_type);you might spot the error yourself.
    Always format your code. When you post any formatted text on thsi site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for