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;
with great_design_tab as (
select 700 as id, '1,11,32,531' as ass_pain from dual union all
select 701 as id, '2, 44, 321' as ass_pain from dual
)
,usrs as (
select 1 as id, 'вася' as username from dual union all
select 11 as id, 'петя' as username from dual union all
select 32 as id, 'костя' as username from dual union all
select 531 as id, 'дима' as username from dual union all
select 2 as id, 'жора' as username from dual union all
select 44 as id, 'изя' as username from dual union all
select 321 as id, 'семен' as username from dual
)
select u.id, u.username, t.id
from usrs u
,great_design_tab t
,lateral (
select level x from dual
connect by regexp_substr(ass_pain, '[^,]+', 1, level) is not null
)
where u.id = trim(regexp_substr(ass_pain,'[^,]+', 1, x));
ID USERNAME ID
---------- -------- ----------
1 вася 700
11 петя 700
32 костя 700
531 дима 700
2 жора 701
44 изя 701
321 семен 701
WITH dt_range AS (
SELECT TRUNC (&dt_start + ROWNUM - 1) dt
FROM DUAL CONNECT BY ROWNUM <= &dt_end - &dt_start + 1
)
,bal AS (
SELECT 101 id_, to_date('20171130', 'yyyymmdd') date_, 50 sum_ FROM DUAL UNION ALL
SELECT 101, to_date('20180102', 'yyyymmdd'), 300 FROM DUAL UNION ALL
SELECT 101, to_date('20180105', 'yyyymmdd'), 500 FROM DUAL UNION ALL
SELECT 101, to_date('20180107', 'yyyymmdd'), 700 FROM DUAL
)
SELECT id_ --MAX(id_) OVER (PARTITION BY grp) id_
,dt
,MAX(sum_) OVER (PARTITION BY grp) sum_
FROM (
SELECT t1.*
,SUM(start_of_group) OVER(ORDER BY t1.dt) grp
FROM (
SELECT bal.id_
,dt_range.dt
,bal.sum_
,CASE WHEN bal.sum_ IS NOT NULL THEN 1 END start_of_group
FROM dt_range
LEFT JOIN bal ON dt_range.dt = bal.date_
) t1
)
ORDER BY dt
exp user/password@SID file=emp.dmp tables=(emp,dept) rows=no