Q&A

  • DBerror : Type mismatch in expression.
파라독스 db를 사용하는데 insert시 'Type mismatch in expression.' 에라가
발생하고 있습니다. 왕초보인 제가 아무리 해봐도 답을 찾지 못하겠네요...

발생하고 있는 부분이...
      params.ParamByName('tp').Value
      := PriceRegForm.StringGrid1.Cells[2,igc];
입니다.
'tp'는 type이 'NUMBER'로 정의되어 있습니다.
PriceRegForm.StringGrid1.Cells[2,igc]의 값은 숫자입니다.

고수님의 도움 부탁합니다....

<원 소스>
=====================================
Function TB_100_INS(I_date: String; I_seq: Integer;
                       igc: Integer): String;

var egr,egc : string;

begin

  egr := 'I_date = '   + I_date +
         ' I_seq = '   + intTostr(I_seq) +
         '   igr = '   + intTostr(igc) +  '  '  +
         PriceRegForm.StringGrid1.Cells[0,igc] + ' ' +
         PriceRegForm.StringGrid1.Cells[1,igc] + ' ' +
         PriceRegForm.StringGrid1.Cells[2,igc] + ' ' +
         PriceRegForm.StringGrid1.Cells[3,igc] + ' ' +
         PriceRegForm.StringGrid1.Cells[4,igc];

  ShowMessage(egr);

  Try
  query1 := Tquery.create(application);
  query1.DatabaseName := 'DBTEST';


  with query1 do
  begin
      Close;
      SQL.Clear;
      SQL.Add('Insert into TT_100_DD ');             // db name
      SQL.ADD('values( :td, :ts, :tc, :tn, :tp, ');   // 컬럼명
      SQL.ADD(      '  :tq, :tt )');

      params.ParamByName('td').asdate
      := StrToDate(I_date);
      params.ParamByName('ts').asinteger
      := I_seq;
      params.ParamByName('tc').Value
      := PriceRegForm.StringGrid1.Cells[0,igc];
      params.ParamByName('tn').asstring
      := PriceRegForm.StringGrid1.Cells[1,igc];
      params.ParamByName('tp').Value
      := PriceRegForm.StringGrid1.Cells[2,igc];
      params.ParamByName('tq').Value
      := PriceRegForm.StringGrid1.Cells[3,igc];
      params.ParamByName('tt').Value
      := PriceRegForm.StringGrid1.Cells[4,igc];

      try
         prepare;
         execsql;
         w_return :='1';
         ShowMessage('INSERT OK!!!');
      except
         on E: EDBEngineError do
         begin
            sterr_no := inttostr(E.Errors[0].ErrorCode);
            sterr_pg := 'TB_100_INS';
            sterr_tb := 'TT_100_DD';
            sterr_mg := E.Message;
            w_return := '0';
            Error_msg := sterr_no + ' : ' +
                         sterr_pg + ' : ' +
                         sterr_tb + ' : ' +
                         sterr_mg + ' : ' +
                         w_return;
            TEST_error(Error_msg);
         end;
         on E: Exception do
         begin
            sterr_no := inttostr(E.Errors[0].ErrorCode);
            sterr_pg := 'TB_100_INS';
            sterr_tb := 'TT_100_DD';
            sterr_mg := E.Message;
            w_return := '0';
            Error_msg := sterr_no + ' : ' +
                         sterr_pg + ' : ' +
                         sterr_tb + ' : ' +
                         sterr_mg + ' : ' +
                         w_return;
            TEST_error(Error_msg);
         end;
      end;
  end;

  finally
   query1.free;
  end;

end;
========================================

db 정의 ==> 첨부파일 참조
2  COMMENTS
  • Profile
    라벤더 2005.04.09 02:08



    안녕하세요..

    Value말고 AsFloat로 값을 대입해보세요..


    그래도 안되면

    parambyname('tp').asstring := FlostToStr(PriceRegForm.StringGrid1.Cells[2,igc]);

    이렇게 한번 해보세요..

    예전에 오라클 사용할 때 Number형이 문제를 일으켰는데;

    파라독스도 그런가보네요 ;; 이상하네요 -ㅁ- ;
  • Profile
    Unistar 2005.04.09 04:30

    님 말씀대로 하니까 잘 되었습니다.

    너무~너무 감사합니다.....