Tuesday, December 1, 2015

PL/SQL Best Practices

A blog after many years :-)

My best practices for PL/SQL are below:
  • Always use Exception Block within each block, function, procedure
  • Send email to your development team for any error which occurs in Production
  • Give top priority to error email
  • Make sure you will never get any error email :-)
  • Write reusable procedures/functions and SQL (If you use APEX you can use List of values)
  • Avoid using Triggers except audit
  • Make sure you add below 6 columns to important tables for Audit.
    1. Created by User
    2. Creation Date
    3. Updated by User
    4. Update Date
    5. User Agent
    6. IP Address
  • Avoid using Stateful Package i.e. do not use package level variables/constants and instead create a DB table which stores all constants. This will avoid causing "ORA-06508: PL/SQL: could not find program unit being called" if you need to do a minor change in package then this could heavily affect where the application has thousands of users.

Thanks to Steven Feuerstein.

Monday, August 1, 2011

SQL Joins

If you need to understand SQL Joins then following is the good article.

http://www.oracle-base.com/articles/9i/ANSIISOSQLSupport.php

Friday, July 8, 2011

ALL, ANY and SOME Comparison Conditions in SQL

It is quite possible you could work with Oracle databases for many years and never come across the ALL, ANY and SOME comparison conditions in SQL because there are alternatives to them that are used more regularly.

You can find more info on following links:
I hope this will be quite useful to many developers.

Thanks to PL/SQL Challenge.

Regards,

Sohil Bhavsar

Tuesday, May 24, 2011

SQL Functions: Calculate difference between columns of current and previous/next row

Hi friends,

How to calculate difference between columns of current and previous/next row?

Let's say, you want to monitor how often products are sold from your store.

i.e. 

You want difference between current and previous SELL_DATE then you can write query as follows:

SELECT TO_CHAR(SELL_DATE, 'DD-MON-YYYY HH24:MI:SS'),
       TO_CHAR(LAG(SELL_DATE) OVER (ORDER BY SELL_DATE), 
       'DD-MON-YYYY HH24:MI:SS') AS SELL_DATE_PREV,
       (SELL_DATE - LAG(SELL_DATE) OVER (ORDER BY SELL_DATE))
       * 24 * 60 * 60 AS DIFF_IN_SECONDS
FROM PRODUCT_SALES
ORDER BY SELL_DATE DESC;

More Info: Oracle - Base : Lag Lead Analytic Functions

Regards,


Sohil Bhavsar

Monday, May 16, 2011

Oracle Application Express 4.0 with ExtJS

Oracle Application Express 4.0 with ExtJS

Oracle Application Express 4.0 with ExtJS is quite interesting book. I feel it will be very helpful to the APEX community.

Because, there are very limited resources available for integration of ExtJS and Oracle APEX and the way the book is written it is very easy to understand the concepts of ExtJS.

APEX team has already integrated jQuery in Oracle APEX 4.0 onwards, so before reading the book I had a mindset that jQuery is better then ExtJS but now I feel for Rich User Experience ExtJs is quite good option and APEX Developmt Team should focus towards that.

Congratulations Mark Lancaster for publishing this book.

Sunday, August 1, 2010

Oracle Hidden Columns

Hidden Columns for Tables with Column Objects

When a table is defined with a column of an object type, Oracle adds hidden columns to the table for the object type's leaf-level attributes. Each object-type column also has a corresponding hidden column to store the NULL information for the column objects (that is, the atomic nulls of the top-level and the nested objects).

Wednesday, June 23, 2010

APEX 4.0, now the game begins....

Finally APEX 4.0 is released.

Download APEX 4.0

For which we all are waiting.

Great!!!