Search This Blog

Saturday 5 November 2016

ORA-01460: unimplemented or unreasonable conversion requested

I got "ORA-01460: unimplemented or unreasonable conversion requested" error when I pass the large file data from Dot Net application to Oracle server. 

I found that When file data small 100kb or less I am not getting the error but when file data more than 650kb getting the error.

To resolve this issue, I put my cmd.ExecuteNonQuery() function between cmd.Transanction = con.BeginTransaction() and cmd.Transaction.Commit() function.


Before

            try
            {
                string file1Path = @"Text File Path";
                string file2Path = @"XML File Path";

                // Reading File1
                FileStream fs = new FileStream(file1Path, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                byte[] file1 = br.ReadBytes((int)fs.Length);

                // Reading File2
                StreamReader sr2 = new StreamReader(file2Path, Encoding.ASCII);
                string file2 = sr2.ReadToEnd();
                sr2.Close();

                string connection = "Connection String";

                OracleConnection con = new OracleConnection(connection);
                con.Open();
                OracleCommand cmd = new OracleCommand("Procedure Name", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("BLOB_FILE"OracleDbType.Blob)).Value = file1;
                cmd.Parameters.Add(new OracleParameter("CLOB_FILE"OracleDbType.Clob)).Value = file2;

                int i = cmd.ExecuteNonQuery();

                con.Close();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

After

            try
            {
                string file1Path = @"Text File Path";
                string file2Path = @"XML File Path";

                // Reading File1
                FileStream fs = new FileStream(file1Path, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                byte[] file1 = br.ReadBytes((int)fs.Length);

                // Reading File2
                StreamReader sr2 = new StreamReader(file2Path, Encoding.ASCII);
                string file2 = sr2.ReadToEnd();
                sr2.Close();

                string connection = "Connection String";

                OracleConnection con = new OracleConnection(connection);
                con.Open();
                OracleCommand cmd = new OracleCommand("Procedure Name", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("BLOB_FILE"OracleDbType.Blob)).Value = file1;
                cmd.Parameters.Add(new OracleParameter("CLOB_FILE"OracleDbType.Clob)).Value = file2;

                cmd.Transaction = con.BeginTransaction();
                int i = cmd.ExecuteNonQuery();
                cmd.Transaction.Commit();
                con.Close();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }


Script

CREATE TABLE TestTable
(
  BLOB_FILE        BLOB,
  CLOB_FILE        CLOB
)

create or replace procedure USP_INS_TestTable(BLOB_FILE IN BLOB,
                                              CLOB_FILE IN CLOBAS
begin
  insert into TestTable (BLOB_FILE, CLOB_FILE) values (BLOBFILE, CLOBFILE);
end USP_INS_TestTable;


Note:-

While sending large data from dot net application to oracle server It's send the chunk data instead of actual data for that cause oracle server send the error "ORA-01460: unimplemented or unreasonable conversion requested".

No comments:

Post a Comment