Answer the question
In order to leave comments, you need to log in
Why is it throwing an error in oracle dynamic query?
It throws an error that the end-of-request character was expected (and a number of other ora-06550, pls-00103) and not $ in the first line with to_date:
declare
p_sql clob;
begin
βfor naprav in (select naprav_name from naprav)
β β βloopβ β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
β β β β β β for pokaz in (select * from pokaz)
β β β β β β βloop
β β β β β β β β βfor group_level in (select * from group_level)
β β β β β β β β β β βloop
β β β β β β β β β β β β β β p_sql := '
β β β β β β β β β β β β β insert into from_cost_lab_with_love
β β β β β β β β β β β β β with cte as (
β β β β β β β β β β β β β β β β β β β β select
β β β β β β β β β β β β β β β β β β β β β ' ||β pokaz.i_id_pokaz || ' as i_id_pokaz,
β β β β β β β β β β β β β β β β β β β β ' ||β pokaz.pokaz_measure || ' as pokaz_measure,
β β β β β β β β β β β β β β β β β β β β ' ||β pokaz.pokaz_describe || ' as "ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΠΎΠΊΠ°Π·Π°ΡΠ΅Π»Ρ",
β β β β β β β β β β β β β β β β β β β β ' ||β naprav.naprav_name || ' as "ΠΠ»ΠΎΠΊ Π΄Π°Π½Π½ΡΡ
",
β β β β β β β β β β β β β β β β β β β β ' ||β group_level.level_name || ' as level_name,
β β β β β β β β β β β β β β β β β β β β ' ||β group_level.tb_id || ' as tb_id,
β β β β β β β β β β β β β β β β β β β β ' ||β group_level.gosb_id || ' as gosb_id,
β β β β β β β β β β β β β β β β β β β β ' ||β group_level.org_id || ' as org_id,
β β β β β β β β β β β β β β β β β β β β ' ||β pokaz.pokaz_formula || ' over(' || group_level.partition_column || ') as fact_amt,' --ΠΏΠΎΠΊΠ°Π·Π°ΡΠ΅Π»Ρ
β β β β β β β β β β β β β β β β β β β β β β ||β pokaz.pokaz_formula || ' over(' || group_level.partition_column || ') as fc_amt_1,
β β β β β β β β β β β β β β β β β β β β β β β β β β row_number() over(' || group_level.partition_column || ' order by BE) as rnk
β β β β β β β β β β β β β β β β β β β β β β β β β β 0 as plan_amt,
β β β β β β β β β β β β β β β β β β β β β β β β β β TO_DATE(CONCAT(CONCAT(FINANSOVYJ_GOD,CONCAT(q'$'0'$',KVARTAL*3 - 3)),q'$'01'$'), q'$'yyyymmdd'$') as period_begin,β --Π½Π°ΡΠ°Π»ΠΎ ΠΊΠ²Π°ΡΡΠ°Π»Π°
β β β β β β β β β β β β β β β β β β β β β β β β β β LAST_DAY(TO_DATE(CONCAT(CONCAT(FINANSOVYJ_GOD,CONCAT(q'$'0'$',KVARTAL*3)),q'$'01'$'), q'$'yyyymmdd'$')) as period_end, --ΠΊΠΎΠ½Π΅Ρ ΠΊΠ²Π°ΡΡΠ°Π»Π°
β β β β β β β β β β β β β β β β β β β β β β β β β β LAST_DAY(TO_DATE(CONCAT(CONCAT(FINANSOVYJ_GOD,CONCAT(q'$'0'$',MESJATS)), q'$'01'$'), q'$'yyyymmdd'$')) as rep_date, --Π΄Π°ΡΠ° ΠΈΠ·ΠΌΠ΅ΡΠ΅Π½ΠΈΠΉ
β β β β β β β β β β β β β β β β β β β β β β β β β β β TO_DATE(CURRENT_DATE, q'$'dd.mm.yy'$') as load_date,
β β β β β β β β β β β β β β β β β β β β β β β β β β 0 as execution
β β β β β β β β β β β β β β β β β β β β β from erp_trips
β β β β β β β β β β β β β )
β β β β β β β β β β β β β select *
β β β β β β β β β β β β β from cte
β β β β β β β β β β β β β where rnk=1;';
β β β β β β β β β β β β β dbms_output.put_line(p_sql);
β β β β β β β β β β β β βexecute immediate p_sql;
β β β β β β β βend loop;
β β β β βend loop;
β β βend loop;
end;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question