我正在尝试使用Joins更新oracle SQL开发人员中的记录。 以下是我的查询 -
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'
但是,当我尝试执行它时,我收到了以下错误 -
Error report: SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
我尝试删除JOINS
UPDATE system_info info
SET info.field_value = 'NewValue'
FROM system_users users
where users.user_name = 'uname' AND users.role_type = info.field_desc
但仍有同样的错误 任何人都可以告诉我错误原因和解决方案
答案 0 :(得分:24)
命令末尾的分号;
对我造成了同样的错误。
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.
希望它有所帮助。
答案 1 :(得分:14)
Oracle不允许在UPDATE语句中连接表。您需要使用共同相关的子选择
重写您的语句这样的事情:
UPDATE system_info
SET field_value = 'NewValue'
WHERE field_desc IN (SELECT role_type
FROM system_users
WHERE user_name = 'uname')
有关UPDATE语句的(有效)语法的完整描述,请阅读手册:
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10008.htm#i2067715
答案 2 :(得分:2)
不完全是这个问题的实际上下文的情况,但是这个例外可以通过下一个查询重现:
INSERT INTO t2 a
SELECT
GROUP_CONCAT(IF (criteria = 11,record,NULL)) AS Label_u,
GROUP_CONCAT(IF (criteria = 12,record,NULL)) AS Label_v,
GROUP_CONCAT(IF (criteria = 13,record,NULL)) AS Label_w,
GROUP_CONCAT(IF (criteria = 14,record,NULL)) AS Label_x,
GROUP_CONCAT(IF (criteria = 15,record,NULL)) AS Label_y,
GROUP_CONCAT(IF (criteria = 16,record,NULL)) AS Label_z
FROM mytable b
WHERE a .user field = b.user
GROUP BY USER
ORDER BY USER;;
I have tried many - Can someone help me find a functional query to do this?
单词update users set dismissal_reason='he can't and don't want' where userid=123
和can't
中的单引号打破了字符串。
如果字符串只有一个内部引用,例如'他不希望'oracle抛出更多相关引用的字符串未正确终止错误,但是如果两个 SQL命令未正确结束则抛出。
摘要:检查您的查询是否有双引号。
答案 3 :(得分:1)
您的查询应该是
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
您可以查看以下问题寻求帮助
答案 4 :(得分:-7)
它在oracle上非常真实,而sql是“用户”是保留字只是改变它, 如果你愿意改变它,它会为你提供最好的服务
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'