日期:2014-05-17  浏览次数:20701 次

请问怎样将这种情况在存储过程中插入进去?
我有一个表写了以函数处理
select   getargvbyindex( '1,2,3,4,2004-11-5   下午   09:08:52 ', ', ',5)   from   dual
结果如下:2004-11-5   下午   09:08:52
我现在要将这个结果传给一个字符串变量
strBuf   :=   getargvbyindex(strArgv, ', ',5);
此时strBuf应该是2004-11-5   下午   09:08:52
请问怎样将他插入到另外一个日期字段sdate里面去;
select   to_date(strBuf, 'yyyy-mm-dd   hh24:mi:ss ')   into   sdate   from   dual;
这个语句执行不成功

必须在存储过程里面



------解决方案--------------------
create or replace procedure sp_test_1 is
mydate date;
v_str_1 varchar(20);
begin
v_str_1:= '2004-11-5 09:08:52 ';
select to_date(v_str_1, 'yyyy-mm-dd hh24:mi:ss ') into mydate from dual;
dbms_output.put_line( 'mydate: '||mydate);
end sp_test_1;


SQL> exec sp_test_1();

mydate: 05-11月-04

PL/SQL procedure successfully completed

------解决方案--------------------
2004-11-5 下午 09:08:52
直接這樣應該是不行的...

如果要明確上下午...還要寫個函數對其加工.
比如,直接把
2004-11-5 上午 09:08:52 -> 2004-11-5 09:08:52
2004-11-5 下午 09:08:52 -> 2004-11-5 21:08:52

這樣變化,再插入就可以了