About ORA-00907: missing right parenthesis troubleshooting

Source: Internet
Author: User
Tags sql error

When writing the stored procedure, the system time format conversion is used to compare with the database field, when I test throw the ORA-00907: missing right parenthesis, the default right brace;

The following is my error code:

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 | '';

After correction, the code is successfully executed:

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 | '';

Comparison of the red part

I hope this will be helpful for similar errors.

Second case

(Oracle test) select statements using SQL statements often use aliases of fields and tables. Note that the field alias can be prefixed with the as keyword or omitted without writing, however, the table name alias cannot be prefixed with as; otherwise, the following error is reported:

Command error, row: 11 columns: 20
Error Report:
SQL error: ORA-00907: missing right brackets
00907. 00000-"missing right parenthesis"
* Cause:
* Action:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.