If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Insert JPEG into BLOB error, Help me please.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-10, 08:31
paracet2000 paracet2000 is offline
Registered User
 
Join Date: Sep 2010
Posts: 4
Insert JPEG into BLOB error, Help me please.

I used Delphi.
This work well with MYSQL but error with DB2.

//===================================//
Function TfrmMainScanPict.SavePict(Qry: TADOQuery): String;
Var
hn,cPath,s2:string;
fS : TFileStream;
begin
Result:='Start';
hn:=Trim(ListBox1.Items[0]);
cPath:='C:\TempScan.JPG';

fs:=TFileStream.Create(cPath, fmOpenRead);

Try
s2:='select OP_HN,PIC_AUTO,PIC_RESULT from LAB_RESULT_PICT'
+' WHERE OP_HN='''+HN+'''';
Qry.Close;
Qry.SQL.Clear;
Qry.SQL.Add(s2);
Qry.Open;
Qry.Insert;
Qry.FieldByName('OP_HN').AsString:=HN;
Qry.FieldByName('PIC_AUTO').AsInteger:=Qry.RecordC ount+1;
Qry.FieldByName('PIC_DATETIME').AsDateTime:=Now;
TBlobField(Qry.FieldByName('PIC_RESULT')).LoadFrom Stream(fs);
Try
Qry.Post; // Error occure here said = 0
Except on E:Exception do
Result:= E.Message;
End;
Result:='Success';
Finally
fs.Free;
End;
end;
//==================================//

database structure
==============
CREATE TABLE LAB_RESULT_PICT(
OP_HN CHAR(13) NOT NULL'
,PIC_AUTO INTEGER NOT NULL'
,PIC_DATETIME TIMESTAMP WITH DEFAULT CURRENT TIMESTAMP
,PIC_RESULT BLOB(1024)'
,CONSTRAINT PK_LABRESPICT1 PRIMARY KEY(OP_HN,PIC_AUTO))

Last edited by paracet2000; 09-15-10 at 08:42.
Reply With Quote
  #2 (permalink)  
Old 09-15-10, 08:39
paracet2000 paracet2000 is offline
Registered User
 
Join Date: Sep 2010
Posts: 4
Error picture

Error picture attachDb2 image jpeg.bmp
Reply With Quote
  #3 (permalink)  
Old 09-15-10, 10:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Are you trying to assign values to the result of a SELECT statement? That's not how it should be done. Try an UPDATE statement instead.
Reply With Quote
  #4 (permalink)  
Old 09-19-10, 02:47
paracet2000 paracet2000 is offline
Registered User
 
Join Date: Sep 2010
Posts: 4
Thank a lot

This new to me.
I try to do with your advice it work by use INSERT statement.
And i went back to test with MYSQL it work too.
So both SELECT statatement and INSERT statement work with MYSQL,
but only INSERT work with DB2.
Reply With Quote
Reply

Tags
db2, insert, jpeg

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On