INSERT BLOB

INSERT BLOB

Postby zzzato » Wed 22 Aug 2012 16:06

Hi, all.
After stored procedure, now I need to insert a record with a blob field.
...and I fail: ORA-01460.

I've a simple table with only one blob field
I try to use TSqlQuery with this sql statement:
INSERT INTO TESTBLOB VALUES(:AIMAGE);

As first, I see param AImage has not datatype and paramtype.
I tried settings these properties and without do it: same result.

I read this post:
http://forums.devart.com/viewtopic.php?f=9&t=9493&p=26471&hilit=insert+blob#p26471

1) this post has not info about HOW i must use returned xlob param.

2) linked post is too old. Maybe today I need too do operation in same mode?


TIA
zzzato
 
Posts: 12
Joined: Mon 20 Aug 2012 08:47

Re: INSERT BLOB

Postby AlexP » Thu 23 Aug 2012 09:53

Hello,

The method provided in the topic is a correct variant for loading BLOB data into a table.
When using procedures, we can define the type of the parameters, since the server can return the parameter types used in a procedure.
When using parameters in SQL-statement, server neither defines nor returns their types, therefore you should specify parameter types manually
AlexP
Devart Team
 
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: INSERT BLOB

Postby zzzato » Thu 23 Aug 2012 10:27

Ok. But I need a little help...

I use a TSqlQuery with this statement:
INSERT INTO TABLE(ID,DATA) VALUES (1, empty_blob()) RETURNING DATA INTO :DATAPAR

:DATAPAR is output and ftBlob param, ok?

So:

MyQuery.ParamByName('id').AsBcd := 100;
MyQuery.ExecSql;
MyQuery.ParamByName('datapar').LoadFromFile('c:\sexygirlwallpaper.jpg');

MyQuery. what I need to do, now?

Is LoadFromFile (or LoadFromStream..) sufficient to put data on table?

Bye, and many thanks for your quick response.
zzzato
 
Posts: 12
Joined: Mon 20 Aug 2012 08:47

Re: INSERT BLOB

Postby AlexP » Thu 23 Aug 2012 11:57

hello,

There is a code below for inserting BLOB data (the parameter must be ptInput)

Code: Select all
 
    SQLQuery1.SQL.Text := 'INSERT INTO TABLE(ID,DATA) VALUES (1, empty_blob()) RETURNING DATA INTO :ATAPAR';
  SQLQuery1.ParamByName('DATA').DataType := ftOraBlob;
  SQLQuery1.ParamByName('DATA').ParamType := ptInput;
  SQLQuery1.ParamByName('DATA').LoadFromFile('d:\fish.bmp', ftOraBlob);
  SQLQuery1.ExecSQL();
AlexP
Devart Team
 
Posts: 5530
Joined: Tue 10 Aug 2010 11:35


Return to dbExpress driver for Oracle