Ok, I understand. While the second table "is not as complex" but if you want to take the index optimally try something like:
select first 1 n_orden from ordenes where year_orden = new.year_orden order by* year_orden desc, n_orden desc* into new.n_orden; Regards. Christian [Non-text portions of this message have been removed]