Trying to upload image via UniStoredProcedure

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Rickard
Posts: 1
Joined: Thu 05 Sep 2013 15:33

Trying to upload image via UniStoredProcedure

Post by Rickard » Thu 05 Sep 2013 15:40

I have a table in a PostgreSQL database with a few OID fields. Each OID hold (or can hold) a .png file. The problem I'm having is that I try to upload a new image file using a stored procedure. Or just a UniDac table component for that matter, I get the same error.

Here's a bit of code:
spPostImage.Prepare;
spPostImage.ParamByName( 'p_object_id' ).AsString := qryImagesobject_id.AsString;
spPostImage.ParamByName( 'p_name' ).AsString := qryImagesname.AsString;
spPostImage.ParamByName( 'p_image' ).LoadFromStream( strImage, ftBlob );
spPostImage.Execute;
I've also tried LoadFromFile and AsBlob. The problem is as spPostImage.Execute runs, I get an Access violation at 0000000. I have started a transaction using the connection UniConnection.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Trying to upload image via UniStoredProcedure

Post by DemetrionQ » Fri 06 Sep 2013 15:01

Hello.

When working with Large Object, you can load data to the server in the following way:

when using TUniTable:

Code: Select all

  UniTable1.SpecificOptions.Values['PostgreSQL.OIDAsInt'] := 'False';
  UniTable1.Open;
  UniTable1.Append;
  (UniTable1.FieldByName('OID_field') as TBlobField).LoadFromStream(strImage);
  UniTable1.Post;
when using TUniStoredProc:

Code: Select all

  UniStoredProc1.ParamByName('OID_param').LoadFromStream(strImage, ftOraBlob);
  UniStoredProc1.ExecProc;

Post Reply