我正在尝试向我们的数据库的查询添加一些格式化的列,但我认为我在 CASE 语句中弄错了运算符。
我也不清楚如何为 TO_CHAR 操作编写格式。它与 TO_DATE 操作相同吗?(在 oracle 文档中找不到)
我也不确定我是否应该使用 TO_DATE 或其他调用来创建一个对象,该对象存储为来自四个数字的字符串的时间。
最重要的是,我的代码产生了错误,所以我什么也没看到。
我收到此错误:
ORA-00920: invalid relational operator
00920. 00000 - "invalid relational operator"
*Cause:
*Action:
Error at Line: 53 Column: 30
从这段代码
/* Code written for exercize 3 in the Banner Tutorials by Alex Ackroyd on 18april2013*/
/* Objective: use functions to transform and shape data in the result set*/
/* Tables: SSRMEET ( add to SPRIDEN, SFRSTCR, SSBSECT ) */
/* Select: in addition to the columns from exercize 2, add the following values:
- SSRMEET_ROOM_CODE,
- a computed column for the start time,
- a computed column for the end time, and
- a computed column that shows the days the class meets*/
/* Hint: The computed columns are created by passing table columns through functions.
You can use any non-analytical database function documented by Oracle to transform data from one thing to another.
You can also write your own functions! Whoa there Shadowfax, coming soon to the tutorial near you!*/
/* Note:ssrmeet_begin_time and ssrmeet_end_time are are in a 4 character string 24hr format
so I'm trying to read that in, convert it to a datetime type variable,
then convert it to the final standard format am/pm (ex: 5:00 A.M. , 3:30 P.M., etc.*/
/* Start code from this exercize, 3*/
select
ssrmeet.ssrmeet_room_code,
TO_CHAR(
TO_DATE( ssrmeet.ssrmeet_begin_time, 'HH24MI' )
/*, char format*/
),
TO_CHAR(
TO_DATE( ssrmeet.ssrmeet_end_time, 'HH24MI' )
/*, char format*/
),
CASE
when
/* line 53*/ ssrmeet.ssrmeet_sun_day,
| ssrmeet.ssrmeet_mon_day,
| ssrmeet.ssrmeet_tue_day,
| ssrmeet.ssrmeet_wed_day,
| ssrmeet.ssrmeet_thu_day,
| ssrmeet.ssrmeet_fri_day,
| ssrmeet.ssrmeet_sat_day
IS NOT NULL
END
from ssrmeet
/* End code from this exercize, 3*/
提前感谢您的帮助。