我在使用这个 sql 视图时遇到了一些问题。
CREATE OR REPLACE VIEW view_themed_booking AS
SELECT tb.*,
CASE
WHEN (tb.themed_party_size % 2) = 0 THEN
(tb.themed_party_size-2)/2
ELSE ((tb.themed_party_size-2)/2) + 0.5
END themed_tables
FROM themed_booking tb;
有人能帮我一下吗?我正在尝试在视图的末尾添加一列,即(S-2)/2
where的自然数结果S
是themed_party_size
.
当我说自然数结果时,我的意思是把以 0.5 结尾的答案四舍五入,所以如果S=7
答案是3
和不是2.5
。
当我尝试运行上述代码时出现的错误是
Error starting at line 1 in command:
CREATE OR REPLACE VIEW view_themed_booking AS
SELECT tb.*,
CASE WHEN (tb.themed_party_size % 2) = 0
THEN (tb.themed_party_size-2)/2
ELSE ((tb.themed_party_size-2)/2) + 0.5
END themed_tables
FROM themed_booking tb
Error at Command Line:3 Column:34
Error report:
SQL Error: ORA-00911: invalid character
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
*Action:
如果它有所不同,我正在使用连接到 oracle 服务器的 sqldeveloper,这样我就可以使用 PL/SQL。