CREATE TABLE R5FLEXSQL ( 
    FLX_TABLE          VARCHAR( 32 )     NOT NULL,
    FLX_TRIGGER        VARCHAR( 32 )     NOT NULL,
    FLX_SEQ            NUMERIC( 38, 0 )  NOT NULL,
    FLX_STMT           NVARCHAR( 4000 ),
    FLX_ABORTONFAILURE NVARCHAR( 1 ),
    FLX_REVERSERETURN  NVARCHAR( 1 ),
    FLX_ACTIVE         NVARCHAR( 1 ),
    FLX_MSGFAILURE     NVARCHAR( 240 ),
    FLX_COMMENT        NVARCHAR( 240 ),
    FLX_MUSTEXIST      NVARCHAR( 1 ),
    FLX_UPDATECOUNT    NUMERIC( 38, 0 ),
    DMLTYPE            NVARCHAR( 1 )     DEFAULT ( 'N' ) 
);

INSERT INTO "R5LISTENTITY" VALUES ('BCFLEX',920,NULL,NULL,0,NULL,6,NULL,'R5FLEXSQL',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);

INSERT INTO R5SYSCOLUMNS (TABLE_NAME, COLUMN_NAME, PRIMARY_KEY, DMLTYPE) VALUES ('R5FLEXSQL', 'FLX_TABLE', '+', 'N');
INSERT INTO R5SYSCOLUMNS (TABLE_NAME, COLUMN_NAME, PRIMARY_KEY, DMLTYPE) VALUES ('R5FLEXSQL', 'FLX_TRIGGER', '+', 'N');
INSERT INTO R5SYSCOLUMNS (TABLE_NAME, COLUMN_NAME, PRIMARY_KEY, DMLTYPE) VALUES ('R5FLEXSQL', 'FLX_SEQ', '+', 'N');

insert into  r5configsettings (CFS_CODE,CFS_GROUP,CFS_USER,CFS_COMPTYPE,CFS_CONFIG,CFS_XMLCONFIG,CFS_UPDATED,CFS_DESK)
values('TCFLEX_IPAD','*','*','U',1, '{"sections":[{ "name":"Flex Business Rules", "fields":[{"id":"FLX_TABLE", "lbl":"Table", "type":"LOV-1", "def":"", "ro":"NO", "rq":"YES", "len":"30", "hid":"NO" }, {"id":"FLX_SEQ", "lbl":"Sequence Number", "type":"NUM", "def":"", "ro":"NO", "rq":"YES", "len":"30", "hid":"NO" }, {"id":"FLX_TRIGGER", "lbl":"Trigger", "type":"PICKER", "def":"", "ro":"NO", "rq":"YES", "len":"30", "hid":"NO" }, {"id":"FLX_STMT", "lbl":"SQL Statement", "type":"MEMO-1", "def":"", "ro":"NO", "rq":"YES", "len":"4000", "hid":"NO" }, {"id":"FLX_MSGFAILURE", "lbl":"Failure Message", "type":"CHAR", "def":"", "ro":"NO", "rq":"NO", "len":"240", "hid":"NO" }, {"id":"FLX_COMMENT", "lbl":"Comments", "type":"CHAR", "def":"", "ro":"NO", "rq":"NO", "len":"240", "hid":"NO" }, {"id":"FLX_ACTIVE", "lbl":"Active", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"NO" }, {"id":"FLX_ABORTONFAILURE", "lbl":"Abort on Failure", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"NO" },{"id":"FLX_MUSTEXIST", "lbl":"Must Exist", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"NO" }, {"id":"FLX_REVERSERETURN", "lbl":"Reverse Return Code", "type":"BOOL", "def":"", "ro":"NO", "rq":"NO", "len":"2", "hid":"NO" }]}]}',NULL,1);

INSERT INTO "R5LISTENTITY" VALUES('SCPHYS',921,NULL,NULL,NULL,NULL,3, 'SCPHYS','R5TRANSACTIONS',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES('SCPHYL',922,NULL,NULL,NULL,NULL,3, 'SCPHYS','R5STOCKTAKELINES',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);
INSERT INTO "R5LISTENTITY" VALUES ('SCPHYDEL',923,NULL,NULL,0,NULL,6, 'SCPHYS','R5STOCKTAKESDEL',NULL,NULL,NULL,'-','-',NULL,NULL,NULL);

ALTER TABLE R5TRANSACTIONS add "TRA_UPDATED" DATETIME;

UPDATE R5APPSETTINGS SET AST_VALUE = '11202' WHERE AST_NAME='DBVERSION';

INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Flex Business Rules', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Reglas de Flex Business', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Règles métier Flex', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Flex Geschäftsregeln', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Regole aziendali Flex', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'ﾌﾚｯｸｽﾋﾞｼﾞﾈｽ規則', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Flexbedrijfsregels', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Fleks forretningsregler', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Testar regras do Flex Business', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Бизнес-правила Flex', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , 'Flex affärsregler', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (681 , '灵活机动业务规则', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Post Insert', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Posterior a la inserción', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Après l''insertion', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Nach dem Einfügen (Post Insert)', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Successivo all''inserimento', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , '挿入後', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Na invoegen', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Etter registrering', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Pós-inserção', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'После вставки', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , 'Efter registrering', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (682 , '插入之后', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Post Update', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Posterior a la actualización', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Après la mise à jour', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Nach dem Aktualisieren (Post Update)', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Successivo all''aggiornamento', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , '更新後', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Na bijwerken', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Etter  oppdatering', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Pós-atualização', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'После обновления', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , 'Efter uppdatering', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (683 , '更新之后', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger SQL', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'ﾄﾘｶﾞ', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Utløser', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Ativador', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Триггер', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , 'Trigger', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (684 , '触发器', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Physical Inventory', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Inventario físico', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Stock physique', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Inventur', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Inventario fisico', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , '実地棚卸', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Fysieke voorraad', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Fysisk lagertelling', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Estoque físico', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Инвентаризация', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , 'Fysiskt lager', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (685 , '实际库存', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Physical Qty.', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Cantidad física', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Qté physique', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Inventurmenge', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Quantità fisica', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , '実地数量', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Fysieke hoeveelheid', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Fysisk ant.', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Quantidade física', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Фактическое кол-во', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , 'Fysisk kvant', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (686 , '实际数量', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Expected Qty.', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Cantidad esperada', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Qté attendue', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Erwartete Menge', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Quantità prevista', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , '予想数量', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Verwachte hoeveelheid', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Forventet ant.', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Quantidade prevista', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Предполагаемое кол-во', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , 'Förväntad kvant', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (687 , '预期数量', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Table', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabla', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Table', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabelle', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabella', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'ﾃｰﾌﾞﾙ', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabel', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabell', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabela', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Таблица', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , 'Tabell', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (688 , '表格', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Physical Qty. must be a number between 0 and 999999999999999999.999999', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'La Cantidad física debe ser un número entre 0 y 999999999999999999.999999.', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Qté physique doit être un nombre entre 0 et 999999999999999999,999999.', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , '''Inventurmenge'' muss eine Zahl zwischen 0 und 999999999999999999,999999 sein.', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Quantità fisica deve essere un numero compreso tra 0 e 999999999999999999,999999.', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , '実地数量は0と999999999999999999.999999間の数字にします。', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'de fysieke hoeveelheid moet een waarde zijn tussen 0 en 999999999999999999,999999.', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Fysisk antall må være et nummer mellom 999999999999999999.999999.', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'a quantidade física deve ser um número entre 0 e 999999999999999999,999999.', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Физическое Количество должно быть между 0 и 999999999999999999.999999.', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , 'Fysisk kvantitet måste vara ett tal mellan 0 och 999999999999999999,999999.', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (689 , '实际数量必须是介于 0 到 999999999999999999.999999 之间的数字。', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Download Physical Inventory', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Descargar inventario físico', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Télécharger Stock physique', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Inventur herunterladen', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Scarica inventario fisico', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , '実地棚卸をﾀﾞｳﾝﾛｰﾄﾞ', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Fys. voorraad downloaden', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Laster ned lagertelling', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Baixar estoque físico', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Загружать инвентаризации', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , 'Ladda ned fysiskt lager', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (690 , '下载实际库存', 'ZH');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'For Line', 'EN');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'P. línea', 'ES');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'P. Ligne', 'FR');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'Für Zeile', 'GE');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'Per riga', 'IT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , '項目', 'JP');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'Voor regel', 'NL');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'For rad', 'NO');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'P/ linha', 'PT');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'По строке', 'RU');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , 'För rad', 'SV');
 
INSERT INTO r5mobiletexts (mot_number, mot_text, mot_lang) VALUES (691 , '对于行', 'ZH');
