0
Nome Idade ID
João 5
Lucas 5
João 2
Lucas 1
I would like to use a cursor to sort by names and by age and the ID field to be populated according to the sequence, for example:
Nome Idade ID
João 2 1
João 5 2
Lucas 1 1
Lucas 5 2
It’s Possible?
can inform the scenario? This information is being entered? are in a select? It was not clear your doubt...
– Gabriel Souza
This information is present in a table. that would be inserted only the ID
– update sem where
Declare
 v_contador number := 0;
 v_min_idade number := 0;
 cursor c_i is
 select t.*, rowid from teste_matheus t order by nome, idade asc;
begin
 for i in c_i loop 
 select min(idade)
 into v_min_idade
 from teste_matheus Where id is null and name = i.name; if i.age = v_min_age and i.id is null then v_counter := v_counter + 1; update teste_matheus t set id = v_counter where id is null and t.name = i.name; END IF; END LOOP; END; .
– update sem where