Board index » delphi » Problem inserting blob field into another blob field using two ibsql

Problem inserting blob field into another blob field using two ibsql

Hi Jeff.

I need pass one blob to a ibsql param from ibsql field, and inserting in
one table. I try following code, first with tblobstream and
later with tstream, but don't work. Any idea?

procedure TForm1.Button1Click(Sender: TObject);
var
   Stream1 : TBlobStream; stream :tmemorystream;
begin
   stream.create;
   IBSQL1.ExecQuery;  //select field imagen from one table
   IBSQL1.fieldbyname('imagen').SaveToStream(stream);   -> error here too
//Stream1 := TBlobStream.Create(IBSQL1.fieldbyname('imagen'),bmRead);->
error here
   IBSQL2.ParamByName('IMAGEN').LoadFromStream(stream);
   IBSQl2.ParamByName('entero').Asinteger:=141234;
   IBSQl2.ParamByName('pk').asinteger:=93834;
     try
       IBSQL2.ExecQuery;
     finally
       Stream1.Free;
       stream.free;
     end;

   end;

select sentence for ibsql1 are 'select imagen from datos where pk=1'
where imagen is a blob field. and
select sentence for ibsql2 are
'Insert into DATOS
    (IMAGEN,PK)
Values
    (:IMAGEN,:PK)'

Thanks in advance
--

Felipe Molina
CRELIPA S.L.
C/Claudio Coello 31
San Lorenzo del Escorial
28200-Madrid

 

Re:Problem inserting blob field into another blob field using two ibsql


Quote
Felipe Molina wrote:
> Hi Jeff.

I try this code now, but retrive me message 'invalid blob id' both cases

procedure TForm1.Button1Click(Sender: TObject);
var
stream :tmemorystream;
begin
   IBSQL1.ExecQuery;  //select field imagen from one table
   Stream:=TMemorystream.create;
   IBSQL1.FieldByName('imagen').SaveToStream(stream);
   IBSQL2.ParamByName('IMAGEN').loadfromstream(stream);
   IBSQl2.ParamByName('entero').Asinteger:=1412;
   IBSQl2.ParamByName('pk').asinteger:=934;
     try
       IBSQL2.ExecQuery;
     finally
       stream.free;
     end;
   end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   IBSQL1.ExecQuery;  //select field imagen from one table
   IBSQL1.FieldByName('imagen');
   IBSQL2.ParamByName('IMAGEN').Assign(IBSQL1.FieldByName('imagen'));
   IBSQL2.ExecQuery;
end;

any idea?

Both IBsql are attached to same table, so blobs fields are same.

Thanks

--

Felipe Molina
CRELIPA S.L.
C/Claudio Coello 31
San Lorenzo del Escorial
28200-Madrid

Other Threads