Dev Corner

Software Developer’s Notepad

Archive for October, 2009

PHP implements a bin2hex function that converts given binary string to hexadecimal string. Sometimes you need to solve the reverse task. You are given hexadecimal string and you need a PHP function that converts it to a binary string. Read the rest of this entry »

Input stream are useful as they encapsulate concrete implementation of a data source. You can change the data source without changing the application code. For example, you application reads data from a file. One day your boss decides that you need to retrieve information from a server located 1000 miles away. You just implement another class that implements the same input stream interface. The new class retrieves data from network instead of a local file. Read the rest of this entry »

You are a new database administrator. You are assigned a task to find all obfuscated PL/SQL procedures in an Oracle Database. Here is a simple recipe that solves the problem. After running the SELECT SQL statement you will get a list of obfuscated objects. Read the rest of this entry »

If you need to remove duplicate rows from an Oracle Database Table, you can use different approaches. For example, you can use the DELETE command with a criteria that selects only duplicates. Usually it is faster to create a new table with distinct rows and replace the old table with the new one. Read the rest of this entry »

With this recipe you can count the number of rows for ALL tables in current Oracle Database schema. Read the rest of this entry »

Here is a simple recipe. The following SQL finds the top ten SQL statements with the greatest elapsed time. Read the rest of this entry »

When Oracle executes PL/SQL program code it is interpreted. When compiled to native code, Oracle creates system dependent code. Native code is not interpreted by Oracle, but executed directly by the system. Read the rest of this entry »

You can use Database Link (dblink) to execute SQL against external database as if it was the database you are logged in to. For example, you might need to transfer sales information from a company branch located in Miami. Read the rest of this entry »

You can unlock Oracle user account that is locked by using the ALTER USER command. Read the rest of this entry »

Often we need SQL statements to use one value or another based on some condition that evaluated during the SQL statement execution. Oracle provides convenient functions like DECODE, NVL, NVL2, COALESCE that will return value based on some criteria. For complicated cases there is a CASE statement. With Oracle SQL CASE statement you can implement not only IF-THEN-ELSE logic, but also much more advanced logic. Read the rest of this entry »