[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 2003-03-24
3
Medium Priority
?
523 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
1 Comment
 
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

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
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

611 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