Humprey Evangelista Cogay

My Programming Adventures

SQL versions

Its been months since i have'nt posted anything haha. I was addicted to photography indeed. Http://HumpreyCogay.BlogSpot.Com

Any way i want to share one of my problems then. I've been coding SQL Querries for SQL Server for several years now, but working for the bank we use AS400 DB2 as a main DBMS. The problem here is there are several differences between the 2. SQL Server and DB2.

 Luckily i hava a book titled SQL Cook Book published by O'Reilly.

Here's a sample problem that i have(from the book)

   update e
      set e.sal  = ns.sal,
          e.comm = ns.sal/2
     from emp e,
          new_sal ns
    where ns.deptno = e.deptno

And you cannot use it in DB2, Here's the DB2 Version instead

 update emp e set (e.sal,e.comm) = (select ns.sal, ns.sal/2
                                      from new_sal ns
                                     where ns.deptno=e.deptno)
  where exists ( select null
                   from new_sal ns
                  where ns.deptno = e.deptno )

Now I'm back in the community... Hehehhe

Posted: 04-23-2008 2:44 PM by Comgen | with 1 comment(s)
Filed under: ,

Comments

db2 select not in said:

Pingback from  db2 select not in

# May 2, 2008 3:35 PM