Page 1 of 1

INSERT BLOB

Posted: Wed 22 Aug 2012 16:06
by zzzato
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? ... lob#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

Re: INSERT BLOB

Posted: Thu 23 Aug 2012 09:53
by AlexP
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

Re: INSERT BLOB

Posted: Thu 23 Aug 2012 10:27
by zzzato
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.

Re: INSERT BLOB

Posted: Thu 23 Aug 2012 11:57
by AlexP
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();