CREATE OR REPLACE PROCEDURE adempiere.z_generate_z_period(xad_org_id numeric
,xtahun numeric)
LANGUAGE plpgsql
AS $procedure$ declare
z_value numeric;
z_nama varchar(80);
begin
-- Enter function body here
for i in 1..12
loop
z_value:=xtahun*100+i;
select to_char(to_date(xtahun||'-'||right('0'||i,2),'yyyy-mm'),'Mon-yyyy') into z_nama;
INSERT INTO z_period
(ad_org_id, created, createdby, isactive
, updated, updatedby, z_period_id
, z_period_uu
, "name", value, ad_client_id, isclosed)
VALUES(xad_org_id, statement_timestamp(), 1000000, 'Y'::bpchar
, statement_timestamp(), 1000000
, nextid((select ad_sequence_id from ad_sequence where name = 'z_period')::Integer, 'N'::Varchar)
, generate_uuid()
, z_nama,z_value, 1000000, 'N'::bpchar);
commit;
end loop;
end;
$procedure$
;
Friday, May 24, 2019
generate z_period
Labels:
idempiere,
postgresql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment