--获取系统的当前时间的函数,以字符形式返回(这样写为什么创建失败?????????)
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;
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
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;你的CHARis 在一起了,应该分开,才可创建!
---建议把CHAR 改成VARCHAR2create 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
return 'error';
end get_current_string_date;