Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

Thursday, November 28, 2013

Decimal byte array constructor requires an array of length four containing valid decimal bytes.

This error was very surprising for me. I spent couple of hours with my friends and even search a lot on internet to quikly fix this problem but I could not solved.
Finally I asked one of my senior and he fixed it in a second because he has faced this issue before.
Scenario: I wrote a query which consists of a column returning value like
select avg(tat) from employee.
It was returning values like
12.397339
2.00303
12.9800122
Note: This query was running perfectly in TOAD, SQL Developer while executed at Oracle Server.
When I executed the query in .Net and bind the result to the dataset, i started getting the above exception. I was so much frustrated why it is not executed in .Net when in Oracle the same query is executed.
Reason: Dataset does not support the binding of a value having more than 2 decimal places. So I have to round the values to two decimal places.
Solution: select round(avg(tat),2) from employee
Note: You might also get the message as Accessor is not a parameter accessor.
The reason if the same what I discussed here.