Welcome 微信登录

首页 / 数据库 / MySQL / 关于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,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 || "";红色的部分对比希望对出现类似错误的有所帮助还有第二种情况(Oracle测试)使用SQL语句的select语句是经常会用到字段和表的的别名,使用要注意,字段的别名前面可以加as关键字,或是省略不写,但是表名的别名前面不可以加as,否则会报如下错误:

命令出错, 行: 11 列: 20
错误报告:
SQL 错误: ORA-00907: 缺失右括号
00907. 00000 -  "missing right parenthesis"
*Cause:   
*Action:20个最常见Oracle数据库面试问题ORA-01810格式代码出现两次的解决方案相关资讯      Oracle错误代码 
  • Oracle错误代码大全  (02/16/2015 21:31:57)
  • Oracle中登陆时报ORA-28000: the   (03/06/2013 20:06:23)
  • Oracle 11g startup时报ORA-03113  (02/21/2013 17:25:55)
  • Oracle Grid Control OUI-25031错  (03/09/2013 09:01:36)
  • ORA-04091:触发器/函数不能读  (02/25/2013 08:28:13)
  • Oracle错误 ORA-12514 解决方法  (02/18/2013 08:50:10)
本文评论 查看全部评论 (0)
表情: 姓名: 字数