code formating

Wednesday, May 5, 2010

Why "If" if we can "Coalesce"

Today I wanted to update a row on an Oracle database table. The PL/SQL query was not difficult at all, however, there was a peculiarity. Some fields only needed to be updated if they where null. So, if these particular fields already had a value,we wanted to keep them, otherwise, update them.

The first solution to came to my mind was, reading the row and doing different updates depending on the values. Alas using "If" statements.
However it is possible to do everything in a relatively small PL/SQL update by using coalesce. This might be an example of how to use it.

Update table xxx set yyy=coalesce(yyy,new_value) where .....

Programatically walk a CATIA tree in .NET

One of the most basic tasks when automating anything in CATIA, it's usually to walk the whole tree and apply some changes to objects in ...