text: /**
   * Author:  robson.costa
   * Created: 19/06/2020
   */
  
  -- TABELA "AUXLIAR", com todos os NCMS já USADOS pela AG
  DROP TABLE IF EXISTS TODOS_NCMS_USADOS;
  
  CREATE TABLE IF NOT EXISTS TODOS_NCMS_USADOS(
      CODIGO INT(11) AUTO_INCREMENT NOT NULL,
      NCM INT(11) NOT NULL,
      EXCECAO INT(11) DEFAULT 0 NOT NULL,
      PRIMARY KEY(CODIGO)
  );
  
  -- IMPORTANTEN DE LEMBRAR QUE ALGUNS NCMS PODEM TER MAIS DE UMA EXCECAO, 
  -- E alguma dela na VENDA PODERÁ NÃO SER MONOFASICA
  -- LEMBRA DISSO QUANDO CRIAR A PROCEDURE PARA CADASTRAR AAS TRIBUTACOES para TESTE NO EMISSOR
  
  INSERT INTO TODOS_NCMS_USADOS (NCM)
      VALUES 
  	(12089000),
  	(15079011),
  	(15091000),
  	(15171000),
  	(15211000),
  	(17019900),
  	(22019000),
  	(22030000),
  	(22041090),
  	(22042100),
  	(22071000),
  	(22071090),
  	(22084000),
  	(22090000),
  	(25010020),
  	(25041000),
  	(27011932),
  	(27075000),
  	(27075010),
  	(27100062),
  	(27101149),
  	(27101160),
  	(27101249),
  	(27101919),
  	(27101921),
  	(27101931),
  	(27101932),
  	(27101991),
  	(27101992),
  	(27101999),
  	(27129000),
  	(27150000),
  	(28070010),
  	(28112230),
  	(28112990),
  	(28151100),
  	(28182090),
  	(28289011),
  	(28391900),
  	(28530090),
  	(28539090),
  	(29011000),
  	(29012900),
  	(29021100),
  	(29031200),
  	(29032200),
  	(29032300),
  	(29032900),
  	(29051100),
  	(29051210),
  	(29051220),
  	(29161520),
  	(29213090),
  	(29269096),
  	(29280042),
  	(29309041),
  	(31021010),
  	(32050000),
  	(32073000),
  	(32081010),
  	(32082019),
  	(32089010),
  	(32091010),
  	(32141010),
  	(32141020),
  	(32159000),
  	(33029019),
  	(33074900),
  	(34011190),
  	(34011900),
  	(34013000),
  	(34021190),
  	(34021900),
  	(34022000),
  	(34029019),
  	(34029029),
  	(34029031),
  	(34029039),
  	(34029090),
  	(34031900),
  	(34052000),
  	(34053000),
  	(34054000),
  	(34059000),
  	(35061010),
  	(35061090),
  	(35069110),
  	(35069120),
  	(35069190),
  	(35069900),
  	(36050000),
  	(36263000),
  	(37172200),
  	(38012000),
  	(38089411),
  	(38089419),
  	(38089429),
  	(38089999),
  	(38099190),
  	(38101010),
  	(38109000),
  	(38112150),
  	(38112151),
  	(38112190),
  	(38119010),
  	(38119090),
  	(38140000),
  	(38140090),
  	(38151210),
  	(38190000),
  	(38200000),
  	(38247190),
  	(38249019),
  	(38249041),
  	(38249049),
  	(38249079),
  	(38249929),
  	(38249941),
  	(39019030),
  	(39021010),
  	(39021020),
  	(39022100),
  	(39031110),
  	(39060001),
  	(39061000),
  	(39062000),
  	(39071049),
  	(39100012),
  	(39100013),
  	(39100019),
  	(39100090),
  	(39162000),
  	(39162002),
  	(39172200),
  	(39172300),
  	(39172900),
  	(39173100),
  	(39173229),
  	(39173240),
  	(39173290),
  	(39173300),
  	(39173900),
  	(39174090),
  	(39177300),
  	(39190000),
  	(39191000),
  	(39191010),
  	(39191020),
  	(39191090),
  	(39199000),
  	(39199010),
  	(39199090),
  	(39204390),
  	(39209990),
  	(39211390),
  	(39229000),
  	(39231090),
  	(39232190),
  	(39232910),
  	(39232990),
  	(39233000),
  	(39235000),
  	(39241000),
  	(39249000),
  	(39251000),
  	(39261000),
  	(39263000),
  	(39269010),
  	(39269021),
  	(39269061),
  	(39269090),
  	(39290060),
  	(40021110),
  	(40040000),
  	(40051090),
  	(40059190),
  	(40069000),
  	(40081100),
  	(40081199),
  	(40081900),
  	(40082100),
  	(40082900),
  	(40091100),
  	(40091210),
  	(40091290),
  	(40092190),
  	(40093000),
  	(40093090),
  	(40093100),
  	(40093210),
  	(40093290),
  	(40094100),
  	(40094101),
  	(40094210),
  	(40094290),
  	(40099100),
  	(40102300),
  	(40103100),
  	(40103200),
  	(40103300),
  	(40103400),
  	(40103500),
  	(40103600),
  	(40103900),
  	(40111000),
  	(40114000),
  	(40121900),
  	(40137777),
  	(40139000),
  	(40139300),
  	(40139600),
  	(40151900),
  	(40161010),
  	(40161090),
  	(40163900),
  	(40169000),
  	(40169200),
  	(40169300),
  	(40169399),
  	(40169900),
  	(40169903),
  	(40169990),
  	(40170000),
  	(40208572),
  	(41103100),
  	(42021210),
  	(42022900),
  	(42029200),
  	(42050000),
  	(44082900),
  	(44151000),
  	(44219000),
  	(44219900),
  	(45041000),
  	(45049000),
  	(45099000),
  	(48025510),
  	(48025610),
  	(48025699),
  	(48059300),
  	(48111090),
  	(48114110),
  	(48114190),
  	(48116090),
  	(48119010),
  	(48171000),
  	(48181000),
  	(48182000),
  	(48183000),
  	(48189090),
  	(48191000),
  	(48201000),
  	(48202000),
  	(48204000),
  	(48209000),
  	(48211000),
  	(48219000),
  	(48232099),
  	(48234000),
  	(48239005),
  	(48239099),
  	(49089000),
  	(49111090),
  	(50090000),
  	(51021000),
  	(51022000),
  	(52021000),
  	(52029900),
  	(52105990),
  	(53013000),
  	(54089990),
  	(56029000),
  	(56041000),
  	(56075090),
  	(57050000),
  	(57055000),
  	(57059000),
  	(57083090),
  	(58063200),
  	(59031099),
  	(59090000),
  	(59119000),
  	(61091000),
  	(62104000),
  	(63071000),
  	(63079010),
  	(63079090),
  	(63090090),
  	(64019200),
  	(65061000),
  	(68051000),
  	(68051001),
  	(68052000),
  	(68053090),
  	(68069090),
  	(68083019),
  	(68129010),
  	(68129910),
  	(68131002),
  	(68131010),
  	(68131090),
  	(68138190),
  	(68139010),
  	(68139090),
  	(68139190),
  	(68149000),
  	(68159990),
  	(69131010),
  	(70071100),
  	(70072100),
  	(70091000),
  	(70091090),
  	(70099100),
  	(70140000),
  	(70202010),
  	(71179000),
  	(72012000),
  	(72089000),
  	(72099000),
  	(72141010),
  	(72149910),
  	(72150000),
  	(72151000),
  	(72221100),
  	(72269200),
  	(72269900),
  	(72283000),
  	(73030000),
  	(73061900),
  	(73069010),
  	(73069090),
  	(73071920),
  	(73071990),
  	(73079100),
  	(73079200),
  	(73079900),
  	(73089010),
  	(73121090),
  	(73129000),
  	(73151210),
  	(73151290),
  	(73161000),
  	(73170020),
  	(73170090),
  	(73181000),
  	(73181100),
  	(73181200),
  	(73181400),
  	(73181500),
  	(73181599),
  	(73181600),
  	(73181800),
  	(73181900),
  	(73182000),
  	(73182100),
  	(73182200),
  	(73182300),
  	(73182400),
  	(73182900),
  	(73201000),
  	(73201009),
  	(73201010),
  	(73202010),
  	(73202090),
  	(73209000),
  	(73209001),
  	(73209090),
  	(73212100),
  	(73231000),
  	(73241000),
  	(73251000),
  	(73259100),
  	(73259910),
  	(73259990),
  	(73261900),
  	(73269000),
  	(73269090),
  	(73452900),
  	(74122000),
  	(74149910),
  	(74152100),
  	(74152900),
  	(74153300),
  	(74153900),
  	(74199990),
  	(75152100),
  	(75181500),
  	(76042920),
  	(76071190),
  	(76082090),
  	(76090000),
  	(76161000),
  	(76169900),
  	(76199900),
  	(77283000),
  	(79070090),
  	(80011000),
  	(80499117),
  	(81130010),
  	(81819090),
  	(81829990),
  	(81849090),
  	(82015000),
  	(82021000),
  	(82022000),
  	(82032010),
  	(82033020),
  	(82041100),
  	(82041200),
  	(82054000),
  	(82055900),
  	(82057000),
  	(82073000),
  	(82075011),
  	(82077090),
  	(82090011),
  	(82090019),
  	(82119390),
  	(82130000),
  	(82151000),
  	(82589990),
  	(83011000),
  	(83012000),
  	(83016000),
  	(83021000),
  	(83022300),
  	(83023000),
  	(83052000),
  	(83059000),
  	(83071090),
  	(83079000),
  	(83099000),
  	(83100000),
  	(84031010),
  	(84033020),
  	(84073490),
  	(84082912),
  	(84089990),
  	(84093029),
  	(84095090),
  	(84098099),
  	(84099100),
  	(84099111),
  	(84099112),
  	(84099113),
  	(84099114),
  	(84099115),
  	(84099116),
  	(84099117),
  	(84099118),
  	(84099120),
  	(84099130),
  	(84099140),
  	(84099160),
  	(84099190),
  	(84099196),
  	(84099901),
  	(84099911),
  	(84099912),
  	(84099913),
  	(84099914),
  	(84099915),
  	(84099916),
  	(84099917),
  	(84099920),
  	(84099929),
  	(84099930),
  	(84099949),
  	(84099951),
  	(84099959),
  	(84099961),
  	(84099969),
  	(84099979),
  	(84099990),
  	(84099991),
  	(84099999),
  	(84122110),
  	(84122190),
  	(84123110),
  	(84129080),
  	(84131090),
  	(84131900),
  	(84132000),
  	(84133010),
  	(84133020),
  	(84133030),
  	(84133090),
  	(84133330),
  	(84135019),
  	(84135090),
  	(84136011),
  	(84136019),
  	(84136090),
  	(84137010),
  	(84137080),
  	(84137090),
  	(84138100),
  	(84139090),
  	(84139100),
  	(84139190),
  	(84141000),
  	(84142000),
  	(84145990),
  	(84148019),
  	(84148021),
  	(84148029),
  	(84149000),
  	(84149010),
  	(84149020),
  	(84149032),
  	(84149033),
  	(84149034),
  	(84149039),
  	(84152090),
  	(84195021),
  	(84195090),
  	(84211000),
  	(84212100),
  	(84212300),
  	(84212990),
  	(84212999),
  	(84213020),
  	(84213100),
  	(84213920),
  	(84213990),
  	(84219090),
  	(84219091),
  	(84219910),
  	(84219990),
  	(84219999),
  	(84222090),
  	(84241000),
  	(84242000),
  	(84243010),
  	(84248990),
  	(84249090),
  	(84254200),
  	(84254910),
  	(84279000),
  	(84282090),
  	(84312011),
  	(84312090),
  	(84314200),
  	(84314929),
  	(84329000),
  	(84339090),
  	(84344090),
  	(84388090),
  	(84433239),
  	(84433299),
  	(84571000),
  	(84581199),
  	(84609019),
  	(84661000),
  	(84662010),
  	(84662090),
  	(84669330),
  	(84669410),
  	(84671110),
  	(84672999),
  	(84701000),
  	(84713019),
  	(84715010),
  	(84716052),
  	(84716053),
  	(84716059),
  	(84717010),
  	(84717012),
  	(84719012),
  	(84729040),
  	(84798999),
  	(84799090),
  	(84811000),
  	(84811010),
  	(84811100),
  	(84812022),
  	(84812090),
  	(84813000),
  	(84813030),
  	(84813090),
  	(84814000),
  	(84818019),
  	(84818021),
  	(84818022),
  	(84818029),
  	(84818090),
  	(84818092),
  	(84818096),
  	(84818099),
  	(84819090),
  	(84821010),
  	(84821090),
  	(84822010),
  	(84822090),
  	(84822096),
  	(84822400),
  	(84824000),
  	(84824090),
  	(84825010),
  	(84825090),
  	(84828000),
  	(84829119),
  	(84829120),
  	(84829190),
  	(84829900),
  	(84829910),
  	(84829990),
  	(84830509),
  	(84831010),
  	(84831019),
  	(84831020),
  	(84831030),
  	(84831090),
  	(84832000),
  	(84832090),
  	(84832919),
  	(84833010),
  	(84833020),
  	(84833021),
  	(84833029),
  	(84833090),
  	(84833190),
  	(84833200),
  	(84833900),
  	(84834010),
  	(84834090),
  	(84835000),
  	(84835010),
  	(84835090),
  	(84836019),
  	(84836090),
  	(84838029),
  	(84838090),
  	(84839000),
  	(84841000),
  	(84842000),
  	(84842010),
  	(84848021),
  	(84849000),
  	(84849190),
  	(84859000),
  	(84879000),
  	(84893020),
  	(85011011),
  	(85011019),
  	(85013110),
  	(85014029),
  	(85043000),
  	(85044010),
  	(85044040),
  	(85045000),
  	(85052090),
  	(85059080),
  	(85071000),
  	(85071010),
  	(85071090),
  	(85081100),
  	(85085090),
  	(85110000),
  	(85111000),
  	(85111019),
  	(85111100),
  	(85112090),
  	(85113001),
  	(85113010),
  	(85113020),
  	(85115010),
  	(85115039),
  	(85115090),
  	(85118010),
  	(85118020),
  	(85118030),
  	(85118090),
  	(85118099),
  	(85119000),
  	(85119099),
  	(85122011),
  	(85122012),
  	(85122019),
  	(85122021),
  	(85122022),
  	(85122023),
  	(85122029),
  	(85122061),
  	(85122099),
  	(85122900),
  	(85123000),
  	(85123038),
  	(85124010),
  	(85129000),
  	(85129009),
  	(85131010),
  	(85139000),
  	(85143019),
  	(85171231),
  	(85171899),
  	(85176239),
  	(85176262),
  	(85176294),
  	(85177010),
  	(85177091),
  	(85183000),
  	(85189090),
  	(85191019),
  	(85219999),
  	(85234011),
  	(85235200),
  	(85271990),
  	(85272100),
  	(85272900),
  	(85291019),
  	(85291090),
  	(85311090),
  	(85322590),
  	(85322990),
  	(85334091),
  	(85361000),
  	(85364100),
  	(85365090),
  	(85366100),
  	(85369090),
  	(85385090),
  	(85389090),
  	(85391010),
  	(85392110),
  	(85392190),
  	(85392910),
  	(85392990),
  	(85393100),
  	(85395000),
  	(85432000),
  	(85437099),
  	(85443000),
  	(85444100),
  	(85444200),
  	(85444900),
  	(85452000),
  	(85459090),
  	(85481010),
  	(86072100),
  	(87022300),
  	(87032100),
  	(87033110),
  	(87039000),
  	(87042110),
  	(87042390),
  	(87043190),
  	(87059990),
  	(87060090),
  	(87066090),
  	(87071000),
  	(87079990),
  	(87080000),
  	(87081000),
  	(87081010),
  	(87081999),
  	(87082100),
  	(87082300),
  	(87082900),
  	(87082904),
  	(87082911),
  	(87082912),
  	(87082913),
  	(87082919),
  	(87082990),
  	(87082991),
  	(87082992),
  	(87082993),
  	(87082994),
  	(87082998),
  	(87082999),
  	(87083011),
  	(87083019),
  	(87083090),
  	(87083190),
  	(87083900),
  	(87083902),
  	(87083919),
  	(87083990),
  	(87083999),
  	(87084000),
  	(87084019),
  	(87084090),
  	(87084099),
  	(87085010),
  	(87085011),
  	(87085012),
  	(87085019),
  	(87085036),
  	(87085080),
  	(87085090),
  	(87085091),
  	(87085099),
  	(87086090),
  	(87087010),
  	(87087090),
  	(87087999),
  	(87088000),
  	(87088010),
  	(87088399),
  	(87088800),
  	(87088900),
  	(87088990),
  	(87088999),
  	(87089000),
  	(87089001),
  	(87089009),
  	(87089030),
  	(87089090),
  	(87089100),
  	(87089190),
  	(87089200),
  	(87089300),
  	(87089390),
  	(87089400),
  	(87089401),
  	(87089411),
  	(87089412),
  	(87089422),
  	(87089481),
  	(87089482),
  	(87089483),
  	(87089485),
  	(87089490),
  	(87089491),
  	(87089492),
  	(87089493),
  	(87089899),
  	(87089900),
  	(87089904),
  	(87089906),
  	(87089910),
  	(87089911),
  	(87089930),
  	(87089980),
  	(87089982),
  	(87089990),
  	(87089992),
  	(87089999),
  	(87092900),
  	(87094090),
  	(87099099),
  	(87099130),
  	(87099300),
  	(87099990),
  	(87112020),
  	(87120010),
  	(87141000),
  	(87141900),
  	(87149990),
  	(87169000),
  	(87169010),
  	(87169090),
  	(87169990),
  	(87849000),
  	(87899990),
  	(89089990),
  	(89269090),
  	(89833029),
  	(90251190),
  	(90251990),
  	(90258000),
  	(90259090),
  	(90261019),
  	(90261021),
  	(90261029),
  	(90261090),
  	(90262010),
  	(90262090),
  	(90269090),
  	(90271000),
  	(90291010),
  	(90303321),
  	(90318090),
  	(90318099),
  	(90321010),
  	(90321090),
  	(90328095),
  	(90328911),
  	(90328924),
  	(90328925),
  	(90328929),
  	(90328982),
  	(90329091),
  	(90329099),
  	(91040000),
  	(92062010),
  	(94012000),
  	(94019090),
  	(94032000),
  	(94054090),
  	(94099116),
  	(94099190),
  	(96031000),
  	(96039000),
  	(96081000),
  	(96082000),
  	(96091000),
  	(96100000),
  	(96121090),
  	(96122000),
  	(96138000),
  	(97089300),
  	(99999999),
  	(39259000),
  	(85112010),
  	(85340000),
  	(40119290),
  	(25049000),
  	(85235290),
  	(32151100),
  	(95063200),
  	(84224090),
  	(82141000),
  	(39011092),
  	(61046900),
  	(61130000),
  	(73072200),
  	(48042100),
  	(84433100),
  	(85061010),
  	(27111910),
  	(84918099),
  	(34012090),
  	(62052000),
  	(38089119),
  	(42023200),
  	(62046300),
  	(48022010),
  	(85176266),
  	(82119400),
  	(48101990),
  	(32082011),
  	(85393900),
  	(39233090),
  	(84099900),
  	(83040000),
  	(85044030),
  	(96110000),
  	(73072900),
  	(48025892),
  	(39269069),
  	(82119290),
  	(42021220),
  	(44191100),
  	(82119100),
  	(84433114),
  	(90269010),
  	(61161000),
  	(39211200),
  	(62045300),
  	(85163300),
  	(39264000),
  	(39239000),
  	(95051000),
  	(48237000),
  	(33049990),
  	(69051000),
  	(85061020),
  	(90303319),
  	(31052000),
  	(85258029),
  	(73144100),
  	(56079010),
  	(44039900),
  	(42021900),
  	(42032900),
  	(85171219),
  	(85013220),
  	(85079020),
  	(76071990),
  	(84796000),
  	(84797900),
  	(57039000),
  	(57033000),
  	(49100000),
  	(82119320),
  	(73102990),
  	(67021000),
  	(87149490),
  	(39172100),
  	(19022000),
  	(19023000),
  	(38089192),
  	(38089319),
  	(27079990),
  	(63026000),
  	(65050019),
  	(82060000),
  	(76151000),
  	(10063021),
  	(84733039),
  	(85014019),
  	(87033310),
  	(85166000),
  	(90189099),
  	(20096100),
  	(16010000),
  	(90251110),
  	(39269040),
  	(87139000),
  	(30051090),
  	(30067000),
  	(90049020),
  	(90211010),
  	(30049043),
  	(90183921),
  	(28470000),
  	(30059090),
  	(85287200),
  	(85061019),
  	(84801000),
  	(73071100),
  	(85311010),
  	(85334011),
  	(70109011),
  	(10062020),
  	(17011400),
  	(20081900),
  	(11010010),
  	(19053200),
  	(20057000),
  	(84733011),
  	(94017900),
  	(56031240),
  	(62101000),
  	(21050010);
  