Oracle Best and Worst Practices

 

PLSQL

Page history last edited by Anonymous 2 yrs ago

Best Practices:

  1. Do not use PL/SQL where you can use a SQL statement instead.
  2. Always create functions and procedures inside packages.
  3. Always use the %TYPE attribute to declare variables which are actually PL/SQL representations of database values.
  4. Use BULK COLLECT and FORALL to improve performance.
  5. Bind, do not concatenate, variable values into dynamic SQL strings.
  6. Anchor variables to database datatypes wherever possible
    1. EXAMPLE: l_empno SCHEMA.TABLE.EMPNO%TYPE;
    2. This allows the code to change automatically if the column type changes.

Worst Practices:

  1. Use a loop with commits in the middle and incorrect error trapping
  2. Use EXECUTE IMMEDIATE when static SQL will do

Comments (0)

You don't have permission to comment on this page.