--获取系统的当前时间的函数,以字符形式返回(这样写为什么创建失败?????????)
create or replace function get_current_string_date return char(100)
is
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
return current_date;
exception
when others
return 'error';
end get_current_string_date;
--但是采用这样测试又可以
declare
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
dbms_output.put_line(current_date);
exception
when others then
dbms_output.put_line('error');
end;
create or replace function get_current_string_date return char(100)
is
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
return current_date;
exception
when others
return 'error';
end get_current_string_date;
--但是采用这样测试又可以
declare
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
dbms_output.put_line(current_date);
exception
when others then
dbms_output.put_line('error');
end;
解决方案 »
- 求高手,解决行列之间数据插入问题,感激不尽
- aix系统上安装oracle数据库表空间选择
- 分组统计中某一个字段重复的只统计一次,怎么实现
- 用Oracl.DataAccess.Client.OracleConnection出现异常ORA-12154:TNS:无法解析指定的连接标识符
- 求一SQL语句(找最大值)
- 一个服务器的表导入到另一个服务器上,在线等!
- 我装的是ORACLE 8I 被我关闭了一下。再启动时就不行了.只是已启动,但不是打开状态,.急
- oralce9中如何处理单引号?在线急
- 如何在 ORACLE SQL *PLUS 中建立存储过程?
- 如何把二进制的源文件加载到数据库的目标表(空表)中? oracle数据库
- 分组复杂查询
- 在linux下,启动oracle,提示LRM-00109: could not open parameter file.. initorcl.ora文件
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
return current_date;
exception
when OTHERS THEN return 'error';
end get_current_string_date;
create or replace function get_current_string_date
return char-- 这里不需要指定大小
is
current_date char(100);
begin
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') into current_date from dual;
return current_date;
exception
when others then --少了关键字then
return 'error';
end get_current_string_date;select get_current_string_date from dual;GET_CURRENT_STRING_DATE
------------------------------
2011-03-25 10:06:27