SQL Anomaly?
Posted in 1996
Dear Informix or SQL Gurus,
I ran into a problem with the following simple statement:
delete from tmp_kontakt
where s_doknr in (select unique(s_doknr) from kontakt)
^^^^^^^
Table "kontakt" has 1514 rows, while "tmp_kontakt" had ~6500 rows.
The statement took over one hour to complete, and resulted in all
but 14 rows from "tmp_kontakt" being deleted. These rows had a
"NULL" entry for "tmp_kontakt.s_doknr".
This was not what I wanted, only 1514 rows had to be deleted. It turned
out that I had made a typing mistake and there was no such column
"s_doknr" in table "kontakt". The correct column name is "ko_s_doknr".
After restoring the table "tmp_kontakt" with the original data and
correcting the sql statement, it took only very few seconds and yielded
the correct result.
What troubles me is that no error message was returned with the wrong
sql statement? Shouldn't dbaccess have returned error number -217,
"Column (s_doknr) not found in any table in the query."? Maybe it was
confused by the fact that the column name "s_doknr" indeed exists
in table "tmp_kontakt", but still that is not correct behaviour. The
subquery was not correctly formulated.
Could someone please shed some light on this?
Regards, Richard
--
+----------------------------+-------------------------------------------+
| Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de |
| EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3421 |
| Klinikum Grosshadern | FAX : +49-89-7095-8886 |
| 81366 Munich, Germany | |
+----------------------------+-------------------------------------------+