ORA-00933 帮助:SQL 命令未正确结束
如果我使用 Oracle 的 SQL Developer 运行以下 SQL。
select payee_id, to_char(check_date,'d') as DOW,
(cmcl_bank_cleared - check_date) as DateDiff from AP_Master
where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=1)
order by payee_address_zip, DOW, DateDiff
它工作正常,但是当我尝试使用 Delphi 执行此操作时,
SQL.Add('select payee_id, to_char(check_date, ' + QuotedStr('d') + ') as DOW, ');
SQL.Add('(cmcl_bank_cleared - check_date) as DateDiff from AP_Master ');
SQL.Add('where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=:DaysParam))');
SQL.Add('order by payee_id, DOW, DateDiff;');
我收到“ORA-00933:SQL 命令未正确结束”错误消息
If I run the following SQL using Oracle's SQL Developer.
select payee_id, to_char(check_date,'d') as DOW,
(cmcl_bank_cleared - check_date) as DateDiff from AP_Master
where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=1)
order by payee_address_zip, DOW, DateDiff
It works fine, however when I try to do it using Delphi
SQL.Add('select payee_id, to_char(check_date, ' + QuotedStr('d') + ') as DOW, ');
SQL.Add('(cmcl_bank_cleared - check_date) as DateDiff from AP_Master ');
SQL.Add('where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=:DaysParam))');
SQL.Add('order by payee_id, DOW, DateDiff;');
I get the "ORA-00933: SQL Command nor properly ended" error message
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看DayParams后面的双括号。您的 SQL Developer SQL 中没有它。为了避免使用 StackOverflow 作为 Oracle SQL 拼写检查器,您可以:
查询文本
它是一个整体,而不是逐行
线
Look at the double bracket after DayParams. You don't have it in your SQL Developer SQL. To avoid you to use StackOverflow as an Oracle SQL spell checker, you could:
query text there
it in a whole, instead of line by
line
你为什么坚持用这种艰难的方式来做这件事? :)
我有一个实用程序,允许您在 IDE 中选择它并将其复制到剪贴板,运行该实用程序,然后直接粘贴到 SQL Developer 查询窗口(或任何其他编辑控件)中。我还有一个相反的功能 - 您将任何查询文本选择到剪贴板中,运行该实用程序,然后将代码粘贴到
const Whatever =
之后,以创建一个完美形成的 Delphi 字符串常量,用作上面(事实上,我在清理 SQL.Add 语句以确保嵌入的引号正确后使用了它)。Why do you insist on doing this the hard way? :)
I have a utility that will allow you to select this in the IDE and copy it to the clipboard, run the utility, and then paste directly into your SQL Developer query window (or any other edit control). I also have one that does the reverse - you select any query text into the clipboard, run the utility, and then paste the code after the
const Whatever =
to make a perfectly formed Delphi string constant to use as above (in fact, I used it after cleaning up your SQL.Add statements to make sure embedded quotes were correct).您在 Delphi 中使用哪些组件进行查询?
ORDER BY 子句字符串末尾有一个分号,这将导致此错误,具体取决于您用于查询的组件。
What components are you using in Delphi for your query?
You've got a semi-colon at the end of your ORDER BY clause string which will cause this error, depending on what components you are using for the query.