MySQL utilizes the underlying operating system to store table names and data. On Unix based systems this has the effect that SQL TableNames become case sensitive. A COBOL program does not expect this however and this means that a simple
EXEC SQL
SELECT * FROM TABLENAME1;
END-EXEC
Can fail to find the table if it was created with the following script
CREATE TABLE tablename1
(
acctdo CHAR(5)
,snamedo CHAR(18)
);
tablename1 does sadly not equal TABLENAME1
The solution for this is to ensure that MySQL converts all tablenames to lower case and this is done by adding the following entries to mysql configuration generally /etc/mysql/my.cnf file
[mysqld]
lower_case_table_names=1
see the following article for full details. mysql case
In the case of Docker however it is tedious to build a new image just to add these entries so there is another way which is to start MySQL with a command line parameter. Here is a sample docker command which creates a mysql container and passes in the lower_case_table_names=1
docker run --name mysqldb --rm -e MYSQL_ROOT_PASSWORD=abc000 -e MYSQL_DATABASE=DBJALIT -p 3306:3306 mysql:5.7.22 --lower_case_table_names=1
and here is a snippet of a docker-compose.yml file that does the same thing
version: '3'
services:
db:
image: mysql:5.7.22
environment:
MYSQL_ROOT_PASSWORD: abc000
MYSQL_DATABASE: DBJALIT
#this command is needed otherwise table name case becomes important
#cobol is not case sensitive but linux mysql by default is so we have to turn it off
command: --lower_case_table_names=1
ports:
- "3306:3306"
0 Comments