USING CURSOR

xiaoxiao2021-03-06  22

Purpose:

Sometimes there is a nesed to step through.

SQL retrieval operations work with sets of rows knows as result sets The rows returned are all the rows that match a SQL statement -.. Zero or more of them Using the simple SELECT statements, there is no way to get the first row, the next Row, or the previous 10 rows. That's why cursor is used.

Shortage:

Cursors and web-based applications cursors are rather useless when it comes to web-based applications. Cursors are designed to persist for the duration of a session between a client application and a server, but this client / server model does not fir in the web Application World Because The Application Server Is The Database Client, Ot The End User. as Such, Most Web Application Developers Avoid The Use of Cursors and Re-Create The Functionality Themselves IF NEEDED.

CREATE A CURSOR:

Declair Customercursor Cursor

For

Select * from customer

WHERE Customeremail Is Null

USING A CURSOR:

Declare Type Customercursor Is Ref Cursor Return Customers% RWOTYPE;

Declare CustomerRecord Customers% RowType

Begin

Open Customercursor;

Fetch Customercursor INTO CUSTOMERRECORD;

Close Customercursor;

END;

转载请注明原文地址:https://www.9cbs.com/read-43404.html

New Post(0)