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

Similar Messages

  • 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.

  • 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.

  • 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 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.

  • Query returning too many records

    Hello,
    Below is my query. My intention is to return only the records that fail the test, but it is returning all the records that failed the test and also those that passed the Test. See below
    select pod.pur po_pfx, pod.purch po#, pod.poline line#,pod.waid,
         pod.st, pod.color,pod.po_det,
              (case when pod.po_det is null then 'color can not be Null'
         else case when trim(pod.po_det) = ''then 'color can not be Null'
                   else case when (pod.po_det) is null or trim(pod.po_det) = ''
                   and pod.pur='K'then 'Color is no good'
                        end end end) error_message     
    from s.detail pod, s.ste s
    where po_ind = '0' and po_status='0'     
    and pod.unit_id = s.unit_id
    and pod.id = s.id
    and s.type_ind ='0'

    SELECT *
    FROM (SELECT pod.pur po_pfx, pod.purch po#, pod.poline line#,pod.waid,
                 pod.st, pod.color,pod.po_det,
                 CASE WHEN TRIM(pod.po_det)IS NULL THEN 'color can not be Null'
                      WHEN pod.pur='K' THEN 'Color is no good'
                      ELSE NULL END error_message
          FROM s.detail pod, s.ste s
          WHERE po_ind = '0' and
                po_status='0' and
                pod.unit_id = s.unit_id and
                pod.id = s.id and s.type_ind ='0')
    WHERE error_message IS NOT NULLor possibly
    SELECT pod.pur po_pfx, pod.purch po#, pod.poline line#,pod.waid,
           pod.st, pod.color,pod.po_det,
           (CASE WHEN TRIM(pod.po_det)IS NULL THEN 'color can not be Null'
                 WHEN pod.pur='K' THEN 'Color is no good'
                 ELSE NULL END) error_message
    FROM s.detail pod, s.ste s
    WHERE po_ind = '0' and
          po_status='0' and
          pod.unit_id = s.unit_id and
          pod.id = s.id and s.type_ind ='0' and
          (TRIM(pod.po_det) IS NULL OR
           pod.pur = 'K')Not sure which would be more performant.
    TTFN
    John

  • 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);
    }

  • "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

  • 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. 

  • 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.

  • Resultset returning too many rows when using Group by

    Hello
    My problem is this
    I run the following query which uses a Group By
    sQury = "SELECT Distinct Searches.categoryId ,count(Searches.categoryId) AS NUMBER_OF_APPEARANCE" +
    " FROM Searches " +
    " GROUP BY Searches.categoryId ";
    When I run this query in Access the query returns 15 rows (since I have 15 products)
    When I run this query by opening Resultset I get 60 rows (Which are the number of records in Searches table)
    NOTE: the first 15 rows in the resultset are the 15 rows I got in access and after that I have something like null rows with no data inside (with causes real problems to my program
    I use the followin code in order to run the query
    public ResultSet m_resultSet = null;
    private Statement m_stat;
    private Connection m_conn;
    m_stat = m_conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    m_stat.execute(sql)
    m_resultSet = dbResultSet.m_stat.getResultSet();
    If any one see any problem with this please help

    Try removing distinct as well.
    (The above suggestion also makes sense as it is not possible to update a count. Even if it has no impact on the problem.)

  • 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;

  • How to hold result of query with too many characters into a cursor?

    Hi, guys:
    Could anyone help me on this issue? I encounter such a error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small. The reason is because the returning result is too big to hold in a cursor. I know I should use clob, how can I return result of a query into a clob?
    Here is my code of procedure
    function Find_Near_Offenders(P_f_Resident_Latitude in float, P_f_Resident_Longitude in float, P_n_Radius in number, P_s_User_Group in varchar2, P_b_Found out boolean) return rcur_Offender AS
        rcur_Offender_address rcur_Offender;
      begin
        if P_s_User_Group='Public' then
            open rcur_Offender_address for
              select distinct  so.offender_id as "Offender_ID",  so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender_Name",
              replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#') ,',') as "Address",
              replace(replace(nvl2(sl.physical_address1,sl.physical_address1||' '||sl.physical_city ||' '||sl.physical_county||' '||(select sc4.description from sor_code sc4 where sc4.code_id=sl.physical_state)||' '||sl.physical_zip, 'No Known Address'),'#') ,',')  as "Physical_Address",
              nvl2(sl.ADDRESS_LATITUDE, to_char(sl.ADDRESS_LATITUDE)||','||to_char(sl.address_longitude),'') as "Address_Geocoding",
              nvl2(sl.physical_address_latitude,to_char(sl.physical_address_latitude) ||','||to_char(sl.physical_address_Longitude),'') as "Physical_Geocoding"
              from sor_location sl, sor_offender so, sor_offense sof, registration_offender_xref rox, sor_last_locn_v sllv
              where rox.offender_id=so.offender_id
              and sllv.offender_id(+)=so.offender_id
              and sl.location_id(+)=sllv.location_id
              and sof.offender_id=so.offender_id
              and rox.status not in ('Merged')
              and rox.reg_type_id=1
              and upper(rox.status)='ACTIVE'
              and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
              --and sl.physical_address_latitude is null
              and sl.ADDRESS_LATITUDE <=to_number(P_f_Resident_Latitude)+0.02*to_number(P_n_Radius) and sl.ADDRESS_LATITUDE>= to_number(P_f_Resident_Latitude)-0.02*to_number(P_n_Radius)
              and sl.address_longitude >=to_number(P_f_Resident_Longitude)-0.02*to_number(P_n_Radius) and  sl.address_longitude<=to_number(P_f_Resident_Longitude)+0.02*to_number(P_n_Radius)
              and sor_google_map_service.Calculate_Distance(P_f_Resident_Latitude, P_f_Resident_Longitude, sl.ADDRESS_LATITUDE, sl.address_longitude)<=P_n_Radius
              union
              select distinct  so.offender_id as "Offender_ID",  so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender_Name",
              replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#') ,',') as "Address",
              replace(replace(nvl2(sl.physical_address1,sl.physical_address1||' '||sl.physical_city ||' '||sl.physical_county||' '||(select sc4.description from sor_code sc4 where sc4.code_id=sl.physical_state)||' '||sl.physical_zip, 'No Known Address'),'#') ,',')  as "Physical_Address",
              nvl2(sl.ADDRESS_LATITUDE, to_char(sl.ADDRESS_LATITUDE)||','||to_char(sl.address_longitude),'') as "Address_Geocoding",
              nvl2(sl.physical_address_latitude,to_char(sl.physical_address_latitude) ||','||to_char(sl.physical_address_Longitude),'') as "Physical_Geocoding"
              from sor_location sl, sor_offender so, sor_offense sof, registration_offender_xref rox, sor_last_locn_v sllv
              where rox.offender_id=so.offender_id
              and sllv.offender_id(+)=so.offender_id
              and sl.location_id(+)=sllv.location_id
              and sof.offender_id=so.offender_id
              and rox.status not in ('Merged')
              and rox.reg_type_id=1
              and upper(rox.status)='ACTIVE'
              and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
              and sl.physical_address_latitude <=to_number(P_f_Resident_Latitude)+0.02*to_number(P_n_Radius) and sl.physical_address_latitude>= to_number(P_f_Resident_Latitude)-0.02*to_number(P_n_Radius)
              and sl.physical_address_Longitude >=to_number(P_f_Resident_Longitude)-0.02*to_number(P_n_Radius) and  sl.physical_address_Longitude<=to_number(P_f_Resident_Longitude)+0.02*to_number(P_n_Radius)
              and sor_google_map_service.Calculate_Distance(P_f_Resident_Latitude, P_f_Resident_Longitude, sl.physical_address_latitude, sl.physical_address_Longitude)<=P_n_Radius;
            return rcur_Offender_address;
          end if;
      end;and my anonymous block is:
    declare
      query_result json_list;
      --list_string varchar2(32000);
      list_string clob;
      l_cursor sor_google_map_service.rcur_Offender;
      b_found boolean;
    begin
        l_cursor:=sor_google_map_service.find_near_offenders(35.5113030,-97.5543081, 3, 'Public', b_found);
        query_result:=json_util_pkg.ref_cursor_to_json(l_cursor);
        list_string:='{"Offenders": '||json_printer.pretty_print_list(query_result)||'}';
        dbms_output.put_line(list_string);
    end;

    lxiscas wrote:
    I checked the PL_JSON, and I found it uses sys_refcursor, which is limited to 32K around. That doesn't make sense. A SYS_REFCURSOR has no 32k limit-- the limits are related to the data types that the SQL statement that the SYS_REFCURSOR points to uses. If that SQL statement has a CLOB column, there is effectively no limit. If that SQL statement has a VARCHAR2 column, you've got the 4000 byte limit.
    and I was using varchar2 variable in anonymous block. However, my cursor result is too big to hold in a 32K space. Again, this doesn't seem to make sense. There is no such thing as a result that is too big for a cursor
    Do you think I need to change PL_JSON API myself to ensure it uses CLOB? or there is anyway that I can avoid update PL_JSON package internally?If the PL_JSON package is trying to write more than 32k of data into a VARCHAR2, your options are
    - Modify the package to use a CLOB
    - Find some other package that implements whatever functionality you need
    - Limit the data to 32k
    Justin

Maybe you are looking for

  • Removing "smart" quotes

    I have an html file that appears to have been created by Word and contains so called "smart" quotes.  How can I convert this file so that it has normal quotes?  I tried Googling and found a couple of vi based solutions but, not being a vi user, I did

  • Install Windows 7 64-bit on SATELLITE A665-S5199X

    I'm helping a friend with his laptop and his drive is completely toast (unrecoverable errors across the surface somehow).  It's out of warranty, so I'm using a flash drive of Windows 7 Home Premium along with his key from the Windows sticker on the b

  • Bex display

    Hi All, Can some one plz tell me a typical scenario when we require to have 2 structures in the column section in a query. Thnaks , Tina

  • How to get notified the AO profile has been finished

    I am generationg an output analog profile usling the NI PCI-6014 DAQ (Windows2000/XP environment and VC++ 6 are used). My goal is to generate it once, but I do not want to make a synchronous call having a real-time application. So what I am doing is

  • Hardware options for Time Machine?

    Background I'd guess that if Leopard topped 2 million sales in the first weekend that probably means there are about 1.9x million of us (self included) looking for a neat drive arrangement in order to keep Time Machine running sweet. I'd further gues