Collect in bulk in stores less number of lines in the collection when you use the LIMIT?

I wrote the following PL SQL anonymous block. However, the line dbms_output.put_line (total_tckt_col. FINALLY gives me) output as 366 (DBMS_OUTPUT is Developer SQL) which is correct when there is no limit. If the limit is set at 100 in the FETCH statement then dbms_output.put_line (total_tckt_col. Give me FINALLY) 66. What I'm doing wrong here?


DECLARE

  
CURSOR cur_total_tckt 
  
is
  
select  t.ticket_id ticket_id, t.created_date created_date, t.created_by created_by, t.ticket_status ticket_status,
  t
.last_changed last_changed, h.created_date closed_date
  
from n01.cc_ticket_info t
  
inner join n01.cc_ticket_status_history h
  
on (t.ticket_id = h.ticket_id)
  
where t.last_changed >= '6/28/2012 17:28:59' and t.last_changed < (sysdate + interval '1' day);

  type total_tckt_colcn
  
is
  
TABLE OF cur_total_tckt%rowtype;
  total_tckt_col total_tckt_colcn
;
  total_coach_col total_tckt_colcn
;
  
begin

  total_tckt_col 
:= total_tckt_colcn ();
  total_coach_col
:= total_tckt_colcn ();
  
OPEN cur_total_tckt;
  loop
  
fetch cur_total_tckt bulk collect into total_tckt_col;
-- fetch cur_total_tckt bulk collect into total_tckt_col limit 100;
  
EXIT
  
WHEN (cur_total_tckt%NOTFOUND);
  
END LOOP ;
  
CLOSE cur_total_tckt;  

  dbms_output
.put_line(total_tckt_col.LAST); 

  
FOR i IN total_tckt_col.first..total_tckt_col.last
  LOOP

  dbms_output
.put_line(i);

  
END LOOP;
  
end;

Jocelyn says:

This is a modified version of your code on the standard table EMP in schema scott.

Have you tested it? All you have is last batch has 4 rows. But you print outsite the loop. That way if the last batch is incomplete (within boundary lines) last batch does not have your loop. Suppose you want to print the enames:

DECLARE

CURSOR cur_total_tckt

IS

Select ename

EMP; -I have a total of 14 records in this table

type total_tckt_colcn

is

TABLE OF THE cur_total_tckt % rowtype;

total_tckt_col total_tckt_colcn;

BEGIN

total_tckt_col: = total_tckt_colcn ();

OPEN cur_total_tckt.

LOOP

Cur_total_tckt fetch bulk collect within the limits of the total_tckt_col 5;

EXIT WHEN cur_total_tckt % NOTFOUND;

FOR v_i IN 1.total_tckt_col.count LOOP

dbms_output.put_line (total_tckt_col (v_i) .ename);

END LOOP;

END LOOP;

CLOSE Cur_total_tckt;

END;

/

SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER

PL/SQL procedure successfully completed.

SQL >

As you can see, it didn't print the last batch. Why? Because NOTFOUND is set to true if the number of lines that you asked to fetch was not recovered. This last batch has 4 rows while the claim code to get 5. Therefore, NOTFOUND has the value true and outputs code before dealing with this last batch. Therefore, repeat the treatment code again once outside the loop:

DECLARE

CURSOR cur_total_tckt

IS

Select ename

EMP; -I have a total of 14 records in this table

type total_tckt_colcn

is

TABLE OF THE cur_total_tckt % rowtype;

total_tckt_col total_tckt_colcn;

BEGIN

total_tckt_col: = total_tckt_colcn ();

OPEN cur_total_tckt.

LOOP

Cur_total_tckt fetch bulk collect within the limits of the total_tckt_col 5;

EXIT WHEN cur_total_tckt % NOTFOUND;

FOR v_i IN 1.total_tckt_col.count LOOP

dbms_output.put_line (total_tckt_col (v_i) .ename);

END LOOP;

END LOOP;

FOR v_i IN 1.total_tckt_col.count LOOP

dbms_output.put_line (total_tckt_col (v_i) .ename);

END LOOP;

CLOSE Cur_total_tckt;

END;

/

SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER

PL/SQL procedure successfully completed.

SQL >

But you have to accept to repeat that twice the processing code is no better solution. When you use BULK COLLECT LIMIT we should not leave NOTFOUND but rather by collection.count = 0:

DECLARE

CURSOR cur_total_tckt

IS

Select ename

EMP; -I have a total of 14 records in this table

type total_tckt_colcn

is

TABLE OF THE cur_total_tckt % rowtype;

total_tckt_col total_tckt_colcn;

BEGIN

total_tckt_col: = total_tckt_colcn ();

OPEN cur_total_tckt.

LOOP

Cur_total_tckt fetch bulk collect within the limits of total_tckt_col 6;

WHEN OUTPUT total_tckt_col.count = 0;

FOR v_i IN 1.total_tckt_col.count LOOP

dbms_output.put_line (total_tckt_col (v_i) .ename);

END LOOP;

END LOOP;

CLOSE Cur_total_tckt;

END;

/

SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER

PL/SQL procedure successfully completed.

SQL >

SY.

Tags: Database

Similar Questions

  • Brand new laptop less than a week old keeps freezing when you use 3 dongle mobile huawei E122 briadband dongle. Although even I have the latest version of the software

    as above but 3 it's a compatibility issue with windows 7 this isn't up to 3 I'm goin' round in circles here lol can help please

    For any question on Windows 7:

    http://social.answers.Microsoft.com/forums/en-us/category/Windows7

    Link above is Windows 7 Forum for questions on Windows 7.

    Windows 7 questions should be directed to the it.

    You are in the Vista Forums.

    See you soon.

    Mick Murphy - Microsoft partner

  • get the error when you use the TRIM method in the collections

    Hi Experts,

    When you use the TRIM method I get below error. I make any mistake here?

    DB: Oracle 11g

    SQL > declare

    2

    emp_tab of type 3 is the employee table % rowtype index directory.

    4 l_emp_tab emp_tab;
    5

    6 start

    7

    8 select * bulk collect into l_emp_tab of employees;

    9 l_emp_tab.trim (5);

    10 dbms_output.put_line (l_emp_tab.count);

    11

    12 end;

    13.

    l_emp_tab. Trim (5);

    *

    ERROR on line 9:

    ORA-06550: line 9, column 2:

    PLS-00306: wrong number or types of arguments in the call to 'TRIM '.

    ORA-06550: line 9, column 2:

    PL/SQL: Statement ignored

    Thanks in advance for your help.

    See you soon,.

    Suri

    For PL/SQL collections "index by" you cannot use the TRIM function. If your collection statement excludes the portion "index of...» ", then you can.

    Gerard

  • When you use find on the page (ctrl + F on Windows) it is a message indicating the total number of matches. What does the first number?

    When you use find on the page (ctrl + F on Windows) it is a message indicating the total number of matches. What does the first number?
    I'm more interested in the case when this number is smaller than the total.

    Hello

    I think you mean the text stating "x of there matches", to the right of the box where you entered the search term.

    The first number ("x" in my example above) indicates the current entry highlighted on the page that matches the search phrase. If you use the upper and down arrows to navigate through the instances of this term on the page, you will see this number go up and down.

    I hope this helps, but if not please come back here and we can look at another solution for you.

  • Problem with the number of lines in the channel

    Dear community LabView,

    I'm relatively new to labview and I came across a problem that (I assume) can easily be resolved with your help.

    I need to create a digital signal to trigger a camera, but I have a problem with the configuration of my lines or exit lanes. I would not use that line output to trigger the camera. (I use a card NI PCIe-6353). LabVIEW is telling me that the number of lines in the channel does not have the number of rows of data:

    Possible reasons:

    Specified read or write operation failed because the number of rows in the data of a string is not the lines in the channel.

    If you use the digital waveform data type, make sure that the number of lines in the digital waveforms is the number of lines in the channel. If you are using Boolean data, make sure that the dimension of the array for the rows of the data is the number of lines in the channel.

    Number of lines in the channel: 1
    Number of data lines: 2

    Task name: _unnamedTask<11>

    How and why the number of data rows is connected to the resolution of my analog digital converter?

    I would appreciate your help! Labview code and a screenshot attached.

    Thank you

    Beff

    I got it to work by changing the "data format" "binary not signed" OR by plugging is not the "offset" for the Square Wave VI.  I think that the default "offset binary" data format works correctly if there is a negative value.

  • When you use Excel or my Peachtree Accounting program, entered digital as "$152(32 in the accounting package or the same number with a square symbol as the decimal point in Excel.)". No idea what I should check first?

    When you use Excel or my Peachtree Accounting program, entered digital as "$152(32 in the accounting package or the same number with a square symbol as the decimal point in Excel.)".  No idea what I should check first?

    Thank you for visiting the website of Microsoft Windows Vista Community. The question you have posted is related to Office Excel and would be better suited to the office community. Please visit the link below to find a community that will support what ask you

    http://www.Microsoft.com/Office/Community/en-us/default.mspx?d=1

    Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Used QUICK to collect files from the XP machine. Now cannot locate the data when you use Easy Transfer on Win 7 machine to restore settings

    I had XP SP3 on my computer and used the files and Settings Transfer Wizard to collect the data.  Recorded on another partition, formatted and installed Win 7 Pro.  Now, when you use Easy Transfer to restore data it tells me that it cannot find all the data.

    Any ideas?  Thank you!

    For any question on Windows 7:

    http://social.answers.Microsoft.com/forums/en-us/category/Windows7

    Link above is Windows 7 Forum for questions on Windows 7.

    Windows 7 questions should be directed to the it.

    You are in the Vista Forums.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    XP forums:

    http://social.answers.Microsoft.com/forums/en-us/category/WindowsXP

    Link above is for XP Forums.

    There is a list of the different Forums XP to the link above to help you.

    You get the help you need there.

    See you soon

    Mick Murphy - Microsoft partner

  • number of lines in the ListView blackberry stunts QML

    Hi all

    I have a ListView in QML page that contains several elements.

    I also want to display the total number of lines on the bottom of the page.

    Please tell me how.

    View the list code is as below: -.

     //! [1]
                    // The list view with all messages
                    ListView {
                        dataModel: _messages.model
    
                        listItemComponents: ListItemComponent {
                            type: "item"
    
                            StandardListItem {
                                title: ListItemData.senderName
                                description: ListItemData.sender
                                status: ListItemData.time
                            }
                        }
    
                        onTriggered: {
                            clearSelection()
                            select(indexPath)
    
                            _messages.setCurrentMessage(indexPath)
    
                            _messages.viewMessage();
                            navigationPane.push(messageViewer.createObject())
                        }
                    }
                    //! [1]
    

    Please suggest

    call on the datamodel size()

  • When you use the brush in the development module and I have a lot less brushes to create an image, the program hangs up to what I sometimes have to use windows to complete the task.  I have ICC Intel i7 3.4 and 16 GB of RAM to operate Windows 7.  Why hang

    When you use the brush in the development module and I have a lot less brushes to create an image, the program hangs up to what I sometimes have to use windows to complete the task.  I have ICC Intel i7 3.4 and 16 GB of RAM to operate Windows 7.  Why hang up LR

    Doing a lot of brushing up on an image using Lightroom is known to have this problem. The first thing to try is to turn off the graphics acceleration (go to Preferences/Performance tab and then uncheck the box here). IF this does not help, then you can consider doing your brush in Photoshop Elements or Photoshop, instead of brushing in Lightroom.

  • How to count the number or lines in the file

    Hi Experts,

    I'm file as source and Oracle as target. My folder that contains some data that will load the target.
    My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.


    THX,
    Sara.

    Hi Sahaveda,

    Now, I tried and it works.

    Sorry my mistake again.

    I created HR. ETL_FILE_LOG as below:

    CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))

    Below the code will run without error:

    import java.lang as lang

    import java.sql SQL

    import of java.lang.String

    Import os

    disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")

    dblinks = cons.createStatement)

    File1 = Open ('c:\EMP.txt','r')

    Count = 0

    Line = file1. ReadLine()

    all online! ='' :

    Count += 1

    Line = file1. ReadLine()

    File1. Close()

    sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.

    rqQuery = dblinks.execute (sqlQuery)

    jerks. Close()

    Concerning

  • Photo not added to the quick Collection when you click marker

    Recently I have not been able to add photos to a quick collection, when you click on the marker. The marker provides information, but the photo does not appear in the quick collection. This problem occurred at the same time, I couldn't remove the photos in the quick collection that had been added. I had to remove these photos using the menu system. I've upgraded to the new version of Lightroom 5 yesterday thinking that would solve the problem. I still have the problem so I wonder if this is a setting that I missed. Quick collection markers button is enabled in the display options and the button and change when you click them... The thumbnail of the photo is not added to the quick collection.

    It seems that you no longer have the quick Collection, referred to as a collection of target. Is there a small symbol '+' next to the name of the collection? If this isn't the case, you have another collection in your designated collection list.

    To fix, right-click the name of the quick Collection and click the option "set as target Collection.

  • Problems with sorting of columns and the number of lines in the report

    Hello

    I'm having a problem with sorting of columns and the number of lines displayed in a report.

    This report displays the data correct, but if I try to sort on a column when I click on the column heading in the report returns no line... I need to click on the "go" button to refresh the report (with the column sorted now) in to display the data.

    Similarly, I display only 15 lines per page. If I try to view the lines 16-30, 31-45, etc., that it returns no line until I click on the 'go' button to refresh again.

    Has anyone else had (and overcome) the same problem?

    Thank you

    Joseph

    Joseph,

    2 questions:

    1) are you using the elements referenced by the report page to filter etc.. ? If so, you're failing values of these when the loading of the page?
    (2) are you using PPR page through the results?

    If so, it could be a problem with the different types of session state, as Anton Nielsen blogged about here:
    http://c2anton.blogspot.com/2008/12/Oracle-Application-Express-Apex-three.html

    If so, you can use calculations or processes to set element values in session state persistent during page rendering, as Anton mentions. In this way, when you use PPR page values will be available in session state and your report should work fine.

    Anthony.

  • The limit of the device must be less than or equal to the limit of life cycle license in first cisco 2.2

    Hi all

    I have seen under error in the tool main 2.2 Cisco infrastructure

    The limit of the device must be less or equal to the limit of license of life cycle and also secondary device ISE inaccessible since premium.

    Could you please suggest how we can solve your problem.

    Thanks in advance...

    Kind regards

    Sachin

    Yes. Life cycle license are by smart device managed. See this page for a good overview:

    http://www.Cisco.com/c/en/us/support/docs/cloud-systems-management/Prime...

    .. as well as this page:

    http://www.Cisco.com/c/en/us/products/collateral/cloud-systems-Managemen...

    .. who States:

    Life cycle license: allows access to all the features of the life cycle, which includes the configuration of the devices, image management software, basic health and performance monitoring, fault management, troubleshooting and customer visibility on the network. The license of the life cycle is based on the number of managed devices. Life cycle of the licenses are available in sizes from package of 25, 50, 100, 500, 1000, 2500, 5000, 10,000 and 15 000 devices and can be combined as needed to reach a total number of device under license.

    A device is uniquely identified through the assigned IP address and system object ID (SysOid). Routers, switches, light/unified access points and network first Cisco (NAMs) analysis Modules are charged on the number of licenses. If a switch stack is managed via a single IP address, it counts as a single device. A single frame will, however, be counted as multiple devices if the chassis is configured with several IP addresses. For example, a switch with several service cards, such as a firewall and so forth, or a stackable switch with an IP address assigned to each switch who is involved in the stack is considered multiple devices within the first Cisco Infrastructure. Cisco Wireless LAN controllers (WLCs), autonomous and peripheral access points third are not counted against the number of licenses.

    When you have more devices that licenses, you will receive the error see you and prevented from adding additional devices to your inventory.

    We see it more often when it is light (i.e. not independent) APs are added to a wireless controller. PI will not prevent the new APs to be added, they are managed under their association with the WLC. However, if you try to add a new switch it would prevent you to do until the deficit of licenses has been sent.

  • Stor.e TV + loader error keeps coming up when you turn it on

    I experienced ongoing problems accessing the hard drive. Error message "No Loader" keeps coming up when you turn it on.

    The so-called 'solution' to this problem on this forum is to open the box and play with the cables. While I had some success with this method initially, disassembly of the box 10 times a week is not on.

    In desperation, I tried something else.
    When the message no. Loader is in place, I pass in the box and the new on the remote control.
    After 2 or 3 times, and then the folder of the HARD disk appears generally.

    I did that constantly now with great success. However, this suggests that the error no. Loader is NOT a mechanical connector with the hard drive problem, but (as usual) poor software (what else?).

    Dismantling of the unit is shut down for an extended period of time so may explain why this technique works.

    Put the unit on and off the power several times also solves the problem of file D are not on the network even if Win7 shows shop-TV-Plus as a mapped drive on NTFS (but can not find the file D).

    See the resemblance?

    Another thing that exacerbates the problems is poor ventilation of the device. The first thing that happens with this device, it's rubber feet sticky garbage fall.

    While this may seem trivial, the ventilation slots are under the device and will be blocked if he has no feet. I live in a hot country so this appliance gets very hot and behaves even more erratic, unless it is well ventilated.

    Ideally keep well away from other units and preferably sitting it on a small box in itself with the vents in many exposed.

    I always also have problems to read files FLAC, MKV. The unit sometimes lost synch with files FLAC which generally play OK and crashes or causes a large noise or white noise on the speakers (dangerous).

    Some just MKV files play quite although VLC reads. There are many other inconsistencies, but these are more boring.

    Everyone knows these problems or someone at - it other solutions for these problems?

    I don't think we can expect another software upgrade from Toshiba? Your dreams, pal.

    I m not Stor.E + owner and can not say much about the issues mentioned, but the first sounds of mentioned problem (error no. Loader") for me much more like a hardware problem as a software related issue.

    Files mkv seems to be supported.
    The mkv must be encoded in H.264 and MPEG-4 format
    This is what I found on a Web page.

    In addition, there seems to be an update of the firmware

    [3.5 inches StorE TV + ROM Image 2.12_UI1.0 | http://www.toshiba.eu/innovation/download_driver_details.jsp?service=EU&selCategory = 4 & selFamily = 271 & selSeries = 254 & selProduct = 6350 salt ShortMod = null & language = 13 & selOS = all & selType = all & ye arupload = & monthupload = & dayupload = & useDate = null & mode = allMachines & search = & action = search & macId = & country = all & selectedLanguage = 13 & type = all & page = 1 & ID = 80742 & DISO =-1 & driverLanguage = 42]

  • Display number of Skype when you use Skype to go

    Is it possible to display your Skype number when you call contacts using their Skype To Go number?

    I can't get it displays the number that I'm actually calling.

    The solution proposed here

    http://community.Skype.com/T5/Skype-to-go/display-Skype-number-when-using-Skype-to-go-to-call-mobile...

    does not work.

    Can anyone help? Tried Skype customer support and had someone who was serving as an ashtray on a motorbike and did not get a response.

    your s

    jsp21c wrote:

    Hi, I can only confirm that you are right.

    At the present time, the phone number that you call Skype to Go on appears as caller ID.

    If you want to display your Skype number as the caller ID, you must call from the program or the app.

    It's really useful, thank you, a response finally!

Maybe you are looking for

  • Help me iOS beta 10 of restoration

    SO I recently downloaded 10 beta iOS 4 and I've regretted since that. I connected my phone to the computer and I tried to restore my back upwards, and he says that he is unable to do so for the same reason that it is invalid to read or something. Sin

  • EliteDesk 800 35W G2: G2 EliteDesk 800 35W network driver problem

    Hello We have a new EliteDesk 800 35W G2 phone in our office. In order to obtain compatible drivers, that I'm wrong. The one you suggest the latest network drivers for "G2 HP EliteDesk 800 35W. Network driver: Intel (r) Ethernet connection (2) I219-L

  • &lt; DOUBLE &gt; someone there - random restarts on bike E?

    Hi people! This is my first post in this forum. I had my bike E in October 2014 as a replacement for my broken Galaxy FIT. I totally love the E bike, it is very smooth, the display is strong, speakers are nice and performance is impressive for this p

  • Windows Media Player won't play certain DVD

    I'm able to play most DVDs.  But this one, a concert will start and then will not give me the main menu, so I'm not able to play.  It crashes just after the initial logo from the record company.     I would have thought it was the DVD, but I got to w

  • Windows Vista Edition Family Premium VOIP

    MarkVision VOIP does not work on Windows Vista Edition Home Premium on Lenovo laptop.