ALTER PROCEDURE "dba"."pr_koond_rv_jooksev"( )
BEGIN
  declare ldc_deeb numeric(15,2);
  delete from gl_tr_tabel;

  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,1)='3' or left(konto,1)='4' or left(konto,1)='5' or left(konto,2)='60' or left(konto,2)='61' or left(konto,2)='62' or left(konto,2)='63' or left(konto,2)='64';
  insert into gl_tr_tabel(id,nimi,deeb) values (1,'   Aruandeperioodi tegevustulem',ldc_deeb);

  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,2)='61';
  insert into gl_tr_tabel(id,nimi,deeb) values (3,'      Põhivara amortisatsioon ja ümberhindlus',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='350200' or left(konto,6)='350220' or left(konto,3)='351';
  insert into gl_tr_tabel(id,nimi,deeb) values (4,'      Põhivara sihtfinantseerimise amortisatsioon',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='323880';
  insert into gl_tr_tabel(id,nimi,deeb) values (5,'      Liitumistasude amortisatsioon',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='3810' or left(konto,4)='3811' or left(konto,4)='3813' or left(konto,4)='3814';
  insert into gl_tr_tabel(id,nimi,deeb) values (6,'      Kasum/kahjum põhivara müügist',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,1)='1' and left(ravo,2)='24';
  insert into gl_tr_tabel(id,nimi,deeb) values (7,'      Kahjum antud mitterahalisest sihtfinantseerimisest',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='605000' or left(konto,6)='605010' or left(konto,6)='605020';
  insert into gl_tr_tabel(id,nimi,deeb) values (8,'      Ebatõenäoliselt laekuvate laenude muutus',ldc_deeb);

  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='102' or left(konto,3)='152';
  insert into gl_tr_tabel(id,nimi,deeb) values (11,'      Maksu-, lõivu- ja trahvinõuete muutus',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,5)='10300' or left(konto,5)='15300';
  insert into gl_tr_tabel(id,nimi,deeb) values (12,'      Muutus nõuetes ostjate vastu',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='103190';
  insert into gl_tr_tabel(id,nimi,deeb) values (13,'      Muutus viitlaekumistes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='1035' and left(konto,6)<>'103500' and left(konto,6)<>'103540' and left(konto,6)<>'103556' and left(konto,6)<>'103557';
  insert into gl_tr_tabel(id,nimi,deeb) values (14,'      Muutus nõuetes toetuste ja siirete eest',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='1036' or left(konto,4)='1536';
  insert into gl_tr_tabel(id,nimi,deeb) values (15,'      Muutus muudes nõuetes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='1037';
  insert into gl_tr_tabel(id,nimi,deeb) values (16,'      Muutus maksude, lõivude, trahvide ettemaksetes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='1038' or left(konto,4)='1537';
  insert into gl_tr_tabel(id,nimi,deeb) values (17,'      Muutus toetuste ettemaksetes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='1039' or left(konto,6)='153990';
  insert into gl_tr_tabel(id,nimi,deeb) values (18,'      Muutus muudes ettemaksetes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='108';
  insert into gl_tr_tabel(id,nimi,deeb) values (19,'      Muutus varudes',-1*ldc_deeb);
  
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='200';
  insert into gl_tr_tabel(id,nimi,deeb) values (22,'      Muutus saadud maksude, lõivude, trahvide ettemaksetes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='201000' or left(konto,5)='25000';
  insert into gl_tr_tabel(id,nimi,deeb) values (23,'      Muutus võlgades hankjatele',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='202';
  insert into gl_tr_tabel(id,nimi,deeb) values (24,'      Muutus võlgades töövõtjatele',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='2030' or left(konto,4)='2530';
  insert into gl_tr_tabel(id,nimi,deeb) values (25,'      Muutus maksu-, lõivu- ja trahvikohustustes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='203290';
  insert into gl_tr_tabel(id,nimi,deeb) values (26,'      Muutus viitvõlgades',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='2035' and left(konto,6)<>'203500' and left(konto,6)<>'203540';
  insert into gl_tr_tabel(id,nimi,deeb) values (27,'      Muutus toetuste ja siirete kohustustes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='2036' or left(konto,4)='2536';
  insert into gl_tr_tabel(id,nimi,deeb) values (28,'      Muutus muudes kohustustes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='2038' and left(konto,6)<>'203856' and left(konto,6)<>'203857';
  insert into gl_tr_tabel(id,nimi,deeb) values (29,'      Muutus saadud toetuste ettemaksetes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='203900' or left(konto,6)='203990' or left(konto,6)='253890';
  insert into gl_tr_tabel(id,nimi,deeb) values (30,'      Muutus muudes saadud ettemaksetes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where ((left(konto,3)='206' and left(konto,6)<>'206030') or left(konto,3)='256') and (left(ravo,2)='41' or left(ravo,2)='49' or left(ravo,2)='05' or left(ravo,2)='06');
  insert into gl_tr_tabel(id,nimi,deeb) values (31,'      Muutus eraldistes',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='289';
  insert into gl_tr_tabel(id,nimi,deeb) values (32,'      Muutus vähemusosas',ldc_deeb);

  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='155' and (left(ravo,2)='01' or left(ravo,2)='19' or left(ravo,2)='20' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (102,'      Materiaalse põhivara soetus',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='154' and (left(ravo,2)='01' or left(ravo,2)='19' or left(ravo,2)='20' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (103,'      Kinnisvarainvesteeringute soetus',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='156' and (left(ravo,2)='01' or left(ravo,2)='19' or left(ravo,2)='20' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (104,'      Immateriaalse põhivara soetus',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='157' and (left(ravo,2)='01' or left(ravo,2)='19' or left(ravo,2)='20' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (105,'      Bioloogiliste varade soetus',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='201010' or left(konto,5)='25001';
  insert into gl_tr_tabel(id,nimi,deeb) values (106,'      Korrigeerimine muutusega võlgades hankijatele',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='257' and (left(ravo,2)='01' or left(ravo,2)='05' or left(ravo,2)='11' or left(ravo,2)='19' or left(ravo,2)='29' or left(ravo,2)='49') or left(konto,6)='350200' or left(konto,6)='350220' or left(konto,3)='351';
  insert into gl_tr_tabel(id,nimi,deeb) values (107,'      Saadud sihtfinantseerimine põhivara soetuseks',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='203856' or left(konto,6)='203857';
  insert into gl_tr_tabel(id,nimi,deeb) values (108,'      Korrigeerimine muutusega sihtfinantseerimise kohustustes',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='103556' or left(konto,6)='103557';
  insert into gl_tr_tabel(id,nimi,deeb) values (109,'      Korrigeerimine muutusega sihtfinantseerimise nõuetes',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2082' or left(konto,4)='2582') and (left(ravo,2)='01' or left(ravo,2)='05' or left(ravo,2)='29' or left(ravo,2)='49');
  insert into gl_tr_tabel(id,nimi,deeb) values (110,'      Korrigeerimine kapitalirendi tingimustel soetatud põhivaraga',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='253800' or left(konto,6)='323880';
  insert into gl_tr_tabel(id,nimi,deeb) values (111,'      Korrigeerimine liitumistasudega',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6) in ('381000','381001','381100','381101','381110','381111','381115','381116','381120','381121','381125','381126','381130','381131','381140','381141','381145','381146','381150','381151','381160','381161','381170','381171','381180','381181','381300','381301','381320','381321','381360','381361','381400','381401','381410','381411','381420','381421');
  insert into gl_tr_tabel(id,nimi,deeb) values (114,'      Müügist saadud tulu',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,5)='10301' or left(konto,5)='15301';
  insert into gl_tr_tabel(id,nimi,deeb) values (115,'      Korrigeerimine laekumata nõuete muutusega',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='203910';
  insert into gl_tr_tabel(id,nimi,deeb) values (116,'      Korrigeerimine laekunud ettemaksete muutusega',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,5)='10325' or left(konto,5)='15325';
  insert into gl_tr_tabel(id,nimi,deeb) values (117,'      Korrigeerimine järelmaksunõuete muutusega',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='605020';
  insert into gl_tr_tabel(id,nimi,deeb) values (118,'      Korrigeerimine ebatõenäoliselt laekuvaks arvatud järelmaksunõuetega',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='206030' or left(konto,6)='700030' or left(konto,6)='710030';
  insert into gl_tr_tabel(id,nimi,deeb) values (119,'      Korrigeerimine kustutatud EVP-de jäägi muutusega',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='1032' or left(konto,4)='1532') and (left(ravo,2)='01' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (121,'   Antud laenud',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='1032' or left(konto,4)='1532') and (left(ravo,2)='02');
  insert into gl_tr_tabel(id,nimi,deeb) values (122,'   Tagasi makstud laenud',ldc_deeb);
  select sum(gl_pr_saldoandmik.deebet-gl_pr_saldoandmik.kreedit) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='103540' or left(konto,6)='203540';
  insert into gl_tr_tabel(id,nimi,deeb) values (123,'   Korrigeerimine laenutegevuseks saadud sihtfinantseerimise muutusega',-1*ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='1011' or left(konto,3)='151') and (left(ravo,2)='01' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (124,'   Tasutud finantsinvesteeringute soetamisel',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='1011' or left(konto,3)='151') and (left(ravo,2)='02');
  insert into gl_tr_tabel(id,nimi,deeb) values (125,'   Laekunud finantsinvesteeringute müügist',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,3)='150') and (left(ravo,2)='01' or left(ravo,2)='29');
  insert into gl_tr_tabel(id,nimi,deeb) values (126,'   Tasutud osaluste soetamisel',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,3)='150') and (left(ravo,2)='02');
  insert into gl_tr_tabel(id,nimi,deeb) values (127,'   Laekunud osaluste müügist',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='655500' or left(konto,6)='103110';
  insert into gl_tr_tabel(id,nimi,deeb) values (128,'   Laekunud dividendid',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='6580' or left(konto,5)='10310';
  insert into gl_tr_tabel(id,nimi,deeb) values (129,'   Laekunud intressid',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='655' or ((left(konto,4)='1011' or left(konto,3)='151') and (left(ravo,2) in ('10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28')));
  insert into gl_tr_tabel(id,nimi,deeb) values (130,'   Laekunud muu finantstulu',ldc_deeb);

  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2080' or left(konto,4)='2580') and (left(ravo,2)='05');
  insert into gl_tr_tabel(id,nimi,deeb) values (201,'   Laekunud võlakirjade emiteerimisest',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2080' or left(konto,4)='2580') and (left(ravo,2)='06');
  insert into gl_tr_tabel(id,nimi,deeb) values (202,'   Lunastatud võlakirjad',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2081' or left(konto,4)='2581') and (left(ravo,2)='05');
  insert into gl_tr_tabel(id,nimi,deeb) values (203,'   Laekunud laenud',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2081' or left(konto,4)='2581') and (left(ravo,2)='06');
  insert into gl_tr_tabel(id,nimi,deeb) values (204,'   Tagasi makstud laenud',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='208100';
  insert into gl_tr_tabel(id,nimi,deeb) values (205,'   Arvelduskrediidi muutus',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2082' or left(konto,4)='2582') and (left(ravo,2)='06');
  insert into gl_tr_tabel(id,nimi,deeb) values (206,'   Tagasi makstud kapitalirendikohustused',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2083' or left(konto,4)='2583') and (left(ravo,2)='05');
  insert into gl_tr_tabel(id,nimi,deeb) values (207,'   Laekunud faktooringlepingute alusel',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,4)='2083' or left(konto,4)='2583') and (left(ravo,2)='06');
  insert into gl_tr_tabel(id,nimi,deeb) values (208,'   Tagasi makstud faktooringlepingute alusel',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,3)='650' or left(konto,6)='203200' or left(konto,6)='209000' or left(konto,6)='103300';
  insert into gl_tr_tabel(id,nimi,deeb) values (209,'   Makstud intressid',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,4)='6589' or (left(konto,3)='208' or left(konto,3)='258') and (left(ravo,2) in ('40','41','42','43','44','45','46','47','48','49'));
  insert into gl_tr_tabel(id,nimi,deeb) values (210,'   Makstud muud finantskulud',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,6)='203210';
  insert into gl_tr_tabel(id,nimi,deeb) values (211,'   Makstud dividendid',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where left(konto,2)='68';
  insert into gl_tr_tabel(id,nimi,deeb) values (212,'   Dividendidelt makstud tulumaks',ldc_deeb);
  select sum(gl_pr_saldoandmik.kreedit-gl_pr_saldoandmik.deebet) into ldc_deeb from gl_pr_saldoandmik where (left(konto,1)='7' and left(konto,6)<>'700002' and left(konto,6)<>'710002' and left(konto,6)<>'700030' and left(konto,6)<>'710030') or (left(konto,1)='1') and (left(ravo,2) in ('15','16')) or (left(konto,1)='2') and (left(ravo,2) in ('15','16','35','36'));
  insert into gl_tr_tabel(id,nimi,deeb) values (213,'   Netofinantseerimine eelarvest',ldc_deeb);

END