Description:
There is basically a problem with the creation of foreign key, or problem with usage of SQLForeignKey() to retrieve foreign key information.
In MySQL server, create a database with name 'acTestDB'. Notice the
use of mixed-case within the database name.
Then run the following 2 create statements:
CREATE TABLE `tab1` (
`supp_no` int(11) NOT NULL default '0',
`item_no` int(11) NOT NULL default '0',
`qty` int(11) NOT NULL default '0',
PRIMARY KEY (`supp_no`,`item_no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `tab2` (
`ord_no` int(11) NOT NULL default '0',
`supp_no` int(11) NOT NULL default '0',
`item_no` int(11) NOT NULL default '0',
KEY `supp_no` (`supp_no`,`item_no`),
CONSTRAINT `tab1_ibfk_1` FOREIGN KEY (`supp_no`, `item_no`) REFERENCES `tab1` (`supp_no`, `item_no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Then, issue the following command in ODBCTE32W.exe (Microsoft's ODBC Test tool):
SQLForeignKeys:
In:
StatementHandle = 0x008418C0,
PkCatalogName = SQL_NULL_HANDLE,
NameLength1 = 0,
PkSchemaName = SQL_NULL_HANDLE,
NameLength2 = 0,
PkTableName = SQL_NULL_HANDLE,
NameLength3 = 0,
FkCatalogName = SQL_NULL_HANDLE,
NameLength4 = 0,
FkSchemaName = "acTestDB",
NameLength5 = 8,
FkTableName = "tab2",
NameLength6 = 4
Return: SQL_SUCCESS=0
Get Data All:
"PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY"
"actestdb", "", "tab1", ""supp_no"", "acTestDB", "", "tab2",
""supp_no"", 1, 1, 1, "NULL", "NULL", 7
Notice that PKTABLE_CAT is "actestdb" (all lower-case, which is wrong) while
"FKTABLE_CAT" is "acTestDB" (mixed-case, which is correct.)
How to repeat:
See description above.