Unable to insert file into a BLOB field.

rakgol_a

Member²
BLOBS newbie, D7 and DOA V4.0.6.2

I'm getting message below message trying to insert
a file into a blob field.

"A lock, refresh or check cannot be performed without a rowid. Provide a rowid in the query or handle this action in the OnApplyRecord event"

Code:
lobQuery.SQL.Text := 'insert into projfiles(projectid_fk,filename, pfile) values(:PROJID,:FILENAME,:PFILE)';
lobQuery.SetVariable('PROJID', IntToStr(m_projectNumber));
lobQuery.SetVariable('FILENAME', odAddFiles.FileName);

//loc := TLOBLocator.Create(pvSession1, otBLOB);
loc := TLOBLocator.CreateTemporary(pvSession1, otBLOB, true);
lobQuery.DeclareVariable('PFILE', otBLOB);
lobQuery.SetComplexVariable('PFILE', loc);
try
lobQuery.Execute;
loc.LoadFromFile(odAddFiles.FileName);
loc.Free;
pvSession1.Commit;
tblProjFiles.RefreshRecord;

I'm not sure how to get rowid into insert statement.
Any ideas of what I'm doing wrong?

Thanks in advance.
Alfred
 
The dataset for which you are trying to refresh a specific record does not include a rowid. This is required to uniquely identify this record in the database. You can simply add it to the SQL statement of the dataset though. For example:

Old: select * from emp

New: select e.*, rowid from emp e
 
Back
Top