Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select query with a parameter value that is longer than the size of the column results in an exception [DNET384] #389

Closed
firebird-automations opened this issue Jun 7, 2011 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: Ruben Rorije (rubenrorije)

I upgraded my .Net DataProvider from 2.5.2 to 2.6.5.
A simple select query that ran with no problems using the 2.5.2 version, will now throw an exception when using the 2.6.5 version.

When I execute a query with a (string)parameter value that is longer than the size of the column in the database an IscException occurs.

the error code is: 335544321 and the message is 'Arithmetic overflow or division by zero has occurred. arithmetic exception, numeric overflow, or string truncation. string right truncation.'

If it is possible I would like the behaviour of the 2.5.2 version back, because it makes my code a lot simpler. Otherwise I have to make sure a user can not enter data that will result in an exception.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

You have to specify length of parameter explicitly.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Author

Commented by: Ruben Rorije (rubenrorije)

That is a problem. I can not change the whole user interface to prevent the users to enter too long strings.
Furthermore I have to check my code in all places that the values I use to query the database are not longer than the columns, or in case of expressions, longer than the combined columns.

It seems, but I did not check this extensively, that the value of the parameter will be truncated when the length of the parameter is set.
I think this will result in incorrect results when the value in the parameter is truncated and coincidentally is equal to a value in the database that has the maximum length of the column.

I hope this is not the case, because that will produce the wrong results in my application.

@firebird-automations
Copy link
Author

Commented by: Ruben Rorije (rubenrorije)

Because I was not sure, that the behaviour in the new version is not the correct behaviour.
I also checked how, for instance, Sql-server handles the case.
In Sql-server no exception is thrown and no results are returned. Which is exactly what I would like the .Net Data Provider to do.

By the way, I am very much pleased with the .Net DataProvider and this is the first issue I have run into since we are using the .Net dataprovider.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

It's not about UI, but about FbParameter.

The value is truncated to size you specify, be it whatever value you feel comfortable. If you look at tracker items, you'll find this behavior was done to align with SqlClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants