sql% rowcount

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
cleberzumba
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 223
Joined: Thu, 14 Dec 2006 10:45 am
Location: Brasília-DF
Cleber Zumba de Souza

Wanted to know if the SQL% rowcount command only returns lines processed by DML statements, does it not work for a SELECT?

Ex:

Select Count (*) From <table>
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

% Rowcount returns the number of rows returned from a fetch in the cursor. If you do a cursor with Select Count (*), it will return 1 as it is returning only 1 line of the cursor. (With the quantity)

Another thing that you can do is count how many records were affected by an update. Hence, we use SQL% Rowcount.
Example:

Select all

update SUA_TABELA 
  set ok='x' 
  where ok='S'; 
   
  dbms_output.put_line(sql%rowcount); 
In that case, the output will be the amount of rows that the Update did.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests