如何根据当前时间显示“GOOD MORNING”或“GOOD AFTERNOON”或“GOOD NIGHT”
答案 0 :(得分:1)
DECLARE CURSOR CR从DUAL中选择SYSDATE;
BEGIN
FOR IN IN CR LOOP
IF TO_CHAR(I.SYSDATE,'HH24')> = 0 AND TO_CHAR(SYSDATE,'HH24')< 12 THEN
Dbms_output.put_line(' GOOD MORNING');
ELSIF TO_CHAR(I.SYSDATE,'HH24')> = 12 AND TO_CHAR(SYSDATE,'HH24')< 18 THEN
Dbms_output.put_line('GOOD EVENING ');
ELSE
Dbms_output.put_line('GOOD NI8 ');
结束IF;
END LOOP;
END;