$set callfh"extmysql" ASSIGN"EXTERNAL" *************************************************************************** * IMEDIATA INFORMATICA EMPRESARIAL LTDA * * PROGRAMA - Testa compatibilidade entre diversos tipos e tamanhos de * * campo. * * Ao final do programa vc encontra o script para criar a * * tabela correspondente a FD usada pelo programa. * *************************************************************************** IDENTIFICATION DIVISION. PROGRAM-ID. TSMYSQL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. call-convention 66 is WINAPI. INPUT-OUTPUT SECTION. FILE-CONTROL. $set fcdreg SELECT MYSQLTST ASSIGN TO DYNAMIC W-ARQUIVOS ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS MY-CHA ALTERNATE RECORD KEY IS MY-LNCDT = MY-CHA MY-DATA WITH DUPLICATES LOCK MODE IS AUTOMATIC FILE STATUS IS ESTADO. DATA DIVISION. FILE SECTION. FD MYSQLTST. 01 MY-REG. 03 MY-SIT PIC X(01). 03 MY-CHA PIC S9(05) COMP-3. 03 MY-LIMPA. 05 MY-DATA PIC 9(09) COMP-3. 05 MY-CMPX01N PIC 9(01) COMP-X. 05 MY-CMPX02N PIC 9(02) COMP-X. 05 MY-CMPX03N PIC 9(03) COMP-X. 05 MY-CMPX04N PIC 9(04) COMP-X. 05 MY-CMPX05N PIC 9(05) COMP-X. 05 MY-CMPX06N PIC 9(06) COMP-X. 05 MY-CMPX07N PIC 9(07) COMP-X. 05 MY-CMPX08N PIC 9(08) COMP-X. 05 MY-CMPX09N PIC 9(09) COMP-X. 05 MY-CMPX10N PIC 9(10) COMP-X. 05 MY-CMPX11N PIC 9(11) COMP-X. 05 MY-CMPX12N PIC 9(12) COMP-X. 05 MY-CMPX13N PIC 9(13) COMP-X. 05 MY-CMPX14N PIC 9(14) COMP-X. 05 MY-CMPX15N PIC 9(15) COMP-X. 05 MY-CMPX16N PIC 9(16) COMP-X. 05 MY-CMPX17N PIC 9(17) COMP-X. 05 MY-CMPX18N PIC 9(18) COMP-X. 05 MY-CMP301N PIC 9(01) COMP-3. 05 MY-CMP302N PIC 9(02) COMP-3. 05 MY-CMP303N PIC 9(03) COMP-3. 05 MY-CMP304N PIC 9(04) COMP-3. 05 MY-CMP305N PIC 9(05) COMP-3. 05 MY-CMP306N PIC 9(06) COMP-3. 05 MY-CMP307N PIC 9(07) COMP-3. 05 MY-CMP308N PIC 9(08) COMP-3. 05 MY-CMP309N PIC 9(09) COMP-3. 05 MY-CMP310N PIC 9(10) COMP-3. 05 MY-CMP311N PIC 9(11) COMP-3. 05 MY-CMP312N PIC 9(12) COMP-3. 05 MY-CMP313N PIC 9(13) COMP-3. 05 MY-CMP314N PIC 9(14) COMP-3. 05 MY-CMP315N PIC 9(15) COMP-3. 05 MY-CMP316N PIC 9(16) COMP-3. 05 MY-CMP317N PIC 9(17) COMP-3. 05 MY-CMP318N PIC 9(18) COMP-3. 05 MY-CMP301S PIC S9(01) COMP-3. 05 MY-CMP302S PIC S9(02) COMP-3. 05 MY-CMP303S PIC S9(03) COMP-3. 05 MY-CMP304S PIC S9(04) COMP-3. 05 MY-CMP305S PIC S9(05) COMP-3. 05 MY-CMP306S PIC S9(06) COMP-3. 05 MY-CMP307S PIC S9(07) COMP-3. 05 MY-CMP308S PIC S9(08) COMP-3. 05 MY-CMP309S PIC S9(09) COMP-3. 05 MY-CMP310S PIC S9(10) COMP-3. 05 MY-CMP311S PIC S9(11) COMP-3. 05 MY-CMP312S PIC S9(12) COMP-3. 05 MY-CMP313S PIC S9(13) COMP-3. 05 MY-CMP314S PIC S9(14) COMP-3. 05 MY-CMP315S PIC S9(15) COMP-3. 05 MY-CMP316S PIC S9(16) COMP-3. 05 MY-CMP317S PIC S9(17) COMP-3. 05 MY-CMP318S PIC S9(18) COMP-3. 05 MY-CMP501N PIC 9(01) COMP-5. 05 MY-CMP502N PIC 9(02) COMP-5. 05 MY-CMP503N PIC 9(03) COMP-5. 05 MY-CMP504N PIC 9(04) COMP-5. 05 MY-CMP505N PIC 9(05) COMP-5. 05 MY-CMP506N PIC 9(06) COMP-5. 05 MY-CMP507N PIC 9(07) COMP-5. 05 MY-CMP508N PIC 9(08) COMP-5. 05 MY-CMP509N PIC 9(09) COMP-5. 05 MY-CMP510N PIC 9(10) COMP-5. 05 MY-CMP511N PIC 9(11) COMP-5. 05 MY-CMP512N PIC 9(12) COMP-5. 05 MY-CMP513N PIC 9(13) COMP-5. 05 MY-CMP514N PIC 9(14) COMP-5. 05 MY-CMP515N PIC 9(15) COMP-5. 05 MY-CMP516N PIC 9(16) COMP-5. 05 MY-CMP517N PIC 9(17) COMP-5. 05 MY-CMP518N PIC 9(18) COMP-5. 05 MY-CMP501S PIC S9(01) COMP-5. 05 MY-CMP502S PIC S9(02) COMP-5. 05 MY-CMP503S PIC S9(03) COMP-5. 05 MY-CMP504S PIC S9(04) COMP-5. 05 MY-CMP505S PIC S9(05) COMP-5. 05 MY-CMP506S PIC S9(06) COMP-5. 05 MY-CMP507S PIC S9(07) COMP-5. 05 MY-CMP508S PIC S9(08) COMP-5. 05 MY-CMP509S PIC S9(09) COMP-5. 05 MY-CMP510S PIC S9(10) COMP-5. 05 MY-CMP511S PIC S9(11) COMP-5. 05 MY-CMP512S PIC S9(12) COMP-5. 05 MY-CMP513S PIC S9(13) COMP-5. 05 MY-CMP514S PIC S9(14) COMP-5. 05 MY-CMP515S PIC S9(15) COMP-5. 05 MY-CMP516S PIC S9(16) COMP-5. 05 MY-CMP517S PIC S9(17) COMP-5. 05 MY-CMP518S PIC S9(18) COMP-5. WORKING-STORAGE SECTION. 77 W-CMD PIC X(64000) VALUE SPACES. 77 W-CONT1 PIC 9(05) COMP-5. 77 W-CT1 PIC 9(07) COMP-5. 77 W-CT2 PIC 9(07) COMP-5. 77 W-CT3 PIC 9(07) COMP-5. 77 W-LIN PIC X(79). 78 REG-LEN VALUE LENGTH OF MY-REG. 77 W-RGS PIC X(REG-LEN). 77 W-ARQUIVOS PIC X(128) VALUE *> Z"@10.0.0.8@3306@root@@imed@estcad". Z"@127.0.0.1@3306@root@@test@mysqltst". 01 ESTADO PIC X(02). 88 STAT-ERRO VALUE X"3100" THRU X"3943" X"3945" THRU X"39EE". 88 DUPLICADO VALUE "22". 88 CRIAR-ARQUIVO VALUE X"3335" X"3913". 88 JA-ABERTO VALUE "41" X"398D". 88 REINDEXAR VALUE X"3929" X"3912". 88 ESTA-ABERTO VALUE "12". 88 FOI-CRIADO VALUE "05". 88 NAO-ENCONTRADO VALUE "23". 88 FINAL-ARQUIVO VALUE "10". 88 CHAVE-DUPLICADA VALUE "02". 01 RESTADO REDEFINES ESTADO. 02 ST-K01 PIC X(01). 02 ST-K02 PIC X(01). 02 RST-K02 REDEFINES ST-K02. 03 ST-ERR PIC 9(02) COMP-X. 78 TAMANHO-FD VALUE LENGTH OF MY-REG. 01 WORKING-FD PIC X(TAMANHO-FD). LINKAGE SECTION. PROCEDURE DIVISION. PRINCIPAL. DISPLAY ERASE. OPEN I-O MYSQLTST IF ESTADO > "09" DISPLAY "Abrindo TABTST " ESTADO GO TO STATUS-ERRO. MOVE 1 TO MY-CHA. PERFORM INICIALIZA-REG. MOVE MY-REG TO WORKING-FD. WRITE MY-REG INVALID KEY DISPLAY "INVALID-KEY.". MOVE 1 TO MY-CHA. READ MYSQLTST. IF MY-REG NOT = WORKING-FD DISPLAY "Erro nas definições". INITIALIZE MY-LIMPA. MOVE ZEROS TO MY-DATA. WRITE MY-REG. READ MYSQLTST. PERFORM INICIALIZA-REG. MOVE MY-REG TO W-RGS. REWRITE MY-REG. MOVE 1 TO MY-CHA. READ MYSQLTST. IF MY-REG NOT = W-RGS DISPLAY "Tem erro na rotina" STOP " Tecle return ". MOVE 20131231 TO MY-DATA. REWRITE MY-REG. MOVE ZEROS TO MY-DATA. CLOSE MYSQLTST. STOP RUN. INICIALIZA-REG. MOVE ZEROS TO MY-DATA. MOVE 9 TO MY-CMP301N MOVE 91 TO MY-CMP302N MOVE 919 TO MY-CMP303N MOVE 9199 TO MY-CMP304N MOVE 91999 TO MY-CMP305N MOVE 919999 TO MY-CMP306N MOVE 9199999 TO MY-CMP307N MOVE 91999999 TO MY-CMP308N MOVE 919999999 TO MY-CMP309N MOVE 9199999999 TO MY-CMP310N MOVE 91999999999 TO MY-CMP311N MOVE 919999999999 TO MY-CMP312N MOVE 9199999999999 TO MY-CMP313N MOVE 91999999999999 TO MY-CMP314N MOVE 919999999999999 TO MY-CMP315N MOVE 9199999999999999 TO MY-CMP316N MOVE 91999999999999999 TO MY-CMP317N MOVE 919999999999999999 TO MY-CMP318N MOVE -9 TO MY-CMP301S MOVE -91 TO MY-CMP302S MOVE -919 TO MY-CMP303S MOVE -9199 TO MY-CMP304S MOVE -91999 TO MY-CMP305S MOVE -919999 TO MY-CMP306S MOVE -9199999 TO MY-CMP307S MOVE -91999999 TO MY-CMP308S MOVE -919999999 TO MY-CMP309S MOVE -9199999999 TO MY-CMP310S MOVE -91999999999 TO MY-CMP311S MOVE -919999999999 TO MY-CMP312S MOVE -9199999999999 TO MY-CMP313S MOVE -91999999999999 TO MY-CMP314S MOVE -919999999999999 TO MY-CMP315S MOVE -9199999999999999 TO MY-CMP316S MOVE -91999999999999999 TO MY-CMP317S MOVE -919999999999999999 TO MY-CMP318S MOVE 9 TO MY-CMP501N MOVE 9 TO MY-CMP502N MOVE 91 TO MY-CMP503N MOVE 919 TO MY-CMP504N MOVE 9199 TO MY-CMP505N MOVE 91999 TO MY-CMP506N MOVE 919999 TO MY-CMP507N MOVE 9199999 TO MY-CMP508N MOVE 99199999 TO MY-CMP509N MOVE 919999999 TO MY-CMP510N MOVE 9199999999 TO MY-CMP511N MOVE 91999999999 TO MY-CMP512N MOVE 919999999999 TO MY-CMP513N MOVE 9199999999999 TO MY-CMP514N MOVE 91999999999999 TO MY-CMP515N MOVE 919999999999999 TO MY-CMP516N MOVE 9199999999999999 TO MY-CMP517N MOVE 91999999999999999 TO MY-CMP518N MOVE -9 TO MY-CMP501S MOVE -9 TO MY-CMP502S MOVE -91 TO MY-CMP503S MOVE -919 TO MY-CMP504S MOVE -9199 TO MY-CMP505S MOVE -91999 TO MY-CMP506S MOVE -919999 TO MY-CMP507S MOVE -9199999 TO MY-CMP508S MOVE -91999999 TO MY-CMP509S MOVE -919999999 TO MY-CMP510S MOVE -9199999999 TO MY-CMP511S MOVE -91999999999 TO MY-CMP512S MOVE -919999999999 TO MY-CMP513S MOVE -9199999999999 TO MY-CMP514S MOVE -91999999999999 TO MY-CMP515S MOVE -919999999999999 TO MY-CMP516S MOVE -9199999999999999 TO MY-CMP517S MOVE -91999999999999999 TO MY-CMP518S MOVE 9 TO MY-CMPX01N MOVE 91 TO MY-CMPX02N MOVE 919 TO MY-CMPX03N MOVE 9199 TO MY-CMPX04N MOVE 91999 TO MY-CMPX05N MOVE 919999 TO MY-CMPX06N MOVE 9199999 TO MY-CMPX07N MOVE 91999999 TO MY-CMPX08N MOVE 919999999 TO MY-CMPX09N MOVE 9199999999 TO MY-CMPX10N MOVE 91999999999 TO MY-CMPX11N MOVE 919999999999 TO MY-CMPX12N MOVE 9199999999999 TO MY-CMPX13N MOVE 91999999999999 TO MY-CMPX14N MOVE 919999999999999 TO MY-CMPX15N MOVE 9199999999999999 TO MY-CMPX16N MOVE 91999999999999999 TO MY-CMPX17N MOVE 919999999999999999 TO MY-CMPX18N. STATUS-ERRO. CALL "GetLstMsgErr" USING W-CMD. *> Demonstra como monitorar o erro MOVE ZEROS TO W-CONT1. INSPECT W-CMD TALLYING W-CONT1 FOR CHARACTERS BEFORE X"00". IF W-CONT1 > ZEROS IF W-CMD (1:W-CONT1) NOT = SPACES PERFORM VARYING W-CT1 FROM 1 BY 80 UNTIL W-CT1 > W-CONT1 MOVE W-CMD (W-CT1:W-CONT1) TO W-LIN IF W-LIN NOT = SPACES DISPLAY W-LIN ELSE MOVE W-CONT1 TO W-CT1 ADD 1 TO W-CT1 END-IF END-PERFORM END-IF END-IF. IF ST-K01 = "9" EVALUATE ST-ERR WHEN 27 DISPLAY "Access denied for DB/user" WHEN 48 DISPLAY "Heap access failure - out of buffer" WHEN 49 DISPLAY "Heap deallocated while program inactive" WHEN 50 DISPLAY "Backing-file failure: too many files" WHEN 51 DISPLAY "Backing-file failure: file access denied" WHEN 52 DISPLAY "Backing-file failure: I/O failure" WHEN 04 DISPLAY "Nao encontrou no DB tabela procurada - Illeg - "al file name." WHEN 200 DISPLAY "Erro com a execucao de comando da LIBMYSQL c - "onfira sgamysql.log" WHEN 201 DISPLAY "Conexao com servidor perdida." END-EVALUATE ELSE EVALUATE ESTADO WHEN "51" DISPLAY "Erro na conexao com o banco de dados atravez - " da LIBMYSQL" WHEN "53" DISPLAY "Nao foi possivel interpretar campos na tabel - "a e montar correspondencia." WHEN "91" DISPLAY "Erro na montagem da estrutura da FD,falha mo - "ntando campos." END-EVALUATE END-IF. STOP RUN. * *CREATE TABLE `mysqltst` ( * `MY_SIT` VARCHAR(1) NOT NULL DEFAULT ' ', * `MY_CHA` DECIMAL(5,0) NOT NULL DEFAULT '0', * `MY_DATA` DECIMAL(9,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX01N` INT(1) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX02N` INT(2) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX03N` INT(3) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX04N` INT(4) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX05N` BIGINT(5) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX06N` BIGINT(6) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX07N` BIGINT(7) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX08N` BIGINT(8) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX09N` BIGINT(9) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX10N` BIGINT(10) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX11N` BIGINT(11) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX12N` BIGINT(12) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX13N` BIGINT(13) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX14N` BIGINT(14) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX15N` BIGINT(15) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX16N` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX17N` BIGINT(17) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMPX18N` BIGINT(18) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP301N` DECIMAL(1,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP302N` DECIMAL(2,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP303N` DECIMAL(3,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP304N` DECIMAL(4,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP305N` DECIMAL(5,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP306N` DECIMAL(6,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP307N` DECIMAL(7,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP308N` DECIMAL(8,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP309N` DECIMAL(9,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP310N` DECIMAL(10,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP311N` DECIMAL(11,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP312N` DECIMAL(12,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP313N` DECIMAL(13,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP314N` DECIMAL(14,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP315N` DECIMAL(15,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP316N` DECIMAL(16,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP317N` DECIMAL(17,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP318N` DECIMAL(18,0) UNSIGNED NOT NULL DEFAULT '0', * `MY_CMP301S` DECIMAL(1,0) NOT NULL DEFAULT '0', * `MY_CMP302S` DECIMAL(2,0) NOT NULL DEFAULT '0', * `MY_CMP303S` DECIMAL(3,0) NOT NULL DEFAULT '0', * `MY_CMP304S` DECIMAL(4,0) NOT NULL DEFAULT '0', * `MY_CMP305S` DECIMAL(5,0) NOT NULL DEFAULT '0', * `MY_CMP306S` DECIMAL(6,0) NOT NULL DEFAULT '0', * `MY_CMP307S` DECIMAL(7,0) NOT NULL DEFAULT '0', * `MY_CMP308S` DECIMAL(8,0) NOT NULL DEFAULT '0', * `MY_CMP309S` DECIMAL(9,0) NOT NULL DEFAULT '0', * `MY_CMP310S` DECIMAL(10,0) NOT NULL DEFAULT '0', * `MY_CMP311S` DECIMAL(11,0) NOT NULL DEFAULT '0', * `MY_CMP312S` DECIMAL(12,0) NOT NULL DEFAULT '0', * `MY_CMP313S` DECIMAL(13,0) NOT NULL DEFAULT '0', * `MY_CMP314S` DECIMAL(14,0) NOT NULL DEFAULT '0', * `MY_CMP315S` DECIMAL(15,0) NOT NULL DEFAULT '0', * `MY_CMP316S` DECIMAL(16,0) NOT NULL DEFAULT '0', * `MY_CMP317S` DECIMAL(17,0) NOT NULL DEFAULT '0', * `MY_CMP318S` DECIMAL(18,0) NOT NULL DEFAULT '0', * `MY_CMP501N` INT(1) NOT NULL DEFAULT '0', * `MY_CMP502N` INT(2) NOT NULL DEFAULT '0', * `MY_CMP503N` INT(3) NOT NULL DEFAULT '0', * `MY_CMP504N` INT(4) NOT NULL DEFAULT '0', * `MY_CMP505N` INT(5) NOT NULL DEFAULT '0', * `MY_CMP506N` INT(6) NOT NULL DEFAULT '0', * `MY_CMP507N` INT(7) NOT NULL DEFAULT '0', * `MY_CMP508N` INT(8) NOT NULL DEFAULT '0', * `MY_CMP509N` INT(9) NOT NULL DEFAULT '0', * `MY_CMP510N` BIGINT(10) NOT NULL DEFAULT '0', * `MY_CMP511N` BIGINT(11) NOT NULL DEFAULT '0', * `MY_CMP512N` BIGINT(12) NOT NULL DEFAULT '0', * `MY_CMP513N` BIGINT(13) NOT NULL DEFAULT '0', * `MY_CMP514N` BIGINT(14) NOT NULL DEFAULT '0', * `MY_CMP515N` BIGINT(15) NOT NULL DEFAULT '0', * `MY_CMP516N` BIGINT(16) NOT NULL DEFAULT '0', * `MY_CMP517N` BIGINT(17) NOT NULL DEFAULT '0', * `MY_CMP518N` BIGINT(18) NOT NULL DEFAULT '0', * `MY_CMP501S` INT(1) NOT NULL DEFAULT '0', * `MY_CMP502S` INT(2) NOT NULL DEFAULT '0', * `MY_CMP503S` INT(3) NOT NULL DEFAULT '0', * `MY_CMP504S` INT(4) NOT NULL DEFAULT '0', * `MY_CMP505S` INT(5) NOT NULL DEFAULT '0', * `MY_CMP506S` INT(6) NOT NULL DEFAULT '0', * `MY_CMP507S` INT(7) NOT NULL DEFAULT '0', * `MY_CMP508S` INT(8) NOT NULL DEFAULT '0', * `MY_CMP509S` INT(9) NOT NULL DEFAULT '0', * `MY_CMP510S` BIGINT(10) NOT NULL DEFAULT '0', * `MY_CMP511S` BIGINT(11) NOT NULL DEFAULT '0', * `MY_CMP512S` BIGINT(12) NOT NULL DEFAULT '0', * `MY_CMP513S` BIGINT(13) NOT NULL DEFAULT '0', * `MY_CMP514S` BIGINT(14) NOT NULL DEFAULT '0', * `MY_CMP515S` BIGINT(15) NOT NULL DEFAULT '0', * `MY_CMP516S` BIGINT(16) NOT NULL DEFAULT '0', * `MY_CMP517S` BIGINT(17) NOT NULL DEFAULT '0', * `MY_CMP518S` BIGINT(18) NOT NULL DEFAULT '0', * PRIMARY KEY (`MY_CHA`), * INDEX `MY_CHA` (`MY_CHA`, `MY_DATA`) *) *COLLATE='latin1_swedish_ci' *ENGINE=InnoDB;