Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using cursors in Pro*C

Status
Not open for further replies.

rohanem

Programmer
Aug 16, 2002
64
US
I know we use cursors to fetch data i.e. SELECT statements in Pro*C..Can we use cursors for delete as well

For instance

EXEC SQL delcare c1 cursor for SELECT col1,col2 from table_name;

EXEC SQL OPEN c1;

EXEC SQL FETCH c1 into :var1,:var2;

How can we use cursor concept for delete statements.

Thanks & Regards
Rohan
 
You cant use PL/SQL cursors to delete but you can delete using a Pro*C array.
 
thanks lewisp, can u quote a simple example of how we can use it?
 
In your DECLARE SECTION simply define all the variables you want to use in your delete statement with the same array size. Populate the array with the values you need for the delete. When you issue the DELETE statement Pro*C will automatically loop through the array and delete all the rows. Make sure you use EXEC SQL FOR if the array is not used to its full extent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top