Subject | Re: conversion error from string |
---|---|
Author | rrokytskyy |
Post date | 2002-05-28T09:55:35Z |
Hi,
This is likely not a driver issue. GDSException is exception from
database. But why do you use such complex algorithm to generate next
ID? You could get same results by using generators and simple
trigger:
CREATE GENERATOR id_rechnung_gen;
CREATE TRIGGER trig_name FOR your_table BEFORE INSERT
BEGIN
NEW.id_rechnung = gen_id(id_rechnung_gen, 1);
END
Your algorithm is also not 100% correct, because you might get same
id in two concurrently executing transaction. Generators were
designed exactly for this purpose, they are out of transaction
control and guarantee unique value.
Best regards,
Roman Rokytskyy
This is likely not a driver issue. GDSException is exception from
database. But why do you use such complex algorithm to generate next
ID? You could get same results by using generators and simple
trigger:
CREATE GENERATOR id_rechnung_gen;
CREATE TRIGGER trig_name FOR your_table BEFORE INSERT
BEGIN
NEW.id_rechnung = gen_id(id_rechnung_gen, 1);
END
Your algorithm is also not 100% correct, because you might get same
id in two concurrently executing transaction. Generators were
designed exactly for this purpose, they are out of transaction
control and guarantee unique value.
Best regards,
Roman Rokytskyy
--- In Firebird-Java@y..., Carsten Schäfer <ca_schaefer@g...> wrote:
> Hi,
> sometimes i get the following exception when i call exceuteUpdate
on a PreapredStatement:
> java.sql.SQLException: GDS exception:
org.firebirdsql.gds.GDSException: conversion error from string "1432"
> at org.firebirdsql.jdbc.FBPreparedStatement.internalExecute
(FBPreparedStatement.java:491)
> at org.firebirdsql.jdbc.FBPreparedStatement.executeUpdate
(FBPreparedStatement.java:151)
>
> There are some setString()-calls im my method, but i'm 100% sure
that not with '1432'.
> But it is possible that my id-column(type integer) has an highest
entry with 1432.
> In my insert statement i do insert.setInt(1, -999) on this id
column.
> I have an after insert trigger like this:
> BEGIN
> update t_rechnung set id_rechnung = (select max(id_rechnung) + 1
FROM t_rechnung) where
> NEW.id_rechnung = id_rechnung;
> END
>
> I only get this on the table t_rechnung (only sometimes), but I've
other tables that looks analog to t_rechnung (with id-column and
after insert trigger) where i never gets this exception.
>
> Some explanation ?
>
> gruse
> Carsten