On 16/04/2025 12:18, Pierre Vacher wrote:
> I'm currently trying to integrate Jaybird 6 with the LibreOffice
> jdbcDriverOOo extension.
>
> Until now, jdbcDriverOOoused SQL INSERT queries with Jaybird in
> LibreOffice Base instead of ResultSet positioned inserts due to
> issue#818 <
https://github.com/FirebirdSQL/jaybird/issues/818>.
>
> Now with Jaybird 6 the positioned inserts are well managed because they
> are inserted at the end of the resultset as Base requires.
>
> On the other hand, I lose the ability to be able to retrieve the value
> of autoincrement columns during insertions.
>
> I'm experiencing this problem with several JDBC drivers, and I'm
> wondering if this is a JDBC limitation between SQL Inserts and
> positioned insert on ResultSets?
> And if so, is there a way around it?
The problem essentially is that
1) AFAIK, most JDBC drivers need to implement updatable result sets
client-side, especially when it comes to inserts, so usually there are
some oddities and deficiencies.
2) In practice, updatable result set are - at least in my experience -
hardly ever used in Java, so they don't get much use and thus little
attention.
3) JDBC does not specify (or at least, not clearly) what happens after
`insertRow()`, e.g. should you be able to use `getXXX` to get values
that were just inserted? Or will it behave as if `movetoInsertRow()` was
called (and that behaviour itself is also not clearly defined)?
For Jaybird, after `insertRow()`, the row content is reset so it is a
fresh empty row again.
4) JDBC does not define how you can identify which row in the result set
has the data that was just inserted. It just provides methods so you can
identify which rows were inserted.
5) For Jaybird, we simply record the row we sent to the server to be
inserted, and use that when you try to access that row later through the
result set. This means that generated values like ids are not reflected
in that row, so even if points 3 and 4 were defined, you still wouldn't
be able to get the generated id.
Now, I could probably address point 5 by using RETURNING to collect the
data, but because of point 2, I'm not sure if that is good use of my
time, and because of points 3 and 4, it might not be of much use to you.
Now my question to you is, *if* addressing point 5 would be sufficient
for you. That is, do you have enough information if I use INSERT ...
RETURNING ... to populate the (missing columns of the) row that is
stored in the result set?
Mark
--
Mark Rotteveel