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 / Ingres Topics / February 2008

Tip: Looking for answers? Try searching our database.

Running an Ingres application against DB2 through the Gateway

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin Hay - 25 Feb 2008 12:40 GMT
Trying to make our Ingres 2.6 / OpenROAD 4.1 application be able to run on
DB2 through Ingres's gateway

One of the many problems has been UPDATE FROMs

I have a routine that parses the UPDATE FROM statement and converts it into
DB2 speak
before executing IMMEDIATE

This works well EXCEPT that DB2 returns a NULL if no rows are found due to
the inner join failing
and will then try to update the destination column with a NULL !!

e.g. if no matching owner id is found then UnderwriterID is not left alone
(as in Ingres) but updated with a null (also assuming its a nullable column)

Any suggestions, workarounds, choice remarks regarding IBM etc. very much
appreciated !

UPDATE ss03_policy_details_a t
SET ( t.UnderwriterID ) =
(  SELECT  id FROM ownr o
  WHERE t.PolicyNo = o.policy_id
  AND o.relation = 'UNWR'
  AND o.effd <= DATE('01.12.2007 00:00:00')
  AND (o.endd IS NULL OR o.endd >= DATE('01.12.2007 00:00:00'))
  AND o.id =
       (  SELECT MAX(w.id)
          FROM ownr w
          WHERE t.SystemDateTime = DATE('25.02.2008 13:14:41')
          AND t.PolicyNo = w.policy_id
          AND w.relation = 'UNWR'
          AND w.effd <= DATE('01.12.2007 00:00:00')
          AND (w.endd IS NULL OR w.endd >= DATE('01.12.2007 00:00:00'))
      )
)
WHERE t.SystemDateTime = DATE('25.02.2008 13:14:41')

--------------------------------------------------------------------------------
Colin Hay
Roy Hann - 25 Feb 2008 13:52 GMT
> Trying to make our Ingres 2.6 / OpenROAD 4.1 application be able to run on
> DB2 through Ingres's gateway
[quoted text clipped - 15 lines]
> Any suggestions, workarounds, choice remarks regarding IBM etc. very much
> appreciated !

IBM is strictly correct.  Correlated updates are a non-standard extension to
SQL support by Ingres, SQL Server and possibly(?) Sybase.   Just another
reason to hate SQL IMO; not only does the standard leave it out, the
extension is as hideous as it is indispensible.  :-(

Maybe use a type 1 temporary table (session global temporary table) for the
ID, and check that it's non-empty before attempting the update?  Or put a
constraint on the ss03_policy_details_a table so you get a fatal error when
the underwriterID is set null.

Roy
Simon Lovell - 26 Feb 2008 03:29 GMT
You need to include an EXISTS in the where clause.  Best done, as Roy says,
by putting the sub query in a declare global temporary table ... as select.
Of course, you are likely to take a performance hit by doing it this way.

>Trying to make our Ingres 2.6 / OpenROAD 4.1 application be able to run on
>DB2 through Ingres's gateway
[quoted text clipped - 36 lines]
>--------------------------------------------------------------------------------
>Colin Hay
 
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.