On Thu, Feb 8, 2018 at 5:09 PM, Steven Hirsch <snhir...@gmail.com> wrote:
> I have a body of code using JDBC to work with a PostgreSQL 9.6 database. All
> The code being used in the failing case is not the slightest bit different
> from the working cases in terms of structure and transaction control - only
> the SQL, column count, etc. is different (but correctly formed and in all
> other ways functional).
Something must be different. As requested by others, try posting the
SQL code chunks, more eyeballs make bugs shallower ( it's happened
several times to me, make a typo, go over it for half an hour, grab a
colleague, she immediately points to it )
> I'm not sure where to start debugging this. Can anyone give me even a
> working theory to explain how returning a bogus value is possible? When I
> look at the sequences in pgAdmin, they are as expected in terms of
> ownership, etc. And, again, the table IS getting the correct value.
It shouldn't be, this I why several perople are requesting to see the
relevant code. Experience says lots of this fails are pilot error.
As an aside, with recent postgres versions you can normally use the
returning construct to grab autogenerated id. I.e., instead of "insert
blah-blah-blah, select currval(), whatever else" you can many times do
"insert balh-blah-blah returning auto_gen_column, whatever else". I've
used it a lot, and normally leads to shorter/easier/faster code.