Oracle therow and rowid

Results 1 to 2 of 2

Thread: Oracle therow and rowid

  1. #1
    Join Date
    Dec 1969

    Default Oracle therow and rowid

    I&#039;m not expert in Oracle. I&#039;m little bit confused about therow and rowid in following query. I would appreciate if you could explain the query. Thanks<BR><BR>Cursor SALE_MTD Is<BR> Select a.rowid therow from SALES_DTL a<BR> where SA_DATE = sdate<BR> and COMPANY = &#039;D&#039;;<BR><BR>For Cr in SALE_MTD Loop<BR>:<BR>:<BR> counter:=counter + 1;<BR> Update SALE_DTL<BR> Set COMPLETED = &#039;Y&#039;<BR> Where rowid = Cr.therow;<BR>:<BR>:<BR> If mod(counter,25) = 0 then<BR> commit;<BR> End If<BR><BR>End Loop;

  2. #2
    Join Date
    Dec 1969

    Default RE: Oracle therow and rowid

    Each row in a table has a unique adresss. The pseudocolumn ROWID contains that value and can thus be used to uniquely identify a record in a table. therow is an alias, it just renames the column in the result. <BR><BR>What the query does is to update all rows that fulfil the criteria in the cursor definition. The updated is divided into different transactions each containing 25 updates. <BR><BR>This last precaution is probably to avoid getting a large rollback log. Using 25 seems to me very low. Unless there is a very large amount of data that will be update I would try doing it with one update statement instead.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts