?
Solved

Can't give byte[]-Parameter into Oracle Stored Procedure

Posted on 2003-03-24
3
Medium Priority
?
501 Views
Last Modified: 2007-12-19
Hello folks,

I want to insert a blob into an Oracle 9 Database, but I always get the error message "ORA-01460 unimplemented or unreasonable conversion requested" when I try this:

C# function:

public void SQLExec(string Proc,string Para1Name,decimal Para1Wert,string Para2Name,byte[] Para2Wert)
{
     OleDbDataReader reader = null;
     OleDbParameter l_key;
     OleDbCommand cmd;
     
     int l_nr = OpenDB();
     cmd = ((OleDbCommand)DBComm[l_nr]);

     cmd.CommandText=Proc;                    
     cmd.CommandType = CommandType.StoredProcedure;
                   
     l_key = cmd.Parameters.Add("@"+Para1Name, OleDbType.Decimal);
     l_key.Value = Para1Wert;
     l_key.Direction = ParameterDirection.Input;

     l_key = cmd.Parameters.Add("@"+Para2Name, OleDbType.Binary);  // also used OleDbType.LongVarBinary...
     l_key.Value = Para2Wert;
     l_key.Direction = ParameterDirection.Input;
     
     reader = cmd.ExecuteReader();
     reader.Close();

     cmd.Parameters.Clear();
     DBStatus[l_nr] = (int)0;
}

Oracle procedure:

create or replace procedure Write_Blob(
  a_Pkey in number,
  a_Img in long raw -- also tried raw or blob...
) is
begin
  null; --only for testing...
end Write_Blob;


Anybody an idea, what I'm doing wrong?? Is there really no way to input a byte array into a procedure :-((

Thanks

Sabine
0
Comment
Question by:ACGT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 340 total points
ID: 8202350
SQL usually accepts binary data in the folowing form when supplied in textual format:

0xHHHHHH (where HH is a hex pair representig a byte, and there can be as many of these as you like).

Since I do not use Oracle, I have no idea whether this helps, but you may try with the following:

          public static string DbBytesToString(byte[] data) {
               return DbBytesToString(data, 0, data.Length);
          }
     
          public static string DbBytesToString(byte[] data, int offset, int length) {
               StringBuilder result=new StringBuilder(2+length*2);
               result.Append("0x");
               while (length-->0) {
                    result.Append(data[offset++].ToString("X2"));
               }
               return result.ToString();
          }
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question