• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

关于ORA-00907: missing right parenthesis问题整理

mysql 搞代码 4年前 (2022-01-09) 21次浏览 已收录 0个评论

在写存储过程的时候,在把系统时间格式转换用于与数据库字段做比较,当我test时抛出ORA-00907: missing right parenthesis,缺省右括

在写存储过程的时候,在把系统时间格式转换用于与数据库字段做比较,当我test时抛出ORA-00907: missing right parenthesis,缺省右括号;

下面是我的出错代码:

dynamic_sql := ‘select t3.departmentcode, t3.total from (select departmentcode,count(*) total from ‘ || str_tablename || ‘ where (LASTUPDATEDTIME between to_date(to_char(sysdate-1,”yyyy-mm-dd”) ,”yyyy-mm-dd”) and to_date(to_char(sysdate,”yyyy-mm-dd”) ,”yyyy-mm-dd”)) and departmentcode is not NULL group by departmentcode) t3,v_s_data_input_dept_usernum t4 where t3.departmentcode = ‘ || str_departmentcode || ”;

更正后,执行成功的代码:

dynamic_sql := ‘select t3.departmentcode, t3.total from (select departmentcode,co

本文来源gaodai.ma#com搞#代!码网_

unt(*) total from ‘ || str_tablename || ‘ where (LASTUPDATEDTIME between to_date(”’ || to_char(sysdate-1,’yyyy-mm-dd’) || ”’,”yyyy-mm-dd”) and to_date(”’ || to_char(sysdate,’yyyy-mm-dd’) || ”’,”yyyy-mm-dd”)) and departmentcode is not NULL group by departmentcode) t3,v_s_data_input_dept_usernum t4 where t3.departmentcode = ‘ || str_departmentcode || ”;

红色的部分对比

希望对出现类似错误的有所帮助

还有第二种情况

(Oracle测试)使用SQL语句的select语句是经常会用到字段和表的的别名,使用要注意,字段的别名前面可以加as关键字,或是省略不写,但是表名的别名前面不可以加as,否则会报如下错误:

命令出错, 行: 11 列: 20
错误报告:
SQL 错误: ORA-00907: 缺失右括号
00907. 00000 – “missing right parenthesis”
*Cause:
*Action:


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:关于ORA-00907: missing right parenthesis问题整理
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址