【问题标题】:DELETE Function in UcanAccess throws strange exceptionUcanAccess 中的 DELETE 函数抛出奇怪的异常
【发布时间】:2015-03-10 07:52:08
【问题描述】:

自从 Java 1.8 消除了 JDBC 桥(我们仍然感到悲痛)并迁移到 UcanAccess 之后,我一直在调试 SQL 代码,过去从未给我带来任何问题。其中一个语句是:

DELETE TreatmentRecords.DateGiven, TreatmentRecords.TimeGiven, SInformation.Surname, SInformation.FirstNames, TreatmentRecords.Diagnosis, TreatmentRecords.*
FROM SInformation INNER JOIN TreatmentRecords ON SInformation.SID = TreatmentRecords.SID
WHERE (((TreatmentRecords.DateGiven)=#2015-03-07#) AND ((TreatmentRecords.TimeGiven)='17;16') AND ((SInformation.Surname)='Doe') AND ((SInformation.FirstNames)='John') AND ((TreatmentRecords.Diagnosis)='Headache'));

在 Access 本身中执行时,我绝对不会遇到任何错误或问题。 但是 Ucancess 抛出以下异常:

net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: TREATMENTRECORDS required: FROM

任何关于为什么的想法都会受到高度赞赏!

【问题讨论】:

    标签: java sql ucanaccess


    【解决方案1】:

    这是一个非标准的 SQL 删除语句,即使 Jet 引擎支持,ucanaccess 也不支持。这没什么奇怪的。 因此,您必须为此使用标准 SQL。

    编辑 例如,像这样(我没有添加所有条件):

       DELETE FROM TreatmentRecords tr WHERE 
        tr.DateGiven=#2015-03-07# AND EXISTS 
    (SELECT * FROM SInformation s WHERE s.SID=tr.SID AND  s.Surname='Doe')
    

    【讨论】:

    • 您能否建议上面的标准 SQL 语句的外观?
    • 请看上面;-)
    猜你喜欢
    • 1970-01-01
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多