oracle 编写 CASE 语句错误 ORA-00923

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4399124/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:09:01  来源:igfitidea点击:

Writing CASE statement Error ORA-00923

sqloracleora-00923

提问by Spiny Norman

I have a database that I have populated using CREATE and INSERT INTO statements. I am now trying to write a CASE statemenet that will display 'customers' whose payment_due_date has passed todays date. Below is the following code

我有一个使用 CREATE 和 INSERT INTO 语句填充的数据库。我现在正在尝试编写一个 CASE 语句,该语句将显示 Payment_due_date 已超过今天日期的“客户”。下面是下面的代码

CREATE STATEMENT 'Ord'(Order)

CREATE STATEMENT 'Ord'(订单)

CREATE TABLE Ord(OrderID varchar2(9) PRIMARY KEY, 
CustomerID varchar(9) REFERENCES Customer(CustomerID), 
Expected_Delivery_Date date DEFAULT sysdate NOT NULL, 
Actual_Delivery_Date date DEFAULT sysdate NOT NULL, 
Payment_Due_Date date DEFAULT sysdate NOT NULL,
 Order_Date date DEFAULT sysdate NOT NULL, Price Varchar(10), 
Order_Placed varchar2(1) CONSTRAINT OrderPlaced 
CHECK(Order_Placed IN('Y','N')) NOT NULL, Order_Confirmed varchar2(1)
CONSTRAINT Order_Confirmed CHECK(Order_Confirmed IN('Y','N')) 
NOT NULL, Order_Completed varchar2(1) CONSTRAINT Order_Completed
CHECK(Order_Completed IN('Y','N')) NOT NULL) 

INSERT STATEMENT

插入语句

 INSERT INTO Ord VALUES(401565981, 501623129, 
    '10-Dec-10', '11-Dec-10', '07-Dec-10', '03-Dec-10','£14.99', 'Y', 'Y', 'Y')

CASE STATEMENT

案例陈述

 SELECT OrderID, CustomerID, Payment_Due_Date CASE WHEN 
Payment_Due_Date = '08-Dec-10' THEN 'Send Final Demand Letter'
    ELSE 'Do not send letter' 
    END FROM Ord;

When I try to run the above case statement I recieve the following error

当我尝试运行上述 case 语句时,我收到以下错误

ORA-00923: FROM keyword not found where expected 00923. 00000 - "FROM keyword not found where expected" *Cause:
*Action: Error at Line: 26 Column: 50

ORA-00923:在预期 00923 处未找到 FROM 关键字。00000 - “在预期处未找到 FROM 关键字” *原因:
*操作:第 26 行错误:50

Is there any possible way around this?

有没有办法解决这个问题?

回答by Spiny Norman

I think you need a comma between Payment_Due_Date and CASE.

我认为您需要在 Payment_Due_Date 和 CASE 之间使用逗号。