Answer the question
In order to leave comments, you need to log in
How to loop through the value of a field in a table column?
I have a naprav label with naprav_id and naprav_name fields, I'm trying to write something like this:
For naprav_id in (select naprav_id from naprav)
Loop
select naprav_name from naprav where naprav.naprav_id=naprav_id
Endloop;
Answer the question
In order to leave comments, you need to log in
The idea is something like this:
for your_cursor in (select naprav_id, naprav_name from naprav)
loop
dbms_output.put_line('ID: '||your_cursor.naprav_id);
dbms_output.put_line('Name: '||your_cursor.naprav_name);
insert into some_other_table(name)
values(your_cursor.naprav_name);
-- и всякие другие варианты обращения к значению поля через your_cursor.имя_поля
end loop;
commit;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question