DECLARE
cur PLS_INTEGER := DBMS_SQL.OPEN_CURSOR;
cols DBMS_SQL.desc_tab;
ncols PLS_INTEGER;
BEGIN
DBMS_SQL.PARSE
(cur, '
SELECT
(select q.n_order from tmp_sort_report_pok q where q.id = fd.id_pok ) as n_order_pok
,nvl(msk_analytics.get_number(ID_COL_6965),0) as sort_val,fd.id_pok,
fd.id_oiv,
fd.id_okrug,
fd.id_region,
fd.id_complex,
-- fd.id_gp,
fd.id_expense,
fd.id_customer,
r.ID_COL_121,r.ID_COL_132,r.ID_COL_158,r.ID_COL_2201,r.ID_COL_2282,r.ID_COL_3961,r.ID_COL_3962,r.ID_COL_3966,r.ID_COL_406,r.ID_COL_4081,r.ID_COL_4186,r.ID_COL_444,r.ID_COL_5440,r.ID_COL_5525,r.ID_COL_5678,r.ID_COL_6025,r.ID_COL_6041,r.ID_COL_6220,r.ID_COL_6282,r.ID_COL_6460,r.ID_COL_6544,r.ID_COL_6584,r.ID_COL_6585,r.ID_COL_6683,r.ID_COL_6684,r.ID_COL_6724,r.ID_COL_6725,r.ID_COL_6726,r.ID_COL_6764,r.ID_COL_6904,r.ID_COL_6905,r.ID_COL_6906,r.ID_COL_6964,r.ID_COL_6965,r.ID_COL_7046,r.ID_COL_7047,r.ID_COL_7048,r.ID_COL_7058,r.ID_COL_7065,r.ID_COL_7089,r.ID_COL_7264,r.ID_COL_7332,r.ID_COL_7404,r.ID_COL_7409,r.ID_COL_7424,r.ID_COL_7425,r.ID_COL_7426,r.ID_COL_7427,r.ID_COL_7428,r.ID_COL_7429,r.ID_COL_7430,r.ID_COL_7431,r.ID_COL_7432,r.ID_COL_7433,r.ID_COL_7435,r.ID_COL_7436,r.ID_COL_7453,r.ID_COL_7534
FROM R_5618_20150501_15_1 r, /* отчет-дата-бюджет-версия расчета */
iot_rep_fix_dims fd
WHERE
r.id_row = fd.id_row
and fd.ID_GP in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_GP'')
and fd.ID_OIV in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_OIV'')
and fd.ID_POK in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_POK'')
and
id_okrug = 0 and
id_region = 0 and
(
(id_oiv in (100500,100501,100600,100601) and id_complex = -1) or
(id_oiv not in (100500,100501,100600,100601) and id_complex != -1)
)
order by 1,2 asc
', DBMS_SQL.NATIVE);
DBMS_SQL.DESCRIBE_COLUMNS (cur, ncols, cols);
FOR colind IN 1 .. ncols
LOOP
DBMS_OUTPUT.PUT_LINE (cols(colind).col_name);
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cur);
END;
N_ORDER_POK
SORT_VAL
ID_POK
ID_OIV
ID_OKRUG
ID_REGION
ID_COMPLEX
ID_EXPENSE
ID_CUSTOMER
ID_COL_121
ID_COL_132
ID_COL_158
ID_COL_2201
ID_COL_2282
cur PLS_INTEGER := DBMS_SQL.OPEN_CURSOR;
cols DBMS_SQL.desc_tab;
ncols PLS_INTEGER;
BEGIN
DBMS_SQL.PARSE
(cur, '
SELECT
(select q.n_order from tmp_sort_report_pok q where q.id = fd.id_pok ) as n_order_pok
,nvl(msk_analytics.get_number(ID_COL_6965),0) as sort_val,fd.id_pok,
fd.id_oiv,
fd.id_okrug,
fd.id_region,
fd.id_complex,
-- fd.id_gp,
fd.id_expense,
fd.id_customer,
r.ID_COL_121,r.ID_COL_132,r.ID_COL_158,r.ID_COL_2201,r.ID_COL_2282,r.ID_COL_3961,r.ID_COL_3962,r.ID_COL_3966,r.ID_COL_406,r.ID_COL_4081,r.ID_COL_4186,r.ID_COL_444,r.ID_COL_5440,r.ID_COL_5525,r.ID_COL_5678,r.ID_COL_6025,r.ID_COL_6041,r.ID_COL_6220,r.ID_COL_6282,r.ID_COL_6460,r.ID_COL_6544,r.ID_COL_6584,r.ID_COL_6585,r.ID_COL_6683,r.ID_COL_6684,r.ID_COL_6724,r.ID_COL_6725,r.ID_COL_6726,r.ID_COL_6764,r.ID_COL_6904,r.ID_COL_6905,r.ID_COL_6906,r.ID_COL_6964,r.ID_COL_6965,r.ID_COL_7046,r.ID_COL_7047,r.ID_COL_7048,r.ID_COL_7058,r.ID_COL_7065,r.ID_COL_7089,r.ID_COL_7264,r.ID_COL_7332,r.ID_COL_7404,r.ID_COL_7409,r.ID_COL_7424,r.ID_COL_7425,r.ID_COL_7426,r.ID_COL_7427,r.ID_COL_7428,r.ID_COL_7429,r.ID_COL_7430,r.ID_COL_7431,r.ID_COL_7432,r.ID_COL_7433,r.ID_COL_7435,r.ID_COL_7436,r.ID_COL_7453,r.ID_COL_7534
FROM R_5618_20150501_15_1 r, /* отчет-дата-бюджет-версия расчета */
iot_rep_fix_dims fd
WHERE
r.id_row = fd.id_row
and fd.ID_GP in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_GP'')
and fd.ID_OIV in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_OIV'')
and fd.ID_POK in (select to_number(FILTER_VALUE) from REP_FILTERS where WEB_IDENTIFIER = ''d03f75814107ac5b6ce84f9035979a3c'' and DIMENSION_NAME = ''ID_POK'')
and
id_okrug = 0 and
id_region = 0 and
(
(id_oiv in (100500,100501,100600,100601) and id_complex = -1) or
(id_oiv not in (100500,100501,100600,100601) and id_complex != -1)
)
order by 1,2 asc
', DBMS_SQL.NATIVE);
DBMS_SQL.DESCRIBE_COLUMNS (cur, ncols, cols);
FOR colind IN 1 .. ncols
LOOP
DBMS_OUTPUT.PUT_LINE (cols(colind).col_name);
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cur);
END;
N_ORDER_POK
SORT_VAL
ID_POK
ID_OIV
ID_OKRUG
ID_REGION
ID_COMPLEX
ID_EXPENSE
ID_CUSTOMER
ID_COL_121
ID_COL_132
ID_COL_158
ID_COL_2201
ID_COL_2282