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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you make a cursor updateable when using an order by clause?

Status
Not open for further replies.

asotmhg

Programmer
May 11, 2000
48
US
I am using a cursor in a stored procedure.&nbsp;&nbsp;I am using the &quot;order by&quot; clause in the select, but I am also declaring the fields I want to update in the &quot;For Update of&quot; clause.&nbsp;&nbsp;The Query analizer with SQL server 7.0 gives me the error &quot;cursor is read only&quot; when I run it. The statement is as follows:<br><br>declare curPur CURSOR FOR<br>select itemno,itemqty,itemcost,itemfees<br>from purnet<br>where itemno = @sellin<br>order by [date]<br>For Update of itemqty<br><br>I am deleting the entire record the cursor points to if the quantity of itemqty is less than the quantity sought for.&nbsp;&nbsp;If the quantity of itemqty is more then I subtract the quantity sought for from itemqty and update the record with a new quantity.<br><br>I have tried putting all of the fields from that table into the &quot;select&quot; and &quot;For Update of&quot; clauses, just in case the delete couldn't occur because some of the fields where not specified in the &quot;For Update of&quot; clause.<br><br>Thank You for your help.&nbsp;&nbsp;<br><br>&nbsp;<br>
 
The order by clause should not affect you deletion <p>Cal<br><a href=mailto: > </a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top