Problem solve Get help with specific problems with your technologies, process and projects.

REF cursors explained

Can you throw some light on REF cursors? Are they the same as the usual cursors that we define in PL/SQLs? If not, how do they differ.. and when can we use them?

REF cursors are different than your typical, standard cursors. With standard cursors, you know the cursor's query ahead of time. With REF cursors, you do not have to know the query ahead of time. REF cursors let you create a cursor to be used in your PL/SQL block, for instance, and use that cursor, without knowing ahead of time what your particular query might be. This is often used when the cursor's query will be given to a stored procedure or function at runtime. For instance, you might want a function to compute the average of a column on a particular table. But you don't know ahead of time what the table or column will be. With regular cursors, you would need to know. But with REF cursors, you can pass the table and column to the function, and have the REF cursor build the cursor "on the fly".

For More Information

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.