Professional Documents
Culture Documents
P_VAL1 numeric(26,3);
v_loop integer;
v_loop_num1 integer;
boolean_val boolean;
vi_record RECORD;
tmp1 Character varying(60000);
tmp2 Character varying(60000);
tmp3 Character varying(60000);
tmp4 Character varying(60000);
tmp5 Character varying(60000);
tmp6 Character varying(60000);
tmp7 Character varying(60000);
tmp8 Character varying(60000);
tmp9 Character varying(60000);
tmp10 Character varying(60000);
begin
v_loop_num1=0;
v_loop=0;
execute tmp1;
--raise notice '%',tmp1;
execute tmp2;
--raise notice '%',tmp2;
execute tmp3;
--raise notice '%',tmp3;
execute tmp4;
--raise notice '%',tmp4;
execute tmp5;
--raise notice '%',tmp5;
execute tmp6;
--raise notice '%',tmp2;
execute tmp7;
--raise notice '%',tmp4;
execute tmp8;
--raise notice '%',tmp5;
execute tmp9;
--raise notice '%',tmp5;
if boolean_val then
v_loop=-1;
end if;
END;
$BODY$
language plpgsql;
commit;
begin;
call p_kp_firstm_proc();
commit;
OUTPUT
NOTICE: 4.172
NOTICE: 1.000
NOTICE: t
NOTICE: The condition is satisfied exciting while loop ,t
COMMIT
Programme using ‘plsql’
/*******************************************************************************
--------------------------------------------------------------------------------
**History**
Date Version No Change Developer
------- ------ ------ ---------
11/04/2022 0.1 Initial version Raghavendra S Sanganaikar
**********************************************************************************
/
DECLARE
vi_record RECORD;
tmp1 Character varying(60000);
tmp2 Character varying(60000);
tmp3 Character varying(60000);
tmp4 Character varying(60000);
tmp5 Character varying(60000);
tmp6 Character varying(60000);
tmp7 Character varying(60000);
tmp8 Character varying(60000);
tmp9 Character varying(60000);
tmp10 Character varying(60000);
tmp11 Character varying(60000);
tmp12 Character varying(60000);
tmp13 Character varying(60000);
tmp14 Character varying(60000);
tmp15 Character varying(60000);
tmp16 Character varying(60000);
v_loop_num1 integer;
v_loop_num2 integer;
v_loop integer;
var_gf_col boolean ;
var_gf_row boolean;
begin
union all
select 'obase_year_production',
round(sum(zone1)) as zone1,
round(sum(zone2)) as zone2,
round(sum(zone3)) as zone3,
round(sum(zone4)) as zone4,
null,
null,
null
from kp_zones_matrix1
union all
select 'gf',
round((select gfactor::numeric(26,3) from kp_hor_gfs0 where zone='zone1')::numeric(26,3),3)
as zone1,
round((select gfactor::numeric(26,3) from kp_hor_gfs0 where
zone='zone2')::numeric(26,3),3) as zone2,
round((select gfactor::numeric(26,3) from kp_hor_gfs0 where
zone='zone3')::numeric(26,3),3) as zone3,
round((select gfactor::numeric(26,3) from kp_hor_gfs0 where
zone='zone4')::numeric(26,3),3) as zone4,
null,
null,
null
order by source;
v_loop_num1=0;
v_loop_num2=0;
v_loop=0;
union all
union all
union all
execute tmp1;
-- raise notice '%',tmp1;
execute tmp2;
--raise notice '%',tmp2;
execute tmp3;
--raise notice '%',tmp3;
execute tmp4;
----raise notice '%',tmp4;
execute tmp5;
--raise notice '%',tmp5;
execute tmp6;
---raise notice '%',tmp6;
execute tmp7;
--raise notice '%',tmp7;
execute tmp8;
--raise notice '%',tmp8;
execute tmp9;
--raise notice '%',tmp9;
execute tmp10;
--raise notice '%',tmp10;
v_loop_num2=v_loop_num2+1;
raise notice '%',v_loop_num2;
execute tmp11;
--raise notice '%',tmp11;
execute tmp12;
--raise notice '%',tmp12;
execute tmp13;
-- raise notice '%',tmp13;
execute tmp14;
--raise notice '%',tmp14;
execute tmp15;
execute tmp16;
--raise notice '%',tmp16;
v_loop_num1=v_loop_num1+1;
raise notice '%',v_loop_num1;
end LOOP;
END;
$BODY$
language plpgsql;
commit;
drop table if exists kp_zones1;
create table kp_zones1
(source varchar,
destination varchar,
distance numeric);
begin;
call p_kp_secondm_proc();
commit;
OUTPUT
NOTICE: 1
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 1
NOTICE: 2
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 2
NOTICE: 3
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 3
NOTICE: 4
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 4
NOTICE: 5
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 5
NOTICE: 6
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 6
NOTICE: 7
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 7
NOTICE: 8
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 8
NOTICE: 9
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 9
NOTICE: 10
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 10
NOTICE: 11
NOTICE: row boolean value is t
NOTICE: column boolean value is t
NOTICE: 11
COMMIT
Programme using ‘plsql’
/*******************************************************************************
--------------------------------------------------------------------------------
**History**
Date Version No Change Developer
------- ------ ------ ---------
11/04/2022 0.1 Initial version Raghavendra S Sanganaikar
*********************************************************************************/
DECLARE
var_f numeric(26,3);
var_gf_col boolean ;
var_gf_row boolean;
v_loop integer;
var_f1 varchar;
vi_record RECORD;
tmp1 Character varying(60000);
tmp2 Character varying(60000);
tmp3 Character varying(60000);
tmp4 Character varying(60000);
tmp5 Character varying(60000);
tmp6 Character varying(60000);
tmp7 Character varying(60000);
tmp8 Character varying(60000);
tmp9 Character varying(60000);
tmp10 Character varying(60000);
tmp11 Character varying(60000);
tmp12 Character varying(60000);
tmp13 Character varying(60000);
tmp14 Character varying(60000);
tmp15 Character varying(60000);
tmp16 Character varying(60000);
tmp17 Character varying(60000);
tmp18 Character varying(60000);
tmp19 Character varying(60000);
tmp20 Character varying(60000);
v_loop_num1 integer;
v_loop_num2 integer;
begin
union all
union all
select 'gf',
round((select gfactor::numeric(26,3) from kp_given_gf0 e where
zone='zone1')::numeric(26,3),3) as zone1,
round((select gfactor::numeric(26,3) from kp_given_gf0 f where
zone='zone2')::numeric(26,3),3) as zone2,
round((select gfactor::numeric(26,3) from kp_given_gf0 g where
zone='zone3')::numeric(26,3),3) as zone3,
round((select gfactor::numeric(26,3) from kp_given_gf0 h where
zone='zone4')::numeric(26,3),3) as zone4,
null,
null,
null
order by source;
v_loop_num1=0;
v_loop_num2=0;
v_loop=0;
union all
select source,
max(case when dest=''zone1''
then new_matrix_vals
end)zone1,
max(case when dest=''zone2''
then new_matrix_vals
end)zone2,
max(case when dest=''zone3''
then new_matrix_vals
end)zone3,
max(case when dest=''zone4''
then new_matrix_vals
end)zone4
from kp_pre_iteration_dm'|| v_loop_num1 || ' b
where source=''zone2''
group by 1
union all
select source,
max(case when dest=''zone1''
then new_matrix_vals
end)zone1,
max(case when dest=''zone2''
then new_matrix_vals
end)zone2,
max(case when dest=''zone3''
then new_matrix_vals
end)zone3,
max(case when dest=''zone4''
then new_matrix_vals
end)zone4
from kp_pre_iteration_dm'|| v_loop_num1 || ' c
where source=''zone3''
group by 1
union all
select source,
max(case when dest=''zone1''
then new_matrix_vals
end)zone1,
max(case when dest=''zone2''
then new_matrix_vals
end)zone2,
max(case when dest=''zone3''
then new_matrix_vals
end)zone3,
max(case when dest=''zone4''
then new_matrix_vals
end)zone4
from kp_pre_iteration_dm'|| v_loop_num1 || ' d
where source=''zone4''
group by 1
order by source )a ';
union all
union all
union all
execute tmp1;
--raise notice '%',tmp1;
execute tmp2;
--raise notice '%',tmp2;
execute tmp4;
--raise notice '%',tmp4;
execute tmp5;
--raise notice '%',tmp5;
execute tmp6;
--raise notice '%',tmp6;
execute tmp7;
--raise notice '%',tmp7;
execute tmp8;
--raise notice '%',tmp8;
execute tmp9;
--raise notice '%',tmp9;
execute tmp10;
--raise notice '%',tmp10;
execute tmp11;
--raise notice '%',tmp11;
v_loop_num2=v_loop_num2+1;
raise notice '%',v_loop_num2;
execute tmp12;
--raise notice '%',tmp12;
execute tmp13;
--raise notice '%',tmp13;
--execute tmp14;
--raise notice '%',tmp14;
execute tmp15;
--raise notice '%',tmp15;
execute tmp18;
--raise notice '%',tmp18;
execute tmp19;
--raise notice '%',tmp19;
execute tmp20;
--raise notice '%',tmp20;
var_gf_col:=(select final_op from kp_check_gfs_columns);
v_loop_num1=v_loop_num1+1;
raise notice '%',v_loop_num1;
end loop;
END;
$BODY$
language plpgsql;
commit;
begin;
call p_kp_dm_proc();
commit;
drop table if exists kp_zones_list;
create table kp_zones_list
(source varchar,
destination varchar,
distance numeric);
begin;
call p_kp_dm_proc();
commit;
OUTPUT
WARNING: there is no transaction in progress
NOTICE: 2.617
NOTICE: 1
NOTICE: 1.069
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 1
NOTICE: 2
NOTICE: 1.012
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 2
NOTICE: 3
NOTICE: 1.003
NOTICE: row boolean value is f
NOTICE: column boolean value is f
NOTICE: 3
NOTICE: 4
NOTICE: 1.001
NOTICE: row boolean value is t
NOTICE: column boolean value is t
NOTICE: 4
COMMIT
Programme using ‘plsql’
/*******************************************************************************
--------------------------------------------------------------------------------
**History**
Date Version No Change Developer
------- ------ ------ ---------
11/06/2022 0.1 Initial version Raghavendra S Sanganaikar
*********************************************************************************/
DECLARE
begin
union all
select 'dj_curr',
round(sum(zone1)) as zone1,
round(sum(zone2)) as zone2,
round(sum(zone3)) as zone3,
round(sum(zone4)) as zone4,
null,
null,
null
from kp_zones_matrix_fm1 fm
union all
select 'dj_hor',
round(round(sum(zone1)) * (select b.gfactor from kp_gfsfm0 b where b.zone='zone1')),
round(round(sum(zone2)) * (select b.gfactor from kp_gfsfm0 b where b.zone='zone2')),
round(round(sum(zone3)) * (select b.gfactor from kp_gfsfm0 b where b.zone='zone3')),
round(round(sum(zone4)) * (select b.gfactor from kp_gfsfm0 b where b.zone='zone4')),
null,
null,
null
from kp_zones_matrix_fm1 fm1;
v_loop_num1=0;
v_loop_num2=0;
v_loop=0;
union all
union all
select source,
zone1,
zone2,
zone3,
zone4
from kp_base_matrix
where source=''dj_hor''';
execute tmp1;
--raise notice '%',tmp1;
execute tmp2;
--raise notice '%',tmp1;
execute tmp3;
--raise notice '%',tmp1;
execute tmp4;
--raise notice '%',tmp1;
execute tmp5;
--raise notice '%',tmp1;
execute tmp6;
--raise notice '%',tmp1;
--execute tmp7;
--raise notice '%',tmp1;
execute tmp8;
--raise notice '%',tmp1;
if var_gf_row then
return;
end if;
execute tmp9;
--raise notice '%',tmp9;
execute tmp10;
--raise notice '%',tmp10;
--execute tmp11;
--raise notice '%',tmp11;
execute tmp12;
--raise notice '%',tmp12;
execute tmp13;
--raise notice '%',tmp13;
execute tmp14;
--raise notice '%',tmp14;
execute tmp15;
--raise notice '%',tmp15;
if var_gf_col then
v_loop=-1;
end if;
v_loop_num1=v_loop_num1+1;
raise notice '%',v_loop_num1;
end LOOP;
END;
$BODY$
language plpgsql;
commit;
drop table if exists kp_zones_fm;
create table kp_zones_fm
(source varchar,
destination varchar,
distance numeric);