我象实现的功能是:
如果现在的时间是8:00到16:00间
执行语句select to_date(sysdate,'yyyy') from dual
如果现在的时间是16:00到00:00间
执行语句select to_date(sysdate,'yyyy-mm') from dual
如果现在的时间是00:00到08:00间
执行语句select to_date(sysdate,'yyyy-mm-dd') from dual
我写的这句老是有错误,也不知道错在哪里。
if to_char(sysdate,'hh24') >=08 and to_char(sysdate,'hh24')<16 then
select to_date(sysdate,'yyyy') from dual;
elsif to_char(sysdate,'hh24') >=16 and to_char(sysdate,'hh24')<00 then
select to_date(sysdate,'yyyy-mm') from dual;
elsif to_char(sysdate,'hh24') >=00 and to_char(sysdate,'hh24')<08 then
select to_date(sysdate,'yyyy-mm-dd') from dual;
end if;
如果现在的时间是8:00到16:00间
执行语句select to_date(sysdate,'yyyy') from dual
如果现在的时间是16:00到00:00间
执行语句select to_date(sysdate,'yyyy-mm') from dual
如果现在的时间是00:00到08:00间
执行语句select to_date(sysdate,'yyyy-mm-dd') from dual
我写的这句老是有错误,也不知道错在哪里。
if to_char(sysdate,'hh24') >=08 and to_char(sysdate,'hh24')<16 then
select to_date(sysdate,'yyyy') from dual;
elsif to_char(sysdate,'hh24') >=16 and to_char(sysdate,'hh24')<00 then
select to_date(sysdate,'yyyy-mm') from dual;
elsif to_char(sysdate,'hh24') >=00 and to_char(sysdate,'hh24')<08 then
select to_date(sysdate,'yyyy-mm-dd') from dual;
end if;
解决方案 »
- 高分向高手请教,急急急!!!!
- oracle dataguard ora-12523:tns 监听程序未找到合适于客户机连接的例程
- 一个关于级联表操作的简单问题????大家快帮忙阿~~~
- 请问user_TABLESPACES和dba_TABLESPACES有什么区别吗?
- Credential retrieval failed
- 触发器的简单问题,马上结帐
- 请问:Oracle9i For Linux的最低硬件要求
- 在oracle9i中怎样连接其它异构数据库?
- ORACLE8,关键字可以有自动增量吗??解决马上结贴
- 谁用过utl_smtp包,可以有抄送吗?可以有附件吗?
- sqlserver oracle 数据转换
- left outer join 问题
select to_date(sysdate,'yyyy-mm') from dual
select to_date(sysdate,'yyyy-mm-dd') from dual
3句语句本身就是错误的
select to_date(sysdate,'yyyy') from dual
select to_date(sysdate,'yyyy-mm') from dual
select to_date(sysdate,'yyyy-mm-dd') from dual
换成
select to_char(sysdate,'yyyy-mm-dd') from dual
select to_char(sysdate,'yyyy-mm-dd hh24') from dual
select to_char(sysdate,'yyyy-mm-dd hh24:mi') from dual
可以吗?
select to_date(sysdate,'yyyy') from dual;
elsif to_number(to_char(sysdate,'hh24')) >=16 and to_number(to_char(sysdate,'hh24'))<0 then
select to_date(sysdate,'yyyy-mm') from dual;
elsif to_number(to_char(sysdate,'hh24')) >=0 and to_number(to_char(sysdate,'hh24'))<8 then
select to_date(sysdate,'yyyy-mm-dd') from dual;
end if;
单独这样执行可以declare aaa date;
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into aaa from dual;end;
单独这样执行可以如果在pl\sql段中,要加 into
declare aaa date;
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into aaa from dual;end;
我在机械工业出版社出的“Oracle9I初学者指南”中看到上门的例子也只有存储过程。