ORA-00932 错误。不知道如何修复
我正在尝试运行此 Oracle 查询...
SELECT COUNT(*) as total,
q1
FROM exit_responses
WHERE sdate BETWEEN '03-Aug-10 12:00:00 AM' AND '03-Nov-10 12:00:00 AM'
GROUP BY q1;
...但我不断收到此错误...
Error starting at line 3 in command:
SELECT COUNT(*) as total, q1 FROM exit_responses WHERE sdate BETWEEN '03-Aug-10 12:00:00 AM' AND '03-Nov-10 12:00:00 AM' GROUP BY q1
Error at Command Line:3 Column:130
Error report:
SQL Error: ORA-00932: inconsistent datatypes: expected - got CLOB
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:
有人有任何想法吗?说这是不一致的数据类型......但我想我没有完全理解。
谢谢
顺便说一句,这是我的 exit_responses 表的 DESC:
DESC exit_responses
Name Null Type
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SDATE DATE
F_NAME VARCHAR2(255 CHAR)
L_NAME VARCHAR2(255 CHAR)
TITLE VARCHAR2(255 CHAR)
DEPARTMENT VARCHAR2(255 CHAR)
EMP_TYPE VARCHAR2(11 CHAR)
LENGTH_OF_SERVICE VARCHAR2(255 CHAR)
Q1 CLOB()
Q2 CLOB()
Q2_OTHER CLOB()
Q3_PAY NUMBER
Q3_HOLIDAYS NUMBER
Q3_VACATION NUMBER
Q3_SICK NUMBER
Q3_INSURANCE NUMBER
Q3_RETIREMENT NUMBER
Q3_FSA NUMBER
Q4_AVAILABILITY NUMBER
Q4_QUALITY NUMBER
Q4_SATISFACTION NUMBER
Q4_COMMENTS NUMBER
Q5_ORIENTATION NUMBER
Q5_POLICIES NUMBER
Q5_PROMOTIONAL NUMBER
Q6_JOBDUTIES NUMBER
Q6_RELATIONSHIPS NUMBER
Q6_COOPERATION NUMBER
Q6_EQUIPMENT NUMBER
Q6_CONDITIONS NUMBER
Q6_SAFETY NUMBER
Q7 NUMBER
Q8_KNOWLEDGE NUMBER
Q8_DELEGATION NUMBER
Q8_OBSERVANCE NUMBER
Q8_FEEDBACK NUMBER
Q8_CONTRIBUTIONS NUMBER
Q8_LISTENED NUMBER
Q8_COMPLAINTS NUMBER
Q9 VARCHAR2(3 CHAR)
Q9_DESCRIBE CLOB()
Q10 CLOB()
Q11 NUMBER
Q11_COMMENTS CLOB()
Q12 NUMBER
Q12_DESCRIBE CLOB()
ADDITIONAL_COMMENTS CLOB()
I'm attempting to run this Oracle query...
SELECT COUNT(*) as total,
q1
FROM exit_responses
WHERE sdate BETWEEN '03-Aug-10 12:00:00 AM' AND '03-Nov-10 12:00:00 AM'
GROUP BY q1;
...but I keep getting this error...
Error starting at line 3 in command:
SELECT COUNT(*) as total, q1 FROM exit_responses WHERE sdate BETWEEN '03-Aug-10 12:00:00 AM' AND '03-Nov-10 12:00:00 AM' GROUP BY q1
Error at Command Line:3 Column:130
Error report:
SQL Error: ORA-00932: inconsistent datatypes: expected - got CLOB
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:
Anyone have any ideas? Says it's an inconsistent data type... but I guess I'm not understanding completely.
Thanks
Btw, here's the DESC of my exit_responses table:
DESC exit_responses
Name Null Type
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SDATE DATE
F_NAME VARCHAR2(255 CHAR)
L_NAME VARCHAR2(255 CHAR)
TITLE VARCHAR2(255 CHAR)
DEPARTMENT VARCHAR2(255 CHAR)
EMP_TYPE VARCHAR2(11 CHAR)
LENGTH_OF_SERVICE VARCHAR2(255 CHAR)
Q1 CLOB()
Q2 CLOB()
Q2_OTHER CLOB()
Q3_PAY NUMBER
Q3_HOLIDAYS NUMBER
Q3_VACATION NUMBER
Q3_SICK NUMBER
Q3_INSURANCE NUMBER
Q3_RETIREMENT NUMBER
Q3_FSA NUMBER
Q4_AVAILABILITY NUMBER
Q4_QUALITY NUMBER
Q4_SATISFACTION NUMBER
Q4_COMMENTS NUMBER
Q5_ORIENTATION NUMBER
Q5_POLICIES NUMBER
Q5_PROMOTIONAL NUMBER
Q6_JOBDUTIES NUMBER
Q6_RELATIONSHIPS NUMBER
Q6_COOPERATION NUMBER
Q6_EQUIPMENT NUMBER
Q6_CONDITIONS NUMBER
Q6_SAFETY NUMBER
Q7 NUMBER
Q8_KNOWLEDGE NUMBER
Q8_DELEGATION NUMBER
Q8_OBSERVANCE NUMBER
Q8_FEEDBACK NUMBER
Q8_CONTRIBUTIONS NUMBER
Q8_LISTENED NUMBER
Q8_COMPLAINTS NUMBER
Q9 VARCHAR2(3 CHAR)
Q9_DESCRIBE CLOB()
Q10 CLOB()
Q11 NUMBER
Q11_COMMENTS CLOB()
Q12 NUMBER
Q12_DESCRIBE CLOB()
ADDITIONAL_COMMENTS CLOB()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
假设
sdate
的日期类型是Oracle DATE,则使用TO_DATE函数 将字符串转换为 Oracle 中的 DATE:Assuming
sdate
's date type is Oracle DATE, use the TO_DATE function to convert a string to a DATE in Oracle:SDATE 列的数据类型是什么?假设它是一个 DATE,您几乎肯定希望使用显式 TO_DATE 调用将字符串转换为日期,即,
由于午夜是未指定的默认时间,因此您不一定需要 12:00:00 AM 位。如果您想包含
If SDATE is a DATE 并且您希望 BETWEEN 采用两个不同的 Unix 纪元(自 1970 年 1 月 1 日起的毫秒数)而不是字符串,您可能需要类似的内容,
其中 :1 和 :2 是两个绑定变量。如果你的纪元是自 1970 年 1 月 1 日以来的秒数
What is the data type of the SDATE column? Assuming it is a DATE, you almost certainly want to use explicit TO_DATE calls to convert your strings to dates, i.e.
Since midnight is the default time when none is specified, you don't necessarily need the 12:00:00 AM bit. If you want to include that
If SDATE is a DATE and you want the BETWEEN to take two different Unix epochs (milliseconds since Jan 1, 1970) rather than strings, you would want something like
where :1 and :2 are the two bind variables. If your epochs are seconds since Jan 1, 1970
我的猜测是
sdate
是 DATE 或 DATETIME 列,在这种情况下您需要转换日期字符串:my guess is that
sdate
is a DATE or DATETIME column, in which case you need to convert your date strings:由于对 ORACLE 一无所知,我敢打赌您实际上无法对
CLOB
字段进行GROUP BY
。这很有道理......另外,看看 这个。摘抄:
Not knowing anything about ORACLE, I would bet that you in fact can't
GROUP BY
onCLOB
fields. It makes perfect sense...Also, look at this. Excerpt:
我认为,最好使用 to_date 函数。
i think, it's better to use to_date function for that.