Tuesday, December 2, 2008

Dates and Report Parameters

When configuring a Date Parameter in BI Publisher the Date Format String has to conform to the Java SimpleDateFormat format mask. Some commonly used examples are:


Format MaskOutput
dd-MMM-yyyy01-Jan-2008
dd/MM/yyyy HH:mm:ss01/01/2008 13:25:00
hh:mm a01:25 PM
h:mm a1:25 PM
EEE dd-MM-yyTue 01-01-08
EEEE dd-MM-yyTuesday 01-01-08

Default values for Dates
This can either be:
• A fixed date and must match the format mask specified in Date Format String
• One of the following functions:


Function NameDescription
SYSDATE()Today’s Date
FIRST_DAY_OF_MONTH()First day of the current Month
LAST_DAY_OF_MONTH()Last day of the current Month
FIRST_DAY_OF_YEAR()First day of the current Year
LAST_DAY_OF_YEAR()Last day of the current Year

When using the functions above the they need to be surrounded by a curly brace followed by a dollar sign i.e. {$FIRST_DAY_OF_MONTH()$}
Simple addition and subtraction is also supported with these functions, for example:
{$SYSDATE()+1$} would specify tomorrows date as the default parameter.

Thursday, November 13, 2008

Rendering Error: Unexpected element: :report

Ever seen the error "Unexpected element: :report" when trying to render a report in BI Publisher? This is due a a Bug/Feature where the "xmlns" attribute is not automatically inserted into the element in the xdo file for your report. To resolve the issue is quite simple.

1. Open the xdo file for you report in a text editor
2. Insert the following attribute into the element

xmlns="http://xmlns.oracle.com/oxp/xmlp"


The element should then look something like this:

<report version="1.1" xmlns="http://xmlns.oracle.com/oxp/xmlp" defaultDataSourceRef="dev">
...
</report>

Monday, November 10, 2008

Extract a line from a file

There are many times I need to extract a single line (or possibly group of lines) from a file (Usually when things have gone wrong).

The easiest way to do this is as follows:

awk 'NR==lineNumber{print;exit;} filename

Replacing:

  lineNumber - with the line you wish display

  filename - with the name of your file





I have also seen the following suggested:

sed 'lineNumberq;d' filename

Replacing:

  lineNumber - with the line you wish display

  filename - with the name of your file


After performance testing on a large file (~10,000,000+ lines) the awk command was found to be faster.

ls: Arg list too long

Ever seen the error "arg list too long" when issuing an ls with a wildcard? The simple way round this is as follows:


find . -name "regexp" -exec ls -l '{}' +

Where:

regexp is the regular expression you are searching for