Subject Re: [Firebird-Java] Re: conversion error from string
Author Carsten Schäfer
Normally i use generators and triggers like you described.
But in some cases i need to ensure that there is no space in my ids.
A generator always raises his value.
So if an exception occurs in my application i do a rollback and the next time
i do an insert there is left out a number in my ids. And this is not allowed.

And i have ensured in my java application that only 1 client can call this insert at one time.

gruse
Carsten
----- Original Message -----
From: "rrokytskyy" <rrokytskyy@...>
To: <Firebird-Java@yahoogroups.com>
Sent: Tuesday, May 28, 2002 11:55 AM
Subject: [Firebird-Java] Re: conversion error from string


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

--- 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



To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/