Invalid Record Declaration (47) on MariaDB table

I am trying to access a MariaDB table in a database. I have access to most of them, but there are a couple that I am having problems. I am getting

The declaration in Clarion 11

ENGINE_CODE_YEARS       FILE,DRIVER('ODBC'),OWNER(gConnectionString),NAME('wp_engine_code_years'),PRE(ECY),CREATE,BINDABLE,THREAD
ECG_ID_KEY               KEY(ECY:EGC_ID),DUP,NOCASE
MDL_ID_KEY               KEY(ECY:MDL_ID),DUP,NOCASE
ENGINE_CODE_MODEL_YEAR_KEY KEY(ECY:EGC_ID,ECY:MDL_ID,ECY:YEAR),NOCASE
Record                   RECORD,PRE()
EGC_ID                      LONG
MDL_ID                      LONG
YEAR                        SHORT
                         END
                       END

and in Maria DB the statement to create which runs fine.

CREATE TABLE IF NOT EXISTS wp_engine_code_years (
  egc_id INT(14), 
  mdl_id INT(14), 
  year SMALLINT, 
  INDEX ecg_id_key (EGC_ID), 
  INDEX mdl_id_key (MDL_ID), 
  UNIQUE engine_code_model_year_key (EGC_ID, MDL_ID, YEAR)
);

Any ideas?

Can you connect to the database and import the definition into your dictionary?

3 Likes

I would be concerned about the definition of INT(14)
If I read INT - MariaDB Knowledge Base Correctly
then it’s an unsigned 14 digit Integer. A Clarion Long would be a plain INT or INT4

I think ether the SQL definition needs to change to INT4 or maybe use a REAL on the clarion side.

I have other fields that use INT(14) with no issue. I recreated the table with INT(11) and same issue.

Try just plain INT and see if that’s OK
Also try active clarion driver tracing. The logs tend to have additional information.

OK. Getting somewhere.

05A80H(2) 00:28:47.762 Invalid field name: YEAR
05A80H(2) 00:28:47.762 Valid field names are:
05A80H(2) 00:28:47.762 id
05A80H(2) 00:28:47.762 tmc_id
05A80H(2) 00:28:47.762 mdl_id
05A80H(2) 00:28:47.762 year
05A80H(2) 00:28:47.762

If year is a reserved word, then why does it say that year is a valid field name?

That’s clarion just giving you the column names.
If you can just change the name to _year or something and it will be all good.

Hi Ron,

That list is showing you that on the database the field names are id, tmc_id, mdl_id and year. Clarion is expecting to see egc_id, mdl_id and year.

Maybe you created wp_engine_code_years on the database earlier with the wrong definition? Because you now have the “if not exists”, the new definition is not going to overwrite it.

Jon

If Clarion doesn’t like YEAR a s column name try in the DCT to use a different name but use the External name as per DB:

MyClarionYEAR SHORT,name('year')

Just had to put in a name to fool it.

TRANSMISSION_CODE_YEARS  FILE,DRIVER('ODBC','/ALLOWDETAILS=TRUE /LOGFILE=odbc.log'),OWNER(gConnectionString),NAME('wp_transmission_code_years'),PRE(TMY),CREATE,BINDABLE,THREAD
TMC_ID_KEY               KEY(TMY:TMC_ID),DUP,NOCASE
MDL_ID_KEY               KEY(TMY:MDL_ID),DUP,NOCASE
CODE_MODEL_YEAR_KEY      KEY(TMY:TMC_ID,TMY:MDL_ID,TMY:YEAR),NOCASE
Record                   RECORD,PRE()
ID                          LONG
TMC_ID                      LONG
MDL_ID                      LONG
YEAR                        SHORT,NAME('year')
                         END
                       END

Ron,

so did it help?