PL / SQL存储过程错误

时间:2016-05-05 20:53:07

标签: oracle stored-procedures plsql

这是我在PL / SQL中编写的代码我试图从csv文件读取数据并插入到Oracle数据库的表中。

通常,当我插入时间戳值时,我会执行以下操作

insert into t (start_time) values 
(TO_TIMESTAMP('12-SEP-12 10.31.19','DD-MON-YY HH.MI.SS'))

现在我从病房的这些线路上得到错误,如下所示

  

f_call_start:= to_timestamp(substr(l_line,comma2 + 1,comma3-comma2-1),'DD-MON-YY HH.MI.SS');       错误(38,28):PLS-00306:调用'SUBSTR'时参数的数量或类型错误

call_record_processor('calldata');


create or replace procedure call_record_processor(file_name_input in varchar2)
is
l_file UTL_FILE.file_type;
l_line varchar2(100);
l_eof boolean:=false;
comma1 varchar2(10);
comma2 varchar2(10);
comma3 varchar2(10);
comma4 varchar2(10);

f_source_no call_usage.source_phone_number%type;
f_dest_no call_usage.destination_phone_number%type;
f_call_start call_usage.call_start_time%type;
f_call_end call_usage.call_end_time%type;

begin
l_file:=UTL_FILE.fopen('c:\temp\',file_name_input,'r');

loop
  begin
  utl_file.get_line(l_file,l_line);
  dbms_output.put_line(l_line);
  EXCEPTION
  when no_data_found then
   exit;
  end;
comma1:=INSTR(l_line,',',1,1);
comma2:=INSTR(l_line,',',1,2);
comma3:=INSTR(l_line,',',1,3);
comma4:=INSTR(l_line,',',1,4);

f_source_no:=SUBSTR(l_line,1,comma1-1);
dbms_output.put_line('source_phone_number='||f_source_no);

f_dest_no:=SUBSTR(l_line,comma1+1,comma2-comma1-1);
dbms_output.put_line('destination_phone_number='||f_dest_no);

f_call_start:=to_timestamp(substr(l_line,comma2+1,comma3=comma2-1),'DD-MON-YY HH.MI.SS');
dbms_output.put_line('call_start_time='||f_call_start);

f_call_end:=to_timestamp(substr(l_line,comma3+1,comma4-comma3-1),'DD-MON-YY HH.MI.SS');
dbms_output.put_line('call_end_time='||f_call_end);

insert into call_usage values(f_source_no,f_dest_no,f_call_start,f_call_end);
end loop;
utl_file.fclose(l_file);
COMMIT;
end call_record_processor;

1 个答案:

答案 0 :(得分:0)

应为dbms_output.put_line

相关问题