qry1->Close();
  qry1->SQL->Text = "insert into photoinfo(ID,camerano,photo) select seq_photoinfo.nextval,'1',:photo from dual";
  qry1->Parameters->ParamByName("photo")->LoadFromFile("D:\\158999765933-20-2009-5-25-42ATT0000.jpg", ftBlob);
  qry1->ExecSQL();执行时报“ORA-01461: can bind a LONG value only for insert into a LONG column.”这个错误
请热心的朋友帮忙!

解决方案 »

  1.   

    create table t(c blob);
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    self.ADOQuery1.Close;
    self.ADOQuery1.SQL.Clear;
    self.ADOQuery1.SQL.Add('select * from t where 1=2');
    self.ADOQuery1.Open;
    self.ADOQuery1.Append;
    TBlobField(self.ADOQuery1.FieldByName('c')).LoadFromFile('E:\1.bmp');
    self.ADOQuery1.Post;
    end;
      

  2.   

    begin
    //数据库连接字符串 Provider=OraOLEDB.Oracle.1;Password=manager;Persist Security Info=True;User ID=system;Data Source=orcl
      with adoquery1 do
      begin
        close;
        sql.Clear;
        sql.Add('insert into t values(:c)');
        parameters.ParamByName('c').LoadFromFile('e:\1.bmp',ftblob);
        execsql;
      end;
    end;
      

  3.   


    我测试成功
      ADOQuery1.SQL.Text := 'insert into a(b) values(:aa)';
      ADOQuery1.Parameters.ParamByName('aa').LoadFromFile('c:\1.bmp',ftBlob);
      ADOQuery1.ExecSQL;
      

  4.   

    //insert into photoinfo(ID,camerano,photo) select seq_photoinfo.nextval,'1',:photo from dual解决你这个序列问题,最好给photoinfo表加一个before类型触发器
    create table t(cid number,cblob blob);
    /
    create sequence seq_ID
    minvalue 1
    maxvalue 9999999999
    start with 1
    increment by 1
    nocache
    order;
    /
    create or replace trigger trg_t
    before insert on t
    for each row
    begin
      select seq_id.nextval into :new.cid from dual;
    end;
    /
      

  5.   

    经过各位的指点
    发现一个奇怪的现象
      qry1->SQL->Text = "insert into photoinfo(id,camerano,photo) 
        values(seq_photoinfo.nextval,'2',:photo)";  qry1->SQL->Text = "insert into photoinfo(ID,camerano,photo) 
        select seq_photoinfo.nextval,'1',:photo from dual";用第一种写法就没错了
    用第二写法就报“ORA-01461: can bind a LONG value only for insert into a LONG column.”这个错
    到底是什么原因呢???
      

  6.   

    解决办法如下:
              SQL = "declare v_id int;v_camerano varchar2(20);v_receivetime date;v_AREAID varchar2(20);v_AREANAME varchar2(50);";
              SQL += "begin ";
              SQL += "begin ";
              SQL += "select seq_photoinfo.nextval,'"
              + vMobilTelNo + "',case when '"
              + PhotoDate + "'='' then null else to_date('" + PhotoDate + "','yyyy-mm-dd hh24:mi:ss') end,a.areaid,b.areaname"
              + " into v_id,v_camerano,v_receivetime,v_AREAID,v_AREANAME from collection a,addressunit b where a.areaid=b.areaid and a.collid='"+ vMobilTelNo + "';";
              SQL += "exception when others then return; end;  ";
              SQL += "insert into photoinfo(ID,camerano,receivetime,AREAID,AREANAME,photo) values(v_ID,v_camerano,v_receivetime,v_AREAID,v_AREANAME,:photo);";
              SQL += "end;";