Archive

Posts Tagged ‘IBM DB2’

Update or insert rows in SQL

Some operations are not as easy in SQL as in procedural or imperative languages. For example while it is very intuitive to make an update or insert (also known as “upsert”) operation on a std::vector in C++, it is tricky in SQL. The upsert operation is: update data if already in the set and insert it otherwise.

As for recursion in SQL, the way to perform an upsert depends on the DBMS and its version.

Read more…

Recursion in SQL

We are used to easily writing recursive calls and loops in procedural languages, but this doesn’t hold true in SQL. Indeed, it depends on the DBMS used.

This article will focus on the ability to write recursive queries using Common Table Expressions (CTE). CTE are an addition from the SQL 1999 standard and are not yet available in all DBMS. As of today, CTE are at least compatible with:

  • Microsoft SQL Server 2000 / 2005 / 2008
  • IBM DB2
  • Oracle 9.2
  • PostgreSQL

Read more…

Categories: HowTo Tags: , , , , , ,
Follow

Get every new post delivered to your Inbox.