I recently learned about the "SELECT FROM NEW/OLD/FINAL TABLE"
statement and I wanted to replace our old code, where we used
"identity_val_local()" to get auto generated values after an insert.
So I tried the following:
#sql{
SELECT
ID
INTO
:AssetEntryID
FROM
FINAL TABLE
(
INSERT INTO
Accounting.t_Debtor_Asset_Entries
(
AssetID,
MemberID
)
VALUES
(
:AssetID,
:DebtorID
)
)
};
This code works when I execute the SQL directly, and also the INSERT
statement alone is accepted by the SQLJ Precompiler. But as soon is
wrap the insert statement into the SELECT FROM FINAL TABLE statement,
it returns an SQL0530n (indicating that an RI constraint is violated),
which makes absolutly no sense in that context.
Am I doing something wrong or is this, a maybe already known, problem
of the SQLJ precompiler? If so, does there exist a workaround for it?
Regards,
Janick
jefftyzzer - 14 Mar 2007 18:47 GMT
> I recently learned about the "SELECT FROM NEW/OLD/FINAL TABLE"
> statement and I wanted to replace our old code, where we used
[quoted text clipped - 35 lines]
> Regards,
> Janick
Forgive me for asking a potentially stupid question--I intend no
insult--but are you sure that the Accounting.t_Debtor_Asset_Entries
record that you're trying to insert isn't missing a parent in some
other table, thus throwing the RI message?
--Jeff
Janick Bernet - 15 Mar 2007 10:27 GMT
Grml. Google says there are two messages, but I can only see my own!? :
(