Cast object type between C# and Oracle

Cast object type between C# and Oracle

I have got an issue with cast object. I tried to resolve it for a couple of hours. It has to do with data type - raw in Oracle and byte in C#. They seem not compatible.

I have got an issue with cast object. I tried to resolve it for a couple of hours. It has to do with data type - raw in Oracle and byte in C#. They seem not compatible.

Function in Oracle

function dupCheck(i_vendor varchar2,i_transactionnumber varchar2) return raw
is
transactionId raw(16);

BEGIN

select id into transactionId from (select tx.id,row_number() over (order by tx.trans_time asc) as seqnum
from test_tx_log tx
where tx.transactionnumber = i_transactionnumber and lower(tx.vendor) = lower(i_vendor)) tx where seqnum = 1;

return transactionId;

exception
when no_data_found then
return transactionId;

END;

C#

using (DbCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "mca_test_package.dupCheck";
                    command.AddParameter("i_vendor", DbType.String, tx.Vendor);
                    command.AddParameter("i_transactionnumber", DbType.String, tx.TransactionNumber.Trim());
                    command.AddParameter("transactionId", DbType.Byte, DBNull.Value, ParameterDirection.ReturnValue,16);

                command.ExecuteNonQuery();
                var txId = new Guid((byte[])command.Parameters["transactionId"].Value);



                byte[] buffer = new byte[16];
                Guid id = new Guid(buffer);
                bool result = (id == txId);

                if (result)
                {
                    tx.status = "Success";
                    Console.WriteLine("No Duplicate {0}", tx);

                }
                else
                {
                    Console.WriteLine("Duplicate {0}", tx);
                    tx.status = "RejectedDuplicate";
                }

Get the error


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

Variable Introduction in C#[Bangla]

LIKE | COMMENT | SHARE | SUBSCRIBE A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...