I have the following problem (OO2.4, accessing a MySQL server via JDBC):
In a form, assigned to table "CUSTOMER", I need to combine values from two tables (ACM and LOC) in listbox entries. The Listbox Data settings are:
Data field: ACM_ID
Type of list cont.:Sql
List content: SELECT CONCAT(A1.FIRSTNAME,' ',A1.LASTNAME,' (',A2.NAME,')'),A1.ID FROM ACM A1, LOC A2 WHERE A1.LOC_ID = A2.ID;
Bound field: 1
I can submit that command directly to the MySQL server and it gets executed without any error:
Code: Select all
mysql> SELECT CONCAT(A1.FIRSTNAME,' ',A1.LASTNAME,' (',A2.NAME,')'),A1.ID FROM ACM A1, LOC A2 WHERE A1.LOC_ID = A2.ID; Empty set (0.00 sec)
BUT: when I open the form, I receive the following error messages/infos:
A window pops up saying: "The data could not be loaded.
Unknown column 'ACM_ID' in 'where clause'"
Clicking on a softbutton [More] in that window, further information is revealed:
An error list with three entries is seen left with related info in the right window:
Error :
The data content could not be loaded.
Error :
SQL Status: 42S22
Error code: 1054
Unknown column 'ACM_ID' in 'where clause'
Information:
The SQL command leading to this error is:
SELECT CONCAT( `A1`.`FIRSTNAME`, ' ', `A1`.`LASTNAME`, ' (', `A2`.`NAME`, ')' ) FROM `ACM` AS `A1`, `LOC` AS `A2` WHERE ( `ACM_ID` = `ACM`.`ID` AND `ACM`.`LOC_ID` = `LOC`.`ID` ) AND ( 0 = 1 )
Interestingly, that SQL command differs from the one I have set in the Listbox properties and which could be executed without problems. The Sql statement reported in the error message gets obviously compiled by OO (the JDBC driver?); when I feed this to the MySQL server directly, I get the same error as OO:
Code: Select all
mysql> SELECT CONCAT( `A1`.`FIRSTNAME`, ' ', `A1`.`LASTNAME`, ' (', `A2`.`NAME`, ')' ) FROM `ACM` AS `A1`, `LOC` AS `A2` WHERE ( `ACM_ID` = `ACM`.`ID` AND `ACM`.`LOC_ID` = `LOC`.`ID` ) AND ( 0 = 1 );
ERROR 1054 (42S22): Unknown column 'ACM_ID' in 'where clause'
Code: Select all
mysql> DESCRIBE CUSTOMER;
+---------------+----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+----------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| COMPANY | varchar(255) | YES | | NULL | |
| COUNTRY_ID | int(11) | YES | MUL | NULL | |
| PROVINCE | varchar(255) | YES | | NULL | |
| CITY | varchar(255) | YES | | NULL | |
| POSTCODE | varchar(24) | YES | | NULL | |
| ADDRESS | varchar(255) | YES | | NULL | |
| FIRSTNAME | varchar(50) | YES | | NULL | |
| LASTNAME | varchar(60) | YES | | NULL | |
| EMAIL | varchar(255) | YES | | NULL | |
| PHONELANDLINE | varchar(40) | YES | | NULL | |
| PHONEMOBILE | varchar(40) | YES | | NULL | |
| FAX | varchar(40) | YES | | NULL | |
| ACM_ID | int(11) | YES | | NULL | |
| COMMENTS | varchar(32766) | YES | | NULL | |
+---------------+----------------+------+-----+---------+----------------+
15 rows in set (0.03 sec)
Why does OO modify the SQL statement at all, and why does it change a valid SQL statement into an invalid one?
How could I achieve here what I want?
Thanks for any hints and advice.
Uwe