ORA-00936: missing expression bad SQL grammar

user3548196

When i am executing my method i am getting this message in my log file:

org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [DELETE FROM DEVICES WHERE DEVICEID IN ([3715, 3716]) ]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

Can anyone help please?

    public int removeDevice(ArrayList<Long> deviceId) {


    StringBuffer query = new StringBuffer("DELETE FROM DEVICES ");

    query.append("WHERE DEVICEID IN ("+deviceId+") ");


    int rowsRemoved = 0;
    try {
        rowsRemoved = getSimpleJdbcTemplate().update(query.toString());
    } catch(Exception e) {
        log.error("query: " + query.toString());

    }
    return rowsRemoved;

}

Maheswaran Ravisankar

Perhaps deviceId.toString() returns [3715,3716].. it has to be just 3715,3716 . So change your logic to form a comma separated string

query.append("WHERE DEVICEID IN ("+ deviceId.toString().replaceAll("\\[|\\]", "") +") ");

This should help! Sorry not tested! This removes the Square brackets.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL Error -- ORA-00936: missing expression

From Dev

ORA 00936 Missing Expression

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

ora:00936 Missing Expression error

From Dev

ORA-00936: missing expression distinct on oracle

From Dev

ORA-00936: missing expression - what is the cause?

From Dev

ORA-00936: missing expression oracle

From Dev

ORA-00936: missing expression in order by case

From Dev

ORA-00936: Missing Expression Teradata

From Dev

Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

From Dev

getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

From Dev

ORA-00936: missing expression error when inserting values

From Dev

Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

From Dev

ORA-00936: missing expression while executing in C#.

From Dev

ORA-00936: missing expression ORACLE please help me

From Dev

Oracle data access error: ORA-00936: missing expression

From Dev

ORA-00936: missing expression while using stringbuilder

From Dev

ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

From Dev

HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

From Dev

HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

From Dev

ORA-00936, Java and SQL

From Dev

Oracle SQL - ORA-00936 on DATE()

From Dev

SQL Developer Distinct gives ORA-00936

From Dev

Reason: PreparedStatementCallback; bad SQL grammar

From Dev

Missing SELECT statement using QueryDSL with Spring QueryDslJdbcTemplate causing bad SQL Grammar error

From Dev

Bad SQL grammar exception after deploying in server

From Dev

How to solve bad sql grammar error with Spring JDBC?

From Dev

BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar, when I give a timestamp argument

Related Related

  1. 1

    SQL Error -- ORA-00936: missing expression

  2. 2

    ORA 00936 Missing Expression

  3. 3

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  4. 4

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  5. 5

    ora:00936 Missing Expression error

  6. 6

    ORA-00936: missing expression distinct on oracle

  7. 7

    ORA-00936: missing expression - what is the cause?

  8. 8

    ORA-00936: missing expression oracle

  9. 9

    ORA-00936: missing expression in order by case

  10. 10

    ORA-00936: Missing Expression Teradata

  11. 11

    Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

  12. 12

    getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

  13. 13

    ORA-00936: missing expression error when inserting values

  14. 14

    Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

  15. 15

    ORA-00936: missing expression while executing in C#.

  16. 16

    ORA-00936: missing expression ORACLE please help me

  17. 17

    Oracle data access error: ORA-00936: missing expression

  18. 18

    ORA-00936: missing expression while using stringbuilder

  19. 19

    ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

  20. 20

    HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

  21. 21

    HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

  22. 22

    ORA-00936, Java and SQL

  23. 23

    Oracle SQL - ORA-00936 on DATE()

  24. 24

    SQL Developer Distinct gives ORA-00936

  25. 25

    Reason: PreparedStatementCallback; bad SQL grammar

  26. 26

    Missing SELECT statement using QueryDSL with Spring QueryDslJdbcTemplate causing bad SQL Grammar error

  27. 27

    Bad SQL grammar exception after deploying in server

  28. 28

    How to solve bad sql grammar error with Spring JDBC?

  29. 29

    BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar, when I give a timestamp argument

HotTag

Archive