Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / March 2007

Tip: Looking for answers? Try searching our database.

select from final table and sqlj

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Janick Bernet - 14 Mar 2007 15:21 GMT
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!? :
(
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.