DECLARE
  cnt NUMBER (12);
BEGIN

cnt := 0;

select count(*) into cnt from user_tables where table_name='TEMP_MBK_701F_TABLE';
if cnt > 0 then
  begin
    execute immediate 'truncate table TEMP_MBK_701F_TABLE';
    execute immediate 'drop table TEMP_MBK_701F_TABLE';
  end;
end if;


execute immediate 'CREATE GLOBAL TEMPORARY TABLE TEMP_MBK_701F_TABLE('||
'F_ID int ,LINK_ID int ,SWAP_N int ,VALZ int,KODVAL int '||
',FLAG1 int ,FLAG2 int ,FLAG3 int ,FLAG4 int ,F2 date ,F3 date '||
',F4 varchar(3) ,F5 numeric(18,3) ,F6 varchar(3) ,F7 numeric(18,3) ,F8 varchar(1) '||
',F9 varchar(100) ,F10 varchar(100) ,F11 varchar(4) ,F12 varchar(1) ,F13 varchar(4) '||
',F14 numeric(8,4) ,F15 varchar(1) ,F16 numeric(12) ,F17 date, DOC_OID int, DOG_TYPE int, FLAG int'||
',F_ORGID int, F_ISBIRZ int, F_SROK int, F_DELIV int, PFI int, SUMMA numeric(18,3)'||
') ON COMMIT PRESERVE ROWS NOCACHE';


cnt := 0;

select count(*) into cnt from user_tables where table_name='TEMP_CALC701';
if cnt > 0 then
  begin
    execute immediate 'truncate table TEMP_CALC701';
    execute immediate 'drop table TEMP_CALC701';
  end;
end if;

execute immediate 'CREATE GLOBAL TEMPORARY TABLE TEMP_CALC701('||
'FMODULE varchar2(3),DATEZ date, DATER date, VALT varchar2(3), OSTT numeric(18,3), VALO varchar2(3), OSTO numeric(18,3), NR varchar(1), KO varchar2(100), SVSYS varchar2(100)'||
',OTH varchar2(50),  DOPSV varchar2(50), OPT varchar(4), PRSTAV decimal(8,4), SSORT int, SEGM varchar(8), VP varchar(8), SUMMIL int, VB int'||
',OBJID numeric, DOP15_S_B  varchar2(1), DOP16_METHOD numeric(18,3), BEFORE_15_30 numeric(18,3), DOC_OID numeric, ORGID numeric, ISBIRZ int, SROK int, DELIV int, PFI int'|| 
') ON COMMIT PRESERVE ROWS NOCACHE' ;

END;
