Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.oracle    |    Overblown overpriced overengineered SHIT    |    2,288 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 917 of 2,288    |
|    Frank van Bortel to UNIXNewBie    |
|    Re: basic PL/SQL questions    |
|    06 Jan 04 21:36:48    |
      From: fvanbortel@netscape.net              UNIXNewBie wrote:       > Please excuse the basic nature of these questions - I'm just starting off.       >       > This example is taken from Oracle PL/SQL 101 - Osborne/McGraw-Hill - ISBN       > 0-07-212606-X - page 314       >       > Numbers to the left are line numbers for reference only. Hopefully I haven't       > made any typing mistakes.       >       > 1. DECLARE       >       > 2. CURSOR product_cur IS       >       > 3. SELECT * FROM plsql101_product       >       > 4. FOR UPDATE OF product_price;       >       > 5. BEGIN       >       > 6. FOR product_rec IN product_cur       >       > 7. LOOP       >       > 8. UPDATE plsql101_product       >       > 9. SET product_price = (product_rec.product_price =       > 0.97)       >       > 10. WHERE CURRENT OF product_cur       >       > 11. END LOOP;       >       > 12. END;       >       > Am I correct to say the following?       >       > The way a cursor works is that once a record is fetched it is taken out of       > the cursor.       No, fetched is fetched - it "stays" until your fetch the next one.               This works well until the last record is reached at which time       > fetch will continue to return the last record in the cursor              No - just give it a try - oracle will generate an error       unless you use       > the %FOUND and %NOTFOUND constructs to test for the last record?       >       > The cursor loop used in the above example eliminates the need to open, close       > and fetch. It also eliminates the need to check for the last record.       >       It's there: for x IN y : as long as there's an x fetched, do...              > There is no formal declaration of the cursor name "product_rec" first used       > on line 6. Is this an example of an implicit cursor of table-based record       > type?       Ehhh - not sure about the semantics, but it sounds familiar. Undoubtedly       you'll get a concise, yes/no answer.              >       > On line 9 how does PL/SQL know that there is a product_price field in the       > cursor record? Is this also part of the implicit cursor definition?       >       You know, or need to know. As a programmer.       It is checked during compile, if the above is part of a procedure.              Inline...              --              Regards,       Frank van Bortel              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca