Chapter 5: Cursors

In This Chapter

arrow Declaring a cursor

arrow Opening a cursor

arrow Fetching data from a single row

arrow Closing a cursor

SQL differs from most other computer languages in one important respect: Other languages, such as C, Java, or Basic, are procedural languages because programs written in those languages set out a specified series of operations that need to be carried out in the same manner and in the same order — procedures, in other words. That means procedural languages first execute one instruction, and then the next one, then the next, and so on. The pertinent point here is that they can do only one thing at a time, so that when they are asked to deal with data, they operate on one table row at a time. SQL is a nonprocedural language, and thus is not restricted to operating on a single table row at a time. Its natural mode of operation is to operate on a set of rows. For example, an SQL query may return 42 rows from a database containing thousands of rows. That operation is performed by a single SQL SELECT statement.

Because SQL is a data sublanguage, it does not contain all ...

Get SQL All-in-One For Dummies®, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.