ТНВЭД
Материал из wiki.standart-n.ru
								Версия от 17:14, 17 августа 2018; Olgav  (обсуждение | вклад)
- Новая вспомогательная таблица TNVED
 
/******************************************************************************/
/***               Generated by IBExpert 16.08.2018 12:21:47                ***/
/******************************************************************************/
/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;
/******************************************************************************/
/***                                 Tables                                 ***/
/******************************************************************************/
CREATE TABLE TNVED (
    TNVEDCODE  DM_TEXT NOT NULL /* DM_TEXT = VARCHAR(250) */,
    BARCODE    DM_TEXT NOT NULL /* DM_TEXT = VARCHAR(250) */,
    SNAME      DM_TEXT NOT NULL /* DM_TEXT = VARCHAR(250) */
);
/******************************************************************************/
/***                              Primary keys                              ***/
/******************************************************************************/
ALTER TABLE TNVED ADD CONSTRAINT PK_TNVED PRIMARY KEY (TNVEDCODE, BARCODE, SNAME);
/******************************************************************************/
/***                                Indices                                 ***/
/******************************************************************************/
CREATE INDEX TNVED_IDX1 ON TNVED (TNVEDCODE);
CREATE INDEX TNVED_IDX2 ON TNVED (BARCODE);
CREATE INDEX TNVED_IDX3 ON TNVED (SNAME);
/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/
 
- Выполнить файл tnved.sql
 - Заполняем коды
 
update wares w set tnvedcode=(select first 1  t.tnvedcode from tnved t where t.barcode=w.barcode)  where  exists  (select first 1  t.tnvedcode from tnved t where t.barcode=w.barcode);
update wares w set tnvedcode=(select first 1  t.tnvedcode from tnved t where t.sname=w.sname) where  exists  (select first 1  t.tnvedcode from tnved t where t.sname=w.sname) and coalesce(trim(w.tnvedcode),'')='';
update wares w set tnvedcode=(select first 1 ww.tnvedcode from wares ww where ww.name_id=w.name_id and ww.tnvedcode is not null )  where exists  (select first 1 ww.tnvedcode from wares ww  where ww.name_id=w.name_id and ww.tnvedcode is not null )  and w.tnvedcode is null;
EXECUTE BLOCK
AS
declare variable b dm_text;
declare variable t dm_text;
declare variable ware_id dm_uuid;
BEGIN
  for select t.barcode,t.tnvedcode from tnved t into :b,:t do
  begin
    update wares set tnvedcode=:t where barcode containing :b and tnvedcode is null;
  end
END;
 
- Обновить менеджер до версии не ниже 273.71