Hello Jon,

from your description I cannot really figure out what your problem is.
First thing you should tell us is what database i.e. DBMS you are using and 
which Empire-db database driver (DBDatabaseDriver...)

Next thing is, that we need to know what your database / table definition looks 
like and what SQL is generated when you insert  / update records.
The latter should be in the logs or you can set a breakpoint in 
DBRowSet.updateRecord() - around line 812.

Finally our examples - which by default use HSQLDB - do the same thing and you 
may want to look at what is different.

In any case it should not have anything to do with DBSQLScript at all.

Regards
Rainer


> from: Jon Frias [mailto:[email protected]]
> to: [email protected]
> re: empire db 2.4.1: running scripts and autoGenerated fields
> 
> Hi all,
> 
> I have the following problem and I don't know if this is normal or I am doing
> something wrong. Can anybody help?
> 
> Once I have a database schema created I want to initialize the first 
> registers.
> To do this, I am using an script (I load it and run it). Until now everything
> works fine (the database schema and the first registers are created
> correctly).
> 
> The problem comes after this.
> 
> All the autoGenerated fields (id fields) are not working properly and they
> don't take into account the registers created by the script, so every time I
> create a new record after this using DBRecord class, etc. an error message is
> triggered saying that the "unique key constraint is violated".
> 
> I don't know if I am doing something wrong or if this is normal and I have to
> avoid using the script. Because if I initialize the first registers by code 
> (using
> DBRecord class -- the same registers information), everything works fine.
> 
> The source code is the following:
> 
> //To create the database schema
> DBSQLScript script = new DBSQLScript();
> db.getCreateDDLScript(driver, script);
> try{
>       script.run(driver, conn, false);
>       db.commit();
>  }
> 
> //To execute the script to initialize the database information DBSQLScript
> script = new DBSQLScript(); script.addStmt(sql); try{
>      script.run(driver, conn, false);
>      db.commit(conn);
> }
> 
> I have also tried the script step with this code but the result obtained was 
> the
> same
> 
> driver.executeSQL(sql, null, conn, null); //driver is the DatabaseDriver
> instance
> 
> 
> Can anybody tell me if I am doing something wrong?
> 
> Thanks a lot for your help.
> Best regards,
> 
> Jon

Reply via email to