1 |
Install Mysql server. |
2 |
Install a
IDE that makes
easy to handle
and maintain Mysql tables. We recommend HeidiSQL
that besides an excellent tool, and
is free, you will
find in
http://www.heidisql.com for download. |
3 |
Suppose
that the server is installed
on the user machine,
in this case the server address
will be 127.0.0.1. |
4 |
In order to
establish a relationship
between the table in MySQL and
FD of our
application,
We created the following
table of
equivalence:
FD Cobol (PIC)
|
Mysql table |
PIC X(01)...(N)
|
CHAR 1 ... N
|
PIC X(01)...(N)
|
VARCHAR 1 ... N
|
PIC X(01)...(N)
|
BLOB
|
PIC 9(01)...(17) COMP-3
|
DECIMAL 1 ... 17
|
PIC 9(01)V9...(17) COMP-3
|
DECIMAL 2,1 ... 17,N
|
PIC 9(01)...(17) COMP-X
|
INT, BIGINT 1 ... 17 UNSIGNED
|
PIC S9(01)...(17) COMP-5
|
INT, BIGINT 1 ... 17 SIGNED
|
PIC 9(09) *> AAAAMMDD
|
DATE
|
|
5 |
Fields
with Occurs,
and redefines should be treated
as follows: |
5.1 |
Occurs, create the
field N
times, as many
times it occurs.
EX.:
Na FD.
02 CAMPO-A OCCURS 10.
03 DADO1 PIC X(2).
03 DADO2 PIC X(3).
Should be
defined as folow.
`DADO1-01` char(2) NOT NULL,
`DADO2-01` char(3) NOT NULL,
`DADO1-02` char(2) NOT NULL,
`DADO2-02` char(3) NOT NULL,
`DADO1-03` char(2) NOT NULL,
`DADO2-03` char(3) NOT NULL,
...
`DADO1-10` char(2) NOT NULL,
`DADO2-10` char(3) NOT NULL,
|
5.2 |
REDEFINES
is not allowed. In this case the
REDEFINES should
be eliminated, and you will need to
recode your program.
Eventually the User may
have the following situation
as described in the table below:
COBOL |
Mysql |
02 CAMPO-A.
03 DADO1 PIC X(2).
03 DADO2 PIC X(3).
02 FILLER REDEFINES CAMPO-A.
03 SDADO11 PIC X(1).
03 SDADO12 PIC X(1).
03 SDADO21 PIC X(1).
03 SDADO22 PIC X(2).
|
`DADO1` char(5) NOT NULL,
|
02 CAMPO-A.
03 DADO1 PIC X(2).
03 DADO2 PIC S9(5) COMP-3.
|
`DADO1` char(5) NOT NULL,
|
|
BIB2SQL.EXE
To facilitate the
correct definition
of the columns in the tables
we created
the program BIB2SQL.EXE.
From
a text file containing the
definitions of FD,
as far as possible, this routine
will create a new text file,
containing all necessary
commands to create equivalent table
provided with suffix
"SQL".
Fields defined with Occurs
and redefines,
should receive additional treatment.
Just run
BIB2SQL with no parameter,
that it returned
the SYNTAX
necessary for its execution.
Syntax :
BIB2SQL nomearqBib@nomeTabela@nomeDB
Note that was
used "@"
as separator
parameters, where
nomearqBib is the name
of the text file containing the
FD definition,
nomeTabela name of the table and
nomeDB, the name
of the database where
the table will be inserted.Ex.:
EXT2SQL ARQMYS.FD@arqmys@francodb
Text file containing the FD definition, ARQMYS.FD | Will
crate | SQL script file ARQMYS.SQL |
01 MY-REG.
02 MY-SIT PIC X(01).
02 MY-LAN PIC S9(09) COMP-3.
02 MY-CTA PIC S9(15) COMP-3.
02 MY-CDH PIC S9(05) COMP-3.
02 MY-HST PIC X(30).
02 MY-DTA PIC S9(09) COMP-3.
02 MY-VAL PIC S9(13)V99 COMP-3.
|
CREATE TABLE `francodb`.`arqmys` (
`MY-SIT` CHAR(00001) NOT NULL DEFAULT ' ',
`MY-LAN` DECIMAL(00009) NOT NULL DEFAULT '0',
`MY-CTA` DECIMAL(00015) NOT NULL DEFAULT '0',
`MY-CDH` DECIMAL(00005) NOT NULL DEFAULT '0',
`MY-HST` CHAR(00030) NOT NULL DEFAULT ' ',
`MY-DTA` DECIMAL(00009) NOT NULL DEFAULT '0',
`MY-VAL` DECIMAL(00015,00002) NOT NULL DEFAULT '0'
)
ENGINE=InnoDB;
|
Simply run
the script file
ARQMAYS.SQL at your Mysql IDE, and your table will be created.
Until now
we created the table with
their respective columns, based on
the FD,
and in accordance with the
pre set for above
equivalences.
It remains to
define the all keys,
so you can obtain
the same results as far
as accessing via
file and MF
Mysql.
Ex.:how to define keys in
Mysql, meeting
prerequisites of
EXTMYSQL.
SELECT ARQMYS ASSIGN TO DYNAMIC W-LABMSQ
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
FILE STATUS IS W-STATUS
RECORD KEY IS MY-LAN
ALTERNATE RECORD KEY IS MY-CTA
WITH DUPLICATES.
|
 |
SELECT SCCMOV ASSIGN TO DYNAMIC W-ARQUIVOS
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
FILE STATUS IS W-STATUS
RECORD KEY IS LA-LNC = LA-LAN LA-LIN
ALTERNATE RECORD KEY IS LA-DTA
WITH DUPLICATES
ALTERNATE RECORD KEY IS LA-CDA = LA-CAD LA-DTA
WITH DUPLICATES
ALTERNATE RECORD KEY IS LA-CDO = LA-COD LA-DTA
WITH DUPLICATES
ALTERNATE RECORD KEY IS LA-DOA = LA-CAD LA-TIP
LA-SER LANUM LA-LIN
WITH DUPLICATES
|
 |
To define composite keys, simply include all fields
in the same sequence
of keys on
the table as it was defined in
yout traditional SELECT.
The definition of each key in the
right sequence as it was defined
in your SELECT,
is fundamental to obtain the
same results in both MF files
and MYSQL.
Note:
The EXTMYSQL
does not address the key
defined in the table by name, but by the
sequence in which it was
defined, so
the primary key must be the
first key, the first Secondary key
is the second key, and so on, regardless of name given
key.
Warnings:
Before any procedure, it is
essential to have backup.
Backup of programs and data
is mandatory.
Errors:
1 |
I can not get
the same result reading
MF file and
MYSQL table.
|
|
In this case
it is possible that you
have a sequence error
in keys definition. Refresh
HeidiSQL and check if all the keys
are properly
defined, and mostly
in the right sequence.
Whenever you change
any information on the
key defined, make sure
the keys still
defined in the original
sequence.
In some cases the key changed
is placed at the end as the last key,
interfering the way our
program will make your
hits, and
this is only identified
after running the REFRESH command. |
|