Dev Corner

Software Developer’s Notepad

Associative Arrays

DECLARE
  TYPE population_type IS TABLE OF NUMBER INDEX BY VARCHAR2(64);
  country_population population_type;
  continent_population population_type;
  howmany NUMBER;
  which VARCHAR2(64);
 
BEGIN
  country_population('Greenland') := 100000;
  country_population('Iceland') := 750000;
  howmany := country_population('Greenland');
 
  continent_population('Australia') := 30000000;
  continent_population('Antarctica') := 1000; -- Creates new entry
  continent_population('Antarctica') := 1001; -- Replaces previous value
  dbms_output.put_line('Count: ' || continent_population.count);
 
  which := continent_population.FIRST; -- Returns 'Antarctica'
 
-- as that comes first alphabetically.
  which := continent_population.LAST; -- Returns 'Australia'
  howmany := continent_population(continent_population.LAST);
-- Returns the value corresponding to the last key, in this
-- case the population of Australia.
 
  -- Traverse Continents Associative Array
  dbms_output.put_line('Elements in continent_population: ' || continent_population.count);
  which := continent_population.FIRST;
  WHILE which IS NOT NULL LOOP
    dbms_output.put_line(which || ': ' || continent_population(which));
    which := continent_population.NEXT(which);
  END LOOP;
  -- Outputs:
  --   Count: 2
  --   Elements in continent_population: 2
  --   Antarctica: 1001
  --   Australia: 30000000
 
END;

Extend Oracle PL/SQL Collection

DECLARE
  TYPE CourseList IS TABLE OF VARCHAR2(10);
  courses CourseList := CourseList();
BEGIN
  dbms_output.put_line('Initial count= ' || courses.count ||
                       ', first= ' || courses.first ||
                       ', last= ' || courses.last ||
                       '');
  courses.extend(5);
  dbms_output.put_line('After extend(5) count= ' || courses.count ||
                       ', first= ' || courses.first ||
                       ', last= ' || courses.last ||
                       '');
  dbms_output.put_line('After extend(5) count: ' || courses.count);
 
END;
Initial count= 0, first= , last=
After extend(5) count= 5, first= 1, last= 5
After extend(5) count: 5

Multitable INSERT SQL can insert simultaneously into more than one tables. You can also specify optional conditions which determine which values are inserted into which tables. Read the rest of this entry »

The following SQL shows the SQL text for the SQL being executed by a session. Read the rest of this entry »

The following SQL can be used by Oracle Database Administrator (DBA) to retrieve information about the currently active sessions with longest execution. The SQL statement is designed to run with SQL*Plus. Read the rest of this entry »

We often need to limit the number of rows returned by a select statement. Some database servers provide extensions to the select statement. For example, MySql database sever provides LIMIT directive. In Oracle Database each result set has defined a ROWNUM pseudocolumn and ORDER BY clause interact. Read the rest of this entry »

You can easily split long command line into multiple lines. Read the rest of this entry »

bb: Usage Stats collects information about page, post, category and homepage views for your WordPress blog. Builds daily and monthly usage statistics. Read the rest of this entry »

The bb:Text Rotator WordPress plugin contains bb:Text Rotator Widget.

As any WordPress widget, you can add the bb:Text Rotator Widget to any sidebar using the WordPress administrative interface (Appearance – Widgets menu). From the Widget administration form you can define text snippets. You can specify as many text snippets as you like.

When WordPress builds the output HTML, the widget randomly selects a snippet and inserts it in place of the widget.

Any widget have a priority. The higher is the priority of the snippet, the higher is the chance that it will be selected for display.

Current Stable Version: [TODO] [Download]

Previous Versions: [TODO]

Data expressions can be used to describe structure of data. Read the rest of this entry »

Shortcodes are very effective way to include dynamic content into your posting. This tutorial will guide you through the process of creating your own shortcode. Just in few easy steps. Read the rest of this entry »