1

作業中のパラメーターをテストするために日付を挿入すると、エラーが発生します。エラーは次のとおりです。

01858. 00000 -  "a non-numeric character was found where a numeric was expected"
*Cause:    The input data to be converted using a date format model was
           incorrect.  The input data did not contain a number where a number was
           required by the format model.
*Action:   Fix the input data or the date format model to make sure the
           elements match in number and type.  Then retry the operation.

ここに私のテストスクリプトがあります:

set serveroutput on
declare
  type tempcursor is ref cursor;
  v_cur_result tempcursor;
  errcode number;
  errmesg varchar2(1000);
  p_statusmnemonic_in         acts.ct_cu_act_medrecon_pg.varchararrayplstype;
  p_processtypemnemonic_in    transactionprocesslog.processtypemnemonic%type; 
  p_primarymemberplanid_in    membermedicalreconcilationhdr.primarymemberplanid%type;
  p_assigneduserid_in         membermedicalreconcilationhdr.assigneduserid%type;
  p_accountorgid_in           membermedicalreconcilationhdr.accountorgid%type;
  p_reconstatusmnemonic_in    membermedicalreconcilationhdr.reconciliationstatusmnemonic%type;
  p_estimatedenddt_in         membermedicalreconcilationhdr.estimatedenddt%type;
  p_actualenddt_in            membermedicalreconcilationhdr.actualenddt%type;
  p_inserteddate_in           membermedicalreconcilationhdr.inserteddt%type;
  p_insertedby_in             membermedicalreconcilationhdr.insertedby%type;
  p_updateddate_in           membermedicalreconcilationhdr.updateddt%type;
  p_updatedby_in           membermedicalreconcilationhdr.updatedby%type;

begin
  p_statusmnemonic_in(1) := ('OPEN');
  p_statusmnemonic_in(2) := ('SUSPENDED_PRIOR_TO_COMPARE');
  ct_cu_act_medrecon_pg.sps_get_patientmedrecs_hdr      
  (p_statusmnemonic_in,'NO','26-JAN-14',v_cur_result, errcode, errmesg);

   loop
fetch v_cur_result into     p_primarymemberplanid_in,p_assigneduserid_in,p_accountorgid_in,p_reconstatusmnemonic_in,
                        p_estimatedenddt_in,p_actualenddt_in,p_inserteddate_in,p_insertedby_in,
                        p_updateddate_in,p_updatedby_in,p_processtypemnemonic_in;

  dbms_output.put_line(' planid '||p_primarymemberplanid_in||' userid '||p_assigneduserid_in);

  exit when v_cur_result%notfound;
  end loop;

  dbms_output.put_line(' error code '||errcode||' message '||errmesg);
end;

日付が「24-JAN-13」に設定されている場合、エラーは発生しませんが、2番目に何かを変更するとエラーが発生します。私が見ている表の2つの推定日付フィールドは次のとおりです。

24-JAN-13 04.29.19.989847000 PM
28-JAN-13 08.52.27.187015000 PM

ここに私の手続きがあります:

  procedure sps_get_patientmedrecs_hdr (
    p_statusmnemonic_in       in varchararrayplstype,
    p_processtypemnemonic_in  in transactionprocesslog.processtypemnemonic%type,
    p_estimatedenddt_in       in membermedicalreconcilationhdr.estimatedenddt%type,
    p_return_cur_out          out sys_refcursor,
    p_err_code_out            out number,
    p_err_mesg_out            out varchar2)
  is
     lv_varchararray         varchararray := varchararray();
  begin
    if p_statusmnemonic_in.count > 0
    then
      for rec1 in 1..p_statusmnemonic_in.count
      loop
        lv_varchararray.extend(1);
        lv_varchararray(rec1) := p_statusmnemonic_in(rec1);
      end loop;

        open p_return_cur_out for
        select h.membermedreconciliationhdrskey,
               h.primarymemberplanid,
               h.assigneduserid,
               h.accountorgid,
               h.reconciliationstatusmnemonic,
               h.estimatedenddt,
               h.actualenddt,
               h.inserteddt,
               h.insertedby,
               h.updateddt,
           h.updatedby
        from membermedicalreconcilationhdr h
        where h.reconciliationstatusmnemonic in (select *
                                             from table (cast(lv_varchararray as varchararray)))
        and h.estimatedenddt <= nvl(p_estimatedenddt_in, h.estimatedenddt)
        and not exists (select *
                        from transactionprocesslog tpl
                        where tpl.transactiontypemnemonic = 'MEDREC'
                        and tpl.transactionid = h.primarymemberplanid
                        and nvl(p_processtypemnemonic_in, tpl.processtypemnemonic) = tpl.processtypemnemonic);
    else
        open p_return_cur_out for
        select h.membermedreconciliationhdrskey,
               h.primarymemberplanid,
               h.assigneduserid,
               h.accountorgid,
               h.reconciliationstatusmnemonic,
               h.estimatedenddt,
               h.actualenddt,
               h.inserteddt,
               h.insertedby,
               h.updateddt,
               h.updatedby
        from membermedicalreconcilationhdr h; 
    end if;

  p_err_code_out := 0;  
  exception
    when others then
      p_err_code_out := -1;
      p_err_mesg_out := 'error in ct_cu_act_medrecon_pg.sps_get_patientmedrecs_hdr => ' || sqlerrm;
  end sps_get_patientmedrecs_hdr;

to_date 関数を試しましたが、同じエラーが発生しました。事前に感謝します。

4

1 に答える 1

0

文字列を日付のように扱っているようですが、NLS の設定によっては機能する場合と機能しない場合があります。Oracle は、日付を期待する文字列を検出すると、その文字列が特定のセッションの日付フォーマット パラメータと一致するかどうかに基づいて、暗黙的な日付変換を試みます。これは非常に一般的なエラーの原因です。

適切な日付を使用するには、次のように to_date 関数を使用できます。

to_date('26-JAN-14','DD-MON-RR')

または、日付リテラルを指定するためのネイティブ構文を使用します。これは私が推奨するものです。

date'2014-1-26'
于 2013-02-13T20:35:45.797 に答える