Page 1 of 1

Error when Deleting - Unknown column 'xxx' in 'where clause'

Posted: Tue 04 Dec 2007 00:40
by crafty
Hi,

I've encountered a problem when deleting rows from my query. I've come up to the following procedure to reproduce the error:

Create two tables and populate them:

CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`names` varchar(20) default NULL,
PRIMARY KEY (`id`)
);

INSERT INTO `test` VALUES (2,'aaaa');
INSERT INTO `test` VALUES (3,'bbbb');

CREATE TABLE `test2` (
`id` int(11) NOT NULL auto_increment,
`parent_id` int(11) default NULL,
PRIMARY KEY (`id`)
);

INSERT INTO `test2` VALUES (1,2);
INSERT INTO `test2` VALUES (2,3);
INSERT INTO `test2` VALUES (3,2);


Create TMyQuery with the following SQL:

select TC.id,
if(T.id<0,'abc',T.names) as names
from
test2 TC
left join test T on (T.id = TC.parent_id)
order by T.names

Add fields with the `Field Editor`.
Now either use the `Date Editor` in the IDE or launch app and issue MyQuery.Delete - both will result with the same error:
#42S22Unknown column 'names' in 'where clause'

Remove the if clause (or the 'order by') from the SQL query and there will be no error so the query above should also work.

Regards,
Crafty

Posted: Wed 05 Dec 2007 11:50
by Antaeus
Thank you for information. This problem has already been fixed. The fix will be available in the next MyDAC build.
As a temporary solution, you can generate the query for the SQLDelete property at design time and fix this query.

Posted: Wed 05 Dec 2007 22:17
by crafty
It's very nice to here that you care about users and that the issue is fixed :D

Regards,
Crafty

P.S. I've already discovered SQLDelete to be a temporary solution, but thanks anyways.