I use DB2 UDB V8.1.5. Using embedded SQL (SQLJava), I insert a row
into a table which has some foreign keys and check constraints. The
insert works fine, but if I encapsulate the insert into a SELECT INTO
.... FROM FINAL TABLE and then try to _precompile_ it, I get the
following:
SQL0545N (invalidates check constraint). If I try to put DEFAULT for
the column which the ck_constraint applies on, i get SQL0530N (invalid
foreign key) on another column.
I'd like to use the INSERT statement nested in a SELECT statement to
retrieve the generated primary key.
The failing statement looks like this:
SELECT id
INTO :id
FROM FINAL TABLE (INSERT INTO mytable(id, val)
VALUES (DEFAULT, :inputhostvar)
)
Thanks for your advice.