Chapter 5



Bullet Declaring a cursor

Bullet Opening a cursor

Bullet Fetching data from a single row

Bullet 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, 3rd 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.