如何根据使用oracle的当前时间显示“GOOD MORNING”或“GOOD AFTERNOON”或“GOOD NIGHT”

时间:2013-02-21 23:29:04

标签: oracle10g

如何根据当前时间显示“GOOD MORNING”或“GOOD AFTERNOON”或“GOOD NIGHT”

1 个答案:

答案 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;