Error: ObjectTypeName must be specified when writing a Blob

Error: ObjectTypeName must be specified when writing a Blob

Postby sGingter » Fri 23 Feb 2007 15:13

I am using the CoreLab.Oracle provider through the OraDirectFactory in version 3.50.9.0.

I want to store a Blob in the Database through a SP. Here's the Code for the parameter:

Code: Select all
command = (IDbConnection)_conn.CreateCommand();
command.CommandText = "FKT_SAVE_LAYOUT";
command.CommandType = CommandType.StoredProcedure;

// .. some params

IDbDataParameter param = DbProviderFactories.GetFactory("CoreLab.Oracle").CreateParameter();
param.ParameterName = "ALAB";
param.DbType = DbType.Object;
param.Direction = ParameterDirection.Input;
command.Add(param);


I am forced to only use the default interfaces to grant compatibility to other databases.

On this Parameter a exception is thrown: "ObjectTypeName must be specified.", but I can't specify the object name on the interface.

Additional Info: The binary data we need to save is in a Byte[].

What's your suggestion to store a Blob (average is around 0.5 to 2 MB, so DbType.Binary is not possible) in the database through the default interfaces?
sGingter
 
Posts: 2
Joined: Fri 23 Feb 2007 14:54

Postby Alexey » Mon 26 Feb 2007 09:37

Try to use DbType.Binary. Should work without restriction you mentioned.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby galiap » Fri 06 Apr 2007 13:16

I want to store a Blob in the Database through a SP.

..pkg_test_blob IS
PROCEDURE set_blob(p_id_io IN OUT NUMBER,
p_blob_i IN BLOB);

The code:
connection.Open();
CoreLab.Oracle.OracleCommand command = new CoreLab.Oracle.OracleCommand("pkg_test_blob.set_blob", connection);
command.Connection = connection;
command.CommandType=System.Data.CommandType.StoredProcedure;
OracleParameter Param1=command.Parameters.Add "P1",OracleDbType.Number);
Param1.Direction = System.Data.ParameterDirection.InputOutput;
Param1.Value = 2;
OracleParameter
Param2=command.Parameters.Add("P2", OracleDbType.Blob, bytes.Length);
Param2.Value = bytes;
int y = command.ExecuteNonQuery();
Console.WriteLine("Y:{0}", y);


And the result is: Y:-1;
And nothing inserts to the DB

Where I do wrong?
galiap
 
Posts: 3
Joined: Fri 06 Apr 2007 13:04

Postby Alexey » Fri 06 Apr 2007 13:26

Do you use direct mode?
Please specify your stored procedure definition.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby galiap » Fri 06 Apr 2007 13:48

stored procedure:
PROCEDURE set_blob(p_id_io IN OUT NUMBER,
p_blob_i IN BLOB) IS
BEGIN
IF p_id_io IS NULL
THEN
INSERT INTO test_blob
(id, blob_data)
VALUES
(test_blob_seq.NEXTVAL, empty_blob())
RETURNING id INTO p_id_io;
END IF;

UPDATE test_blob
SET blob_data = p_blob_i
WHERE id = p_id_io;

END set_blob;

connection string:
connString = @"Data Source=xxx.xxx.xxx.xx:xxxx:/SERV1; User Id = ***; Password = ***; Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0";
galiap
 
Posts: 3
Joined: Fri 06 Apr 2007 13:04

Postby Alexey » Tue 10 Apr 2007 08:04

Try to change parameters' names P1 and P2 to the names from your stored procedure.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby galiap » Tue 10 Apr 2007 14:58

Yes, thanks, it works now. :D
galiap
 
Posts: 3
Joined: Fri 06 Apr 2007 13:04

Postby Alexey » Wed 11 Apr 2007 06:00

You are welcome.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for Oracle