Hi Alex!

My guess:

The error does not seem to come from the code inserting the new row
but from the code that tries to show the row to you afterwards.
The problem is that you are using an autoinc field, so the value
of field OI is not set by user and is not known by dbforms. 

I think after inserting the new row dbforms tries to navigate
to the new row by using the key of the inserted row. But that
value is currently not know to dbforms but a null value, so the 
error appears. 

What has to be done? Dbforms has to try to get the values of the
new keys. Unfortunately this functionality seems to be missing in JDBC2,
will (when?) come once with implementations of JDBC 3. Apache project 
Torque has similar problems and uses DB Adapters with dbms 
specific SQL queries to get this
information from the underlying dbms. Have a look at:

  http://jakarta.apache.org/turbine/torque/db-adapters.html

and sources of db adapters at

  
http://cvs.apache.org/viewcvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/


Responsible code within dbforms is within InsertEvent.java, lines 338 etc:

    //Show the last record inserted
    String firstPosition = null;
    Vector key = table.getKey();
    FieldValue[] fvEqual = new FieldValue[key.size()];
    for (int i = 0; i < key.size(); i++) {
         Field field = (Field) key.elementAt(i);
         String value = (String) fieldValues.get(new Integer(field.getId()));
         FieldValue keyFieldValue = new FieldValue(field, value, false);
         fvEqual[i] = keyFieldValue;
    }
         // here could be a good place to get the key values
         // generated by dbms

    ResultSetVector resultSetVector =
         table.doConstrainedSelect(...);

Maybe the best way would be to try to integrate the existing Torque Adapters
into dbforms and then use their functionality to get the id of the inserted 
row from them. Why reinvent the wheel? 

Don't we have some Torque professionals among us with some time?

Well, just a quick guess, maybe I'm wrong....comments?

Regards

Dirk

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
DbForms Mailing List

http://www.wap-force.net/dbforms

Reply via email to