473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

select from final table and sqlj

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

Mar 14 '07 #1
2 6698
On Mar 14, 7:21 am, "Janick Bernet" <jaber...@gmail.comwrote:
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
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

Mar 14 '07 #2
Grml. Google says there are two messages, but I can only see my own!? :
(

Mar 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John | last post by:
Why does a select from table with an integer field return a row if I compare the integer to an alpha character? Here's the info ( a straight copy and paste), then compare my two select...
2
by: Philip TAYLOR [PC87S/O-XP] | last post by:
Attempting to do away with all superfluous use of tables (i.e., tables used solely for layout) on our corporate web site, I have reached an impasse : I have one table left (containing a single...
2
by: hubert.trzewik | last post by:
Hello, Is it possible to EXEC stored procedure from a query? I want to execute stored procedure for every line of SELECT result table. I guess it's possible with cursors, but maybe it's...
13
by: Botao | last post by:
Hi, Every Guru, I'd like to put a button on a page. When clicking the button, the table below it gets selected so the user can do Ctrl C to copy the entire table without using the mouse to...
9
by: saturnius | last post by:
Hello, I am passing a value to a stored procedure in vb.net to get normally a selection of the table. How could I get the complete table without writing the code twice? Many thanks in advance ....
6
by: Eugene F | last post by:
I am trying to figure out a single select statement from a table function f(x) when the function's argument is fed from another result set, like SELECT ... FROM TABLE( f(x) ) a where x is a...
4
by: d0m_at0m | last post by:
hello, how to select a table that has a highest amount of columns (compared to other tables) using syscat? thanks in advance
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all On SQL Server tables I use SqlDataReader to query data like "SELECT * FROM table". Is there something similar for XML Files ? I want to use SQL Syntax like "SELECT * FROM table" on a...
0
by: onyris | last post by:
Hi have this query which works ok now : SELECT * FROM WHERE (((Table.published) Like '*'&!!& '*' And (Table.published) Like '*'&!!& '*' and (Table.address) Like '*'&!!& '*' )); and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.