Hi Babs,
Essentially cursors are variables within the database space, you open one
and assign an SQL result set to it.
These are indeed temp tables, but may have different rules on persistance
depending on your RDBMS.
Cursors are useful because you can select a large amount of data into a
cursor quickly, and without pulling it over to your application layer.
You can allow you to scroll back and forth among an immediate set of
results too, held in a keyset.
The keyset is a subset of the rowset, where the rowset is created by your
SQL statement.
Think of the keyset as a sliding window.
Additionally, this sliding window has a pointer in it, so you can select a
specifcic record to return or update.
RDBMS support for triggers will depend on the things like directions the
keyset can scroll (bi-directional scrollable cursors) and if the rowset is
sensitive (dynamic cursors) to changes in the underlying database.
Triggers on the other hand are conditional statements stored as database
objects.
They "fire" when the conditional clause conditions are met, often to update
a second set of database records (e.g. to kludge referential integrity) or
to create a log of some sort.
Check out the new Wrox book on Beginning PHP Databases - cursors and
triggers are covered in great depth.
Let me know if you have any questions.
Best regards,
Andrew Hill
At 09:31 PM 11/23/2002, Bab Tools wrote:
>Hi,
>
>What are cursors. In one book I have read they are result sets, and in
>another I have read they are temporary tables. I'm guessing both are
>wrong, could you help please?
>
>Also, could someone please tell me what triggers are?
>
>Thanks
>Babs