Subject | Problem with field length |
---|---|
Author | Herbert.Augustiny@sptroth.com |
Post date | 2001-12-11T10:09:46Z |
Hi
I have a table where I declare a char(10) field and then in an insert
statement I insert a string which is to long (maybe 30 chars). Surprisingly
this works fine. Also when I do a select in isql on this table I am getting
the whole string and not just the first 10 chars. But if I do a select
using interclient I am getting an exception:
SQL error code = -303
arithmetic exception, numeric overflow, or string truncation
Here is the script I am using to reproduce this behavior:
CREATE DATABASE 'db:/dbs/error.gdb'
DEFAULT CHARACTER SET UNICODE_FSS;
create table test(
text CHAR(10)
);
insert into test VALUES('This text is much too long');
Exit;
the Java code looks like this:
database.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:interbase://db/dbs/error.gdb", "sysdba", null, true,
"interbase.interclient.Driver"));
database.setDatabaseName("");
Statement statement = database.createStatement();
try {
ResultSet results = statement.executeQuery("select text from test"); // the exception happens here
statement.close();
}
catch (Exception ex) {ex.printStackTrace();}
}
I am using Firebird super server on Linux.
The version of firebird is 0.9-4 Firebird Test1.
Interserver is running on the same box
JDK: 1.3.0-C
Too me this look like a bug. What I expect would either be an error while
executing the insert statement or a truncation of the inserted string, but
never an exception on a select statement. This would case invalid data to
be inserted into the DB and then it breaks the application and maybe even
the DB get inconsistent?
Is this addressed in Firebird 1 RC1?
Regards,
Herbert
I have a table where I declare a char(10) field and then in an insert
statement I insert a string which is to long (maybe 30 chars). Surprisingly
this works fine. Also when I do a select in isql on this table I am getting
the whole string and not just the first 10 chars. But if I do a select
using interclient I am getting an exception:
SQL error code = -303
arithmetic exception, numeric overflow, or string truncation
Here is the script I am using to reproduce this behavior:
CREATE DATABASE 'db:/dbs/error.gdb'
DEFAULT CHARACTER SET UNICODE_FSS;
create table test(
text CHAR(10)
);
insert into test VALUES('This text is much too long');
Exit;
the Java code looks like this:
database.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:interbase://db/dbs/error.gdb", "sysdba", null, true,
"interbase.interclient.Driver"));
database.setDatabaseName("");
Statement statement = database.createStatement();
try {
ResultSet results = statement.executeQuery("select text from test"); // the exception happens here
statement.close();
}
catch (Exception ex) {ex.printStackTrace();}
}
I am using Firebird super server on Linux.
The version of firebird is 0.9-4 Firebird Test1.
Interserver is running on the same box
JDK: 1.3.0-C
Too me this look like a bug. What I expect would either be an error while
executing the insert statement or a truncation of the inserted string, but
never an exception on a select statement. This would case invalid data to
be inserted into the DB and then it breaks the application and maybe even
the DB get inconsistent?
Is this addressed in Firebird 1 RC1?
Regards,
Herbert