SQL Error: ORA-00933: SQL command not properly ended

后端 未结 5 2133
鱼传尺愫
鱼传尺愫 2020-11-29 09:03

I am trying to update a record in oracle SQL developer by using Joins. Following is my query-

UPDATE system_info set field_value = \'NewValue\' 
FROM system_         


        
相关标签:
5条回答
  • 2020-11-29 09:37

    Semicolon ; on the end of command had caused the same error on me.

    cmd.CommandText = "INSERT INTO U_USERS_TABLE (USERNAME, PASSWORD, FIRSTNAME, LASTNAME) VALUES ("
                    + "'" + txtUsername.Text + "',"
                    + "'" + txtPassword.Text + "',"
                    + "'" + txtFirstname.Text + "',"
                    + "'" + txtLastname.Text + "');"; <== Semicolon in "" is the cause.
                                                          Removing it will be fine.
    

    Hope it helps.

    0 讨论(0)
  • 2020-11-29 09:37

    its very true on oracle as well as sql is "users" is a reserved words just change it , it will serve u the best if u like change it to this

    UPDATE system_info set field_value = 'NewValue' 
    

    FROM system_users users JOIN system_info info ON users.role_type = info.field_desc where users.user_name = 'uname'

    0 讨论(0)
  • 2020-11-29 09:42

    Your query should look like

    UPDATE table_name
    SET column1=value, column2=value2,...
    WHERE some_column=some_value
    

    You can check the below question for help

    • SQL update query using joins?
    0 讨论(0)
  • 2020-11-29 09:47

    Not exactly the case of actual context of this question, but this exception can be reproduced by the next query:

    update users set dismissal_reason='he can't and don't want' where userid=123
    

    Single quotes in words can't and don't broke the string. In case string have only one inside quote e.g. 'he don't want' oracle throws more relevant quoted string not properly terminated error, but in case of two SQL command not properly ended is thrown.

    Summary: check your query for double single quotes.

    0 讨论(0)
  • 2020-11-29 09:48

    Oracle does not allow joining tables in an UPDATE statement. You need to rewrite your statement with a co-related sub-select

    Something like this:

    UPDATE system_info
    SET field_value = 'NewValue' 
    WHERE field_desc IN (SELECT role_type 
                         FROM system_users 
                         WHERE user_name = 'uname')
    

    For a complete description on the (valid) syntax of the UPDATE statement, please read the manual:

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10008.htm#i2067715

    0 讨论(0)
提交回复
热议问题