Oracle ISNULL() Equivalent

Most major DBMSs provide us with a function for replacing null values with another value.

But the name of the function tends to differ across DBMSs. For example, SQL Server has an ISNULL() function, while others (such as MySQL, MariaDB, and SQLite) have an IFNULL() function for doing the same thing.

However, to confuse matters, MySQL and MariaDB each have an ISNULL() function that works differently to SQL Server’s function of the same name (MySQL and MariaDB’s implementation only accept a single argument, and return 1 if its null and 0 if it’s not).

Read more

Convert a Unix Timestamp to a Date Value in Oracle

In Oracle Database, we can use the following technique to return a date from a Unix timestamp value.

The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).

Read more

How to Return the Unix Timestamp in Oracle

Here’s an option for returning the Unix timestamp when using Oracle Database.

The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).

Read more

2 Ways to Delete Duplicate Rows in Oracle

The following options can be used to delete duplicate rows in Oracle Database.

These examples delete duplicate rows but keep one. So if there are three identical rows for example, it deletes two of them and keeps one. This is often referred to as de-duping the table.

Read more

Fix Error “ORA-01789: query block has incorrect number of result columns”

If you’re getting the error “ORA-01789: query block has incorrect number of result columns” in Oracle Database, then it’s probably because you’re trying to use an operator such as UNION, INTERSECT, or EXCEPT to run a compound query, but the SELECT statements on either side of the operator return a different number of columns.

To fix this, simply ensure that both queries return the same number of columns.

Read more