Pagination Limit the number of result from query. If exceed throw error

Hi expert,
I have a question that need your guidance.
Declare
    type myarray is table of emp.empid%type;
    mytab myarray;
    vcounter number;
    vlimit number;
Begin
    select limitnumber into vlimit from ABC where table_name = 'XYZ';
    select count(*) into vcounter from emp where empid = 1 /*let say this return 5500 records and take 10 seconds*/
    if vcounter > 5000 then
       raise_application_error(-20010,'you will process more than allowed number of record');
    else
        select empid bulk collect into mytab where empid = 1; /*let say this will take another 10 seconds for 5000 records*/
    end if
End;
/as you see there, if I want to insert 5000 records it will take me 10 sec to count first and then another 10 sec to insert.
I am trying to avoid the count to save time, but how to limit if the array insertion to 5000 otherwise throw the error.
please note that we limit the limitnumber in table ABC and that can be changed.
thanks
Henk
Edited by: user9180414 on Oct 19, 2011 12:57 PM

If you want to select just first 5000 rows use LIMIT:
select empid bulk collect into mytab limit 5000 where empid = 1;If you also want to make sure there is no more than 5000 rows use:
select empid bulk collect into mytab limit 5001 where empid = 1;
if mytab(5001). exists then
raise_application_error(-20010,'you will process more than allowed number of record');
end if;SY.

Similar Messages

  • Limit the number of results from a querying a table

    I have a table, NAMES, that holds appx 50 names.
    I want to be able to list a certain amount of names and once that limit is reached( 6 or 7 or so), output a row / link / statement that says, you've reached your limit.
    For example the output would look similar to :
    Jim
    John
    James
    Mike
    Henry
    Mark
    'Limit Reached'
    'Limit Reached' would eventually need to be a link, but I am already familiar with creating links from query results, persay.
    I've experimented with listagg, case statements and decode but am not sure how to do this. I'm thinking decode is the way to go but am not sure how to keep track of a counter as the sql is running. This needs to be written in sql only, not pl/sql, if possible. My query so far is
    Select first, last
    From Names
    where rownum <= 6
    Not sure how to accomplish this. Any help would be greatly appreciated. Thanks in advance

    Hi,
    NewApexCoder wrote:
    @FrankKulasg
    I have tested these using union. However, I also have columns I need to include that aren't text fields (such as an ID column, which is a number / integer type). I can't use NULL. Is there anything to substitue for this?
    Other people can use NULL.  Why can't you?
    If you could use NULL. then you could do something like this:
    SELECT  ename
    ,       job
    ,       sal     -- a NUMBER column
    FROM    scott.emp
    WHERE   ROWNUM  <= 6
        UNION ALL
    SELECT  'Limit reached'
    ,       NULL    -- in place of a VARCHAR2
    ,       NULL    -- in place of a NUMBER
    FROM    dual
    Output:
    ENAME         JOB              SAL
    SMITH         CLERK            800
    ALLEN         SALESMAN        1600
    WARD          SALESMAN        1250
    JONES         MANAGER         2975
    MARTIN        SALESMAN        1250
    BLAKE         MANAGER         2850
    Limit reached
    7 rows selected.

  • Nepomuksearch - How to limit the number or results

    Hello,
    I use nepomuksearch for several versions of kde now.
    Until now, we could limit the number of results in systemsettings.
    Since switching to kde 4.10, it is no longer possible: this parameter does not exist in the systemsettings. We can not further limit the number of results.
    Is there a way to limit the number of results in nepomuksearch, and if so, how?
    Thank you very much for your help.

    Hi,
    If not set explicitly, the default value for WILDCARD_MAXTERMS is 5000. This is set as a wordlist preference. This means that if your wildcard query matches more than 5000 terms the message is returned. Exceeding that would give the user a lot to sift through.
    My suggestion: trap the error and return a meaningful message to the user indicating that the search needs to be refined. Although it is possible to increase the number of terms before hitting maxterms (increase wildcard_maxterms preference value for your wordlist), 5000 records is generally too much for a user to deal with anyway. The search is not a good one since it is not restricting rows adequately. If it happens frequently, get the query log and see the terms that are being searched that generate this message. It may be necessary to add one or more words to a stoplist if they are too generic.
    Example: The word mortgage might be a great search term for a local business directory. It might be a terrible search term for a national directory of mortgage lenders though (since 99% of them have the term in their name). In the case of the national directory, that term would be a candidate for inclusion in the stoplist.
    Also remember that full terms do not need a wildcard. Search for "car %" is not necessary and will give you the error you mentioned. A search for "car" will yield the results you need even if it is only part of a bigger sentence because everything is based on the token. You may already know all of this, but without an example query I figured I'd mention it to be sure.
    As for limiting the results - the best way to do that is to allow the user to limit the results through their query. This will ensure accurate and more meaningful results for them.
    -Ron

  • HT2729 I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    you can do this by keeping the external hard drive connected and doing the following
    -hold shift key down on computer while opening iTunes and a prompt will appear to choose a library
    -select choose library, iTunes should bring up your explorer windows where you can search for the external HD
    -after you find the external HD find the iTunes folder you just copied to it
    -after opening the iTunes folder look for the file that says iTunes library.itl or if you can't see that extenstion just look for a document looking thing in the iTunes folder that shows up as a database file
    -double click the database file and boom iTunes should load your library without having to copy it to the computer
    PS: do make sure that if you are going to do it this way, make sure that the external HD is connected at all times, because if you don't then you will get exclamation marks next to your iTunes songs
    double PS: if you are unsure how to find out if the iTunes library file is a database file just right click it and choose properties and under the type it should say database file
    hope this helps:)

  • How to limit the number of items from RSS using XSLT

    Hello,
    I am using plsql to read contents from RSS, basically a simple RSS reader.
    I would like to somehow want the feature to restrict the number of items in the RSS feed, say I would like to display only the first 5 items.
    How could I achieve this?
    Any help is highly appreciable.
    Thanks in advance.
    Regards

    Hi,
    According your post, I know you would like to set the item display limit in Status List web part.
    In the web part, the number of items to display is based on the view which you selected when configuring the web part. The default view for status list is status list view.
    However, I am not able to limit the items’ display number of the status list view. After changing the items limit, the list item displayed would not match the number specified by Item Limit. Thus, it is not possible to limit the number
    of items in the Status list web part.
    It could be a potential issue in SharePoint 2010.
    We will log this issue to our suggestion box. As after the submission, we may not have any time guarantee when the fix may be released, but it may come out on next cumulative update.
    Appreciate your time and efforts.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Is there is limit to the number of results from Address Book

    I am syncing with Exchange 2007, and when I use Address Book to search the Exchange GAL, I only ever get a 100 results. I have checked the same search on Windows and get more than 100 results. It would appear that Address Book has some sort of limit to LDAP searches in Address Book.
    Has anyone else seen this?

    You can create Matlab scripts with more than 4 outputs. Maybe if you could provide your script and the error message we can provide more insight into your difficulty.
    Marc

  • If my code displays a recordset, how can I limit the number of results to display?

    I have the code below:
    <div id="content">
        <table width="998" border="0" cellspacing="4" id="stuff">
            <?php do { ?>
              <tr>
                <td><?php echo $row_Recordset1['name']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
          <div id="spryTable" spry:region="ds1">
            <table align="center">
              <tr>
                <th spry:sort="name"> </th>
              </tr>
              <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected">
               <td height="40" align="center">{name}</td>
               <td height="40" align="center">{name}</td>
              </tr>
              </table>
          </div>
    At the moment the green line prints the names in one column of a table, and the orange line prints the same list again.
    The problem is, I want half the names to be printed in one column and the other half of names to be displayed in the other column.
    Can someone show me how to set the php code to do this? I've been trying various things for a while now without success.
    Thank you.

    I am assuming that you have created a SpryHTMLDataSet from the table produced from the PHP-code.
    To display the result in two columns, use CSS as follows
    <!DOCTYPE HTML>
    <html xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script src="SpryAssets/xpath.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    var ds1 = new Spry.Data.XMLDataSet("employees.xml", "employees/employee");
    </script>
    <style>
    .RowContainer {
        width: 400px;
    .RowColumn {
        width: 50%;
        float: left;
    </style>
    </head>
    <body>
    <div spry:region="ds1">
      <div spry:repeat="ds1" class="RowContainer">
        <div class="RowColumn">{firstname} {lastname}</div>
      </div>
    </div>
    </body>
    </html>
    In the example above I have use a SpryXMLDataSet but the principle remains the same. The used XML file is as follows
    <?xml version="1.0" encoding="iso-8859-1"?>
    <employees>
        <employee id="123456">
            <lastname>Smith</lastname>
            <firstname>Edward</firstname>
            <joinDate>2009-10-01</joinDate>
        </employee>
        <employee id="127937">
            <lastname>Johnson</lastname>
            <firstname>Neil</firstname>
            <joinDate>2011-03-06</joinDate>
        </employee>
        <employee id="126474">
            <lastname>Williams</lastname>
            <firstname>Steve</firstname>
            <joinDate>2011-03-20</joinDate>
        </employee>
        <employee id="120585">
            <lastname>Jones</lastname>
            <firstname>John</firstname>
            <joinDate>2010-12-13</joinDate>
        </employee>
        <employee id="127493">
            <lastname>Brown</lastname>
            <firstname>Joe</firstname>
            <joinDate>2011-01-01</joinDate>
        </employee>
    </employees>
    Gramps

  • Limit the number of records in result list cartridge

    Hi experts
    I want to use result list cartridge for displaying some products but also want to limit the returned results to some max records.
    Is there any way i can limit the number of results in result list cartridge?
    Thanks

    Results list has a 'recordsPerPage' property that will limit the number of records on the page.
    Are you looking to limit it at some other place?
    HTH,
    Pankaj.

  • How do you limit the number of rows return from query?

    How do you limit the number of rows return from query? Do all databases support this kind of feature?

    i think the standard is limit
    to get the top 30
    select * from mytable LIMIT 30;returns the first 30 rows
    also if you want a range
    select * from mytable LIMIT 10,30;returns 30 rows starting from 10
    this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages

  • ABAP Query - Want to limit the number of records to 5

    I have a query based on a a table join (MKPF with MSEG) infoset. I want to limit the number of records to first five.
    How to deal with it?

    select data from tables using join and where conditions....into internal table....
    now move the first 5 records to second internal table and use them...
    or else in ur select statement u can use...
    select  data from tables <join condition> upto 5 rows.
    Message was edited by:
            Ramesh Babu Chirumamilla

  • Limit the number of record to download to excel from a report

    I am just wondering if there is a way to limit the number of rows that I want to download to excel from a report in apex, right now when I click download to excel it downloads all records. If I am displaying 15 records on report page I want the ability to download only those records.
    Any help with that would be appreciated.
    Kind Regards,
    Sofia.

    Sofia,
    The same report query runs for downloading the data into excel, I don't think you can limit the number of records in download.
    You can achieve it using custom code, like on click of download excel redirect to another page and then restrict the data as per your need, or you can use the custom procedure to download the limited data.
    Denes' utility to download into excel.
    http://htmldb.oracle.com/pls/otn/f?p=31517:108:1476564836494581:::RP,::
    Regards,
    Manish

  • How to limit the number of search results returned by oracle text

    Hello All,
    I am running an oracle text search which returned the following error to my java program.
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    #### ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    java.sql.SQLException: ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    When i looked up the net, one suggestion that was given is to narrow the wildcard query, which i cannot in my search page. Hence I am left with the only alternative of limiting the number of results returned by oracle text search query.
    Please let me know how to limit the number of search results returned by oracle text so that this error can be avoided.
    Thanks in advance
    krk

    Hi,
    If not set explicitly, the default value for WILDCARD_MAXTERMS is 5000. This is set as a wordlist preference. This means that if your wildcard query matches more than 5000 terms the message is returned. Exceeding that would give the user a lot to sift through.
    My suggestion: trap the error and return a meaningful message to the user indicating that the search needs to be refined. Although it is possible to increase the number of terms before hitting maxterms (increase wildcard_maxterms preference value for your wordlist), 5000 records is generally too much for a user to deal with anyway. The search is not a good one since it is not restricting rows adequately. If it happens frequently, get the query log and see the terms that are being searched that generate this message. It may be necessary to add one or more words to a stoplist if they are too generic.
    Example: The word mortgage might be a great search term for a local business directory. It might be a terrible search term for a national directory of mortgage lenders though (since 99% of them have the term in their name). In the case of the national directory, that term would be a candidate for inclusion in the stoplist.
    Also remember that full terms do not need a wildcard. Search for "car %" is not necessary and will give you the error you mentioned. A search for "car" will yield the results you need even if it is only part of a bigger sentence because everything is based on the token. You may already know all of this, but without an example query I figured I'd mention it to be sure.
    As for limiting the results - the best way to do that is to allow the user to limit the results through their query. This will ensure accurate and more meaningful results for them.
    -Ron

  • Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    You can't. Why on earth would you attempt to manage 2500 emails with setting up a folder structure or some means of doing so? Simply keeping them in an single inbox is not realistic, no matter what email client you use.

  • When I air print from my iPad, I can't limit the number of pages. It just says print and the number of copies and I end up with way more than I want. How do I set it to limit the pages?

    When I air print using FingerPrint from my ipad, it doesn't let me limit the number of pages, and I end up with more pages than I want. It asks if I want multiple copies, but it doesn't ask me number of pages, or which pages. Is there a way to do this?

    When you use an AirPrint compatible printer, you get this option for page range. You are using your computer as the server in order to print, so you probably have to set the range on the computer. While you can print from your printer with this app, I assume that it doesn't give you the same control that you get directly from the iPad when using an AirPrint printer.
    Read this from the FingerPrint support site. Selecting the page range would be part of the formatting of a print job.
    http://fingerprint-support.collobos.com/knowledgebase/articles/66972-i-can-t-for mat-the-print-job

  • Is there any way to limit the number of RFC calls from xMII to SAP R/3

    Hi All!
    I wanted to know whether the number of simultaneous RFC connections made from xMII to SAP R/3 system can be controlled in any way. Suppose we have a scenario wherein some million Sales Orders or Production Orders are to be updated in SAP R/3 from xMII in a short span of time. For all these updations to take place, multiple RFC calls will be established from xMII to SAP at the same time. This will increase the load on the SAP R/3 system and affect performance of the SAP R/3 system. Is there any check on xMII side to limit the number of RFC calls that can be made to SAP R/3 system?
    Regards
    Anupam

    Anupam,
    If you are using 11.5 just keep in mind that the JCO connection points to a single application server (based upon the SAP Server alias connection settings), but the traffic itself to make a BAPI request is effectively the same as any client user traffic.  There will obviously be limitations on performance and throughput, with network and server constraints added to the number and size of the R/3 requests, but there is no magic formula to plug-in because of all of these variables.
    If you are using 12.0 (or plan to migrate when it goes GA) then taking advantage of the JRA (java resource adapter) and the associated application server pooling that it offers on the NetWeaver side of things will greatly help you in the throughput capacity.
    If you have put some of your xMII application into either test or productive use and are running into issues then I would highly recommend entering the specifics into the customer / partner support portal so that they can help you through any associated problems.
    Regards,
    Jeremy Good

Maybe you are looking for

  • Need advice. Is it necessary to put images in folders and subfolders with LR?

    It seems that the concept of spending hours putting files into folders, sub-folders and sub-sub-folders is not needed  with LR. Creating all these folders takes hours, especially if you are like me and need a major reorganization of image organizatio

  • Open apps do not show as open in dock...

    ... command tab only shows Finder. I can navigate to the other 9 apps that are open with the mouse. Strange. I have repaired permissions, activity monitor shows nothing out of the ordinary.

  • Gathering Entire Database Structure

    Hi Geeks, I want to gather the entire database structure for our client database, which is outside of our country and it is impossible to send the export dump file since so many formalities are there. I need to gather the information, but not through

  • Flash movie will not show or work on server???

    Seems to be a popular thread here,,,,, I have 3 web sites on my hosting server 1 has a small flash movie which works fine i tried adding another to the 2 other sites and nothing !!!! Exactly the same thing as the one that works, the movie will not ev

  • Code works differently in linux

    i am using RedHatLinux 9.0.I am opening a file outside a Thread and reading it inside a infinite for loop which is present inside a thread.The problem is The file pointer doesnt get revised even when the file has been mmodified from outside(i.e manua