Opening and fetching cursor.. what accually happens?

So, if we have an explicit cursor... we open it with open c_cursor_name... and fetches it into some variable...
my question is - what really happens when we open cursor?
does oracle make only instance of cursor object in memory? or... does it reads some basic data about rows that are going to be fetched (rowid's?)..? or what?
also, if we make some insert into a table that is going to be rolled over by cursor (while cursor is fetching..), should cursor read this new data? for example, what is difference if cursor roll over an indexed ID and we make an insert with an ID=10, and cursor is currently on ID=100? or opposite? (commit included in insert)...
oh, so many questions :)
tnx :)

Not really. The same SQL cursor in the shared pool applies.
The difference is on the client side. Each of the methods you've listed is essentially using a different method on the client side to interact with the cursor on the server.
Some methods are more desirable in some cases than another - there's not a single superior method. Each has pros and cons and addresses a specific set of client coding requirements.
There are some preferred methods though on the client. The three primary ones are:
a) use bind variables (enables one to re-use the same SQL cursor)
b) re-use the same client cursor handle for tight loop operations
c) use bulk binding
The first one is kind of obvious - as bind variables creates a cursor "program" that can be called/executed with different values. Like an INSERT cursor for example. The same SQL cursor can be used to insert a million rows, with each execution using different variable values to insert.
The second one is not that applicable to the PL language in PL/SQL - thanks to the integration between the PL and SQL languages. In other client languages though, you want to re-use not only the same server cursor, but the same client cursor handle. As this saves you a soft parse. So instead of this approach:
// pseudo code
for i in 1..count
  CreateCursor( c, <sql statement> );
  BindValue( c, 1, myVariable[i] );
  ExecCursor( c );
  CloseCursor( c );
end loop;..the following is far more efficient:
// pseudo code
CreateCursor( c, <sql statement> );
for i in 1..count
  BindValue( c, 1, myVariable[i] );
  ExecCursor( c );
end loop;
CloseCursor( c );This approach re-uses the client handle - which means a single db parse was needed. The prior approach required a brand new parse for each loop iteration. (even soft parsing is an overhead that should be avoided where possible)
The last primary factor is bulk processing. This is fairly well documented for the PL language - the important bit to remember that bulk processing is only intended to pass more data with a single call between the PL and SQL engines. Nothing more. The price of which is a bigger PGA memory footprint. Thus there is a balance between how much data (rows/variables) one should pass between the two versus the amount of memory that consumes.

Similar Messages

  • Open and closed cursor

    I have some doubts/questions .
    What is the difference between open and closed cursor?
    Are library cache locks same as parse locks?
    What is the difference between latch and mutex?
    I would be grateful if experts could answer these questions.
    Regards

    Almost correct. The terminology is however nor correct.
    Simplistically:
    The SQL engine receives a SQL. It attempts a soft parse first. This means looking for an existing cursor in the Shared Pool with the same SQL. This existing cursor can be in use by other sessions. It does not matter - if that cursor is in used (opend by other sessions), or not. It may not be in use at all and simply sitting there in the cache. If such a cursor is found, it is used for that session's SQL - and that session gets a cursor handle (reference/pointer) to that existing cursor.
    If the SQL engine does not find an existing cursor to use, it needs to create a brand new cursor in the Shared Pool. This is a hard parse. Again, the session receives a cursor handle for that new cursor created.
    And that is it.
    You now need to decide how to use that cursor handle. The cursor itself is a program. You have a handle to execute that cursor program. Via its bind interface you can input data to this cursor program. Then execute it and receive (fetch) output of that cursor program.
    So the ideal is to re-use the cursor handle again and again.
    Basic example: the following is not optimal as the same cursor is opened and closed, opened and closed, for each read from the file. A lot of soft parsing results.
    while not-eof( filehandle )   // read data from a file
      read file data into var1, var2
      open cursor for 'insert into testtab values( :1, :2)'   // create a cursor
      bind cursor :1 = var, :2 = var2  // bind values to cursor (for insert)
      exec cursor // do SQL insert
      close cursor 
    end whileThis is a lot better. A single cursor is used and executed again and again:
    open cursor for 'insert into testtab values( :1, :2)'   // create a cursor
    while not-eof( filehandle )   // read data from a file
      read file data into var1, var2
      bind cursor :1 = var, :2 = var2  // bind values to cursor (for insert)
      exec cursor // do SQL insert
    end while
    close cursor  In this case a single soft/hard parse - and the client uses that cursor handle to execute that cursor (insert data) program again and again.

  • My phone is in some mode where it will say everything i am trying to open and i have to double tap on it to open and wont scroll. whats wrong?

    my phone is in some mode where it will say everything i am trying to open and i have to double tap on it to open and wont scroll. whats wrong?

    You are in VoiceOver mode, you need to go into your settings>general>accessibility and turn off VoiceOver. 

  • I changed the mac´s disk and now sometimes a rainbow circle appears from time to time and processing stops, what is happening? OS 10.6 mac pro

    I changed the mac´s disk and now sometimes a rainbow circle appears from time to time and processing stops, what is happening???   it is a MAC Pro 8GB RAM Snow leopard 10.6.8

    http://www.thexlab.com/faqs/sbbod.html

  • The game "horn" does'nt open and shows installing but nothing happens. it was transferred from the computer to the ipad. help!, The game horn does'nt open and shows installing but nothing happens. it was transferred from the computer to the ipad. help!

    The game "horn" does'nt open and shows installing but nothing happens. it was transferred from the computer to the ipad. help!, The game horn does'nt open and shows installing but nothing happens. it was transferred from the computer to the ipad. help!

    Try this  - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased. http://support.apple.com/kb/ht1430
    iOS 7: Help with how to fix a crashing app on iPhone, iPad (Mini), and iPod Touch
    http://teachmeios.com/help-with-how-to-fix-a-crashing-app-on-iphone-ipad-mini-an d-ipod-touch/
    Troubleshooting apps purchased from the App Store
    http://support.apple.com/kb/TS1702
    Delete the app and redownload.
    Downloading Past Purchases from the iTunes Store, App Store and iBooks Store
    http://support.apple.com/kb/ht2519
     Cheers, Tom 

  • Hi, on my fathers pc sometimes when downloading multiple tabs start opening and I cannot stop this happening. Could anybody please help me?

    Hi, on my fathers pc sometimes when downloading multiple tabs start opening and I cannot stop this happening. Could anybody please help me? for example, trying to download TomTom Start 25 user manual

    You get that problem if you select the Firefox program to handle a file if you get an "open with" dialog.
    *https://support.mozilla.com/kb/Firefox+keeps+opening+many+tabs+or+windows

  • Both my I-Pad and mini I-Pad keep getting dropped off what ever website they are on and end up on the homescreen.  This happens randomly and often.  What is happening?

    Both my I-Pad and mini I-Pad keep getting dropped off what ever website they are on and end up on the homescreen.  This happens randomly and often.  What is happening?

    Both my I-Pad and mini I-Pad keep getting dropped off what ever website they are on and end up on the homescreen.  This happens randomly and often.  What is happening?

  • SetRollbackOnly and EJBException..what should happen?

    I am wondering what peoples opinions are about what should happen when commiting a transaction in the following scenario.
    I have a transaction started by a stateless session bean method. This method just finds an entity bean and sets one of its attributes. When this stateless session bean method finishes, the transaction is commited by the container. While commiting the transaction, the container calls the ejbStore method of the entity bean. The ejbStore method calls a method on a different stateless session ejb. This stateless session ejb method calls setRollbackOnly and throws an ApplicationException. The entity ejbStore method catches the ApplicationException and throws it nested within an EJBException.
    The ejb2.0 spec says that the container should throw a javax.ejb.TransactionRolledbackLocalException if it can't commit a transaction. This is what I receive, but my question is what would you expect the nested transaction to be?
    I would expect the EJBException that I threw from ejbStore to be the nested exception.
    ie. I would expect this....
    javax.ejb.TransactionRolledbackLocalException: Error committing transaction:; nested exception is: javax.ejb.EJBException: nested exception is: au.com.sparq.test.ApplicationException: ApplicationException a b c...
    But as soon as setRollbackOnly is called, I will only ever receive this exception....
    javax.ejb.TransactionRolledbackLocalException: Error committing transaction:; nested exception is: weblogic.transaction.internal.AppSetRollbackOnlyException
    Why is an AppSetRollbackOnlyException being thrown by the container when I have told the container to rollback the transaction by throwing the EJBException from the ejbStore method of the entity ejb? In this case, the container shouldn't care that setRollbackOnly had been called. It should only be if the ejbStore method doesn't throw an EJBException that the AppSetRollbackOnlyException is thrown.
    The side effect of this behaviour is that I can never get access to the ApplicationException thrown within the ejbStore method, so I can never tell what caused it to fail.

    This is the expected behavior since Windows XP/Windows Server 2003.
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Help!! As I was scrolling through my library, one folder after another had the photos in it turn to "static"!  Lots of streaks and dots!  What is happening and how do I save my photos?

        As I was scrolling through my Aperture library just now, I saw one folder after another turn the photos in that folder into garbage!   They have lines and dots and nothing recognizable - what in the world is causing this?    Can I get my photos back?    It almost looks like a virus eating my files - could it be - and if it is - is my entire computer in trouble?   HELP HELP HELP!

    Interesting that you posted this Cleaning up photo library about one hour before this post. I'd say there is a good possibility they are related.
    Without knowing your system, OS version and Aperture version and what you were doing to 'clean up' your library there is little we can do.
    My photo library is a mess.  I have moved things around a lot in a futile attempt to organize them, now I have a lot of placeholders with no files attached.  How do I clean things up?
    I suggest you restore from your backup and forgo the cleaning operation until you have a better grasp of the situation.
    BTW the Masters folder is organized by date and time of import at least in Aperture 3, if you are using 2 then all bets are off,
    Good luck with Apple support, if you want to try and get this sorted out post back the information I requested above.
    regards

  • My iPad screen Shake allone, the games Open And close. What can i do?

    My iPad Open And close games allone, the keyboard Open allone, sometimes thouchscren not works, the screen shakes allone. Whist can i do?

    Connect to iTunes to update.
    How to update your iOS device
    Scroll down to the “Update your device using iTunes” section

  • HT4623 while updating i ios7 in my ipad i counter a problem that it showed its ready to install and aftr 10 minutes a sign of itunes with usb plug in appears its there till 2 hr what to to do now i have open and close several times nuthing happens

    please find the solution while updating every thing went smoothly untill aftr 20 mins a sign of itunes and usb port appear and its not going what to do ..even i have connected to my computer and switched off the antivirus and firwall as well

    Something went wrong with your update; you are in Recovery Mode.
    Follow step 1 to 6 closely to recover your iPad.
    http://support.apple.com/kb/HT1808
    Note: You need to be patient and repeat the above many times to recover your iPad

  • Hello, my problem is this: in my laptop I cant open my e-mails, or any other folder, I mean, I can usually get into my mail but when I click on an email that does not open, and firefox update, this only happens on my laptop, HELP PLEASE!

    the laptop has windows 7, firefox version I have is 3.6.17.
    Version number 4 I cant download and install the laptop doesnt accept why? I do not know. the problem just happened a few days ago, with version 3.6.17 everything was fine, but one day I could not open my mail, I can access my mail normally, but I can not open my mail when I give it a click, or other type of folder, either spam, deleted, drafts etc. PLEASE HELP ME!
    I always got the version 3.6 and never before had given me problems, newer versions 4.0.1 as the laptop does not accept throws me a message saying "the file is corrupt" is not whether it be because I have to update or unconfigure ayudenme firefox

     But where is manufacturer warranty then ? If the seller want to earn money from repairing warranties phones ? I think all products in the EU by the law has manufacturer 2 years warranty, just manufacturer gives the right to the seller took responsibility of warranty, but seems my seller knows that i have no other options and i have to repair or throw away this phone...so manufacturer should took some responsibility on top of that...and the worst way that blackberry suppor is only by forum or twitter but there is no reply on twitter so how i can contact blackberry for the help ?

  • If I use adobe reader 7.0 to open LiveCycle Designer ES2, what will happen?

    Hi,
    I am planning to recommend adobe LiveCycle Designer ES2 as a forms designer software to a corporate client. But it seems that the client is still using the old version of adobe reader 7.0.
    So I need to know that is it essential to use adobe reader 9.0 for designer ES2, and if by adobe reader 7.0, what problem would be happen?
    It is very helpful If there is some detailed information about it.
    Thanks
    En Shoku

    Hi,
    When you design a form in LC Designer ES2 you can set the target version of Acrobat/Reader in the File > Form Properties > Defaults tab.
    While you can target v7, you need to be aware that some of the functionality in LC Designer ES2 is not supported in Reader v7. For example in LC Designer you can set the presence of an object to 'visible (screen only)', but this is not supported in Reader v7, so would cause a problem. So for each form you would need to set the target version and then check the Warnings palette to see if there are any problems.
    Check out the post by John Brinkman discussing Acrobat X, as this has a very handy table for the LC Designer/XFA Specification and Acrobat/Reader versions: Acrobat X and XFA 3.3
    XFA Version
    Acrobat/Reader
    2.1
    6.02
    2.2
    7.0
    2.3
    7.0.1, 7.02
    2.4
    7.0.5, 7.0.7
    2.5
    8.0
    2.6
    8.1, 8.1.1
    2.8
    9.0
    3.0
    9.1, 9.2, 9.3
    3.3
    10.0
    You can see there are alot of changes around v7 and that if the user has Reader v7.0.7, then you can utilise the features in XFA Specification 2.4.
    The other issue to be aware of is that users with Reader will NOT be able to save data in the form UNLESS the form has been Reader Enabled before the form is deployed.
    The form can be Reader Enabled in two ways:
    Using Acrobat Standard v9 or Acrobat Professional v7 or v8. Has licence restrictions, see EULA.
    Using a server produce called Adobe LiveCycle Reader Extensions ES2. Additional costs.
    Here is a summary of the options available to users with Reader, depending on whether the form is Reader Enabled AND how it was enabled:
    There is a post here and a PDF summary:
    http://assurehsc.ie/blog/index.php/2010/05/using-livecycle-forms-in-acrobat-and-reader/
    Hope that helps,
    Niall

  • Suddenly, any new music or podcast I download - from any source - will be choppy, and corrupted. What's happened?

    No matter which site I use as the source, anything I download will be choppy and corrupted. Music and podcasts both end up unlistenable. This has only started happening in the last few days, with nothing I can think of that has changed in that time to cause this. Steam cannot update itself, or install the new Skyrim patch - it keeps flickering between "x% complete" and "Starting download". Some pictures also look garbled or entirely absent.
    I've already tweaked and then uninstalled Quicktime; I've reset Firefox; and I've kicked the desk a few times. All useless. What is going on?

    Do you have this issue with another browser? Have you checked out our help articles? This could also be an issue with your internet connectivity (contact your ISP for that reason)

  • My screen will suddenly be 're-directed' by Modzilla to a new site not ever opened by me. What's happening?

    When on a screen, it will suddenly disappear and I will be at another screen, usually '...film trailers'.
    I have never opened this screen in the past.
    The comment at the bottom is "re-directed by Modzilla"
    This has just happened in the last few days, 3-4 times.

    I'll try more/different anti-virus programs and let you know.
    Thanks,
    lmkbh1

Maybe you are looking for

  • IPod frozen and not showing up in iTunes, I've tried everything

    My iPod Nano (2nd generation) has "Do not disconnect" on the screen whether or not it is connected to the computer, and it will not show up in iTunes, and I do not think that it is showing up in "My Computer." I think I have tried everything that the

  • Java.util.zip.ZipException error when building

    Good Day All, I am a newbie and this is my first JWS deployment. I have an app that I am writing in Netbeans 6.1 that I want to deploy via JWS. The app accesses five different JAR libraries and that is where my troubles started. I thought that I need

  • Smartview keeps asking for password

    Hi We have a user who keeps gets the login prompt even though he has entered the password correct. This is only for one user and when tried another ID on the same pc/sheet -> we are able to login successfully. Thanks in advance. regards Dps

  • Scene selection button disappeared forever

    After struggling fruitlessly with DVD studio pro, (which refused to make a DVD that played on any machine other than my iMac,) I was forced to switch to iDVD, which behaves at least half-competently. I was editing a project and deleted the scene sele

  • Need to stop a Wait(mS) instruction in the middle of execution

    I have an application that needs to be able to stop a process in case of emergency. Currently, this is implemented with a Wait(ms) instruction, with a front panel variable wired to it, to give it the number of milliseconds to wait. This time can be u