Fetching the image field stored as a BLOB in oracle

In MySQL, all the image types (jpeg, gif, png, bmp) can be fetched easily by drag-drop of the BLOB field.

In Oracle though, none of the images can be fetched like this. As a workaround, the image types other than bmp, can be fetched following the steps below:

1. Connect to the database and write a query that fetches the BLOB field. Preview it to check if the query fetches any data.

2. Right click on the "functions" header and add a new function.

3. In the dialog box for the New Function, double click on the "Scripts" and select the BHSExpression. Click "OK".

4. In the "Expression" field for the "BHSExpression", copy the following code:

Object getValue()
{
var blobObject = dataRow.get("BLOB_COL");
long blobLength = blobObject.length();
byte[] blobContent = blobObject.getBytes((long)1, (int)blobLength);
return Toolkit.getDefaultToolkit().createImage(blobContent);
}

This Javascript code will convert the BLOB field to an image field where BLOB_COL is the column name.

5. Drag and drop the BLOB field in the canvas and map the Attribute->field to the BHSEpression.

6. Previewing it will show the image fields in the canvas.

This workaround is not useful for bmp stored as BLOB in Oracle.

If you want to set dynamic size for blob image field then set aspect ration and scale is true in style--- object property & also set invisible-consume-space = true in size&position property


resource :- http://jira.pentaho.com/browse/PRD-2473

Comments

Popular posts from this blog

Changing the Java VM Memory Limits in Pentaho BI

utf8_general_ci VS utf8_unicode_ci what should we use?

CAS with Pentaho Community Edition