用char也一样:
SQL> select text from user_source where name='TEST_DATE'
2 order by line;
TEXT
--------------------------------------------------------------------------------
procedure test_date(stattime in integer) is
max_d varchar2(32);
begin
select to_char(max(created),'yyyy-mm-dd') into max_d
from user_users
where created>to_date(stattime,'yyyymmdd');
dbms_output.put_line(max_d);
end test_date;
8 rows selected
SQL> exec test_date(20060101);
2006-02-06
PL/SQL procedure successfully completed
SQL> select text from user_source where name='TEST_DATE' order by line;
TEXT
--------------------------------------------------------------------------------
procedure test_date(stattime in char) is
max_d varchar2(32);
begin
select to_char(max(created),'yyyy-mm-dd') into max_d
from user_users
where created>to_date(stattime,'yyyymmdd');
dbms_output.put_line(max_d);
end test_date;
8 rows selected
SQL> exec test_date(20060101);
2006-02-06
PL/SQL procedure successfully completed
SQL> select text from user_source where name='TEST_DATE' order by line;
TEXT
--------------------------------------------------------------------------------
procedure test_date(stattime in varchar2) is
max_d varchar2(32);
begin
select to_char(max(created),'yyyy-mm-dd') into max_d
from user_users
where created>to_date(stattime,'yyyymmdd');
dbms_output.put_line(max_d);
end test_date;
8 rows selected
SQL> exec test_date(20060101);
2006-02-06
PL/SQL procedure successfully completed
SQL> select text from user_source where name='TEST_DATE' order by line;
TEXT
--------------------------------------------------------------------------------
procedure test_date(stattime in number) is
max_d varchar2(32);
begin
select to_char(max(created),'yyyy-mm-dd') into max_d
from user_users
where created>to_date(stattime,'yyyymmdd');
dbms_output.put_line(max_d);
end test_date;
8 rows selected
SQL> exec test_date(20060101);
2006-02-06
PL/SQL procedure successfully completed
SQL>