PL/SQL RPN calculator – version 2

November 24, 2014 2 comments

This post presents a new version of my PL/SQL RPN calculator.
It now includes :

  • a regex-free tokenizer
  • a recursive-descent parser to validate the input expression
  • an improved evaluator based on a compiled “type-aware” RPN expression

Program and additional objects available here :


Read more…

Categories: Fun, PL/SQL Tags: ,

XMLTransform Tips and Tricks

November 16, 2014 3 comments

No real new stuff there but as I’m a big user of XSLT transformation inside the database, I just thought I could share a few interesting (hidden) things I’ve encountered so far, that is :

  1. Using XSLT parameters with XMLTransform
  2. Using text output method with XMLTransform and XMLType.transform method


Read more…

How To : Parse sibling repeating groups without wrapper element

November 9, 2014 Leave a comment

Long time no post, so here’s a new (short) article.
Behind the cryptic title lies a situation like this :


where each logical record {id, name} is not enclosed by a row tag.
This is the result we want out of that data :

----- ---------
    1 SMITH
    2 WILSON
    3 GRANT


Read more…

XMLTABLE vs. External XSLT preprocessor

September 16, 2013 2 comments

We all know – I hope ;) – about XMLTABLE function to shred an XML document into relational rows and columns. In this article, I will describe an alternative approach to achieve the same result with an external table and the preprocessor feature.
And in case you wonder, no, it’s not one of this attempt to implement an XML parser using SQL*Loader syntax, something we can see from time to time as an answer to “How can I load my XML file using SQL*Loader?”.
This method relies on the external table preprocessor to transform the input XML file into CSV format and pipe the result to the loader.


Read more…


September 9, 2013 Leave a comment

This is a short article about the new 12c RETURNING SEQUENCE BY REF feature available with XMLTable function.
This clause allows us to access the complete tree of nodes produced by the main XQuery expression. In particular, we can now use reverse axes in the COLUMNS PATH expression.
Below is an example using this method, compared with prior releases’ techniques to achieve the same result (all queries tested on


Read more…

PL/SQL RPN calculator

February 3, 2013 3 comments

Some non-XML stuff for a change :)
This is something I’ve developed recently to evaluate stored expressions (formulas) using variables.
The “calculator” is written in PL/SQL and implements an RPN evaluation technique, as well as a method to convert infix expressions to RPN using the shunting-yard algorithm.
The evaluation function does not involve any dynamic SQL.

Program and additional objects available here :

Update 2014-11-24 – upgraded version available here :
PL/SQL RPN calculator – version 2


Read more…

XML Flattening revisited : Java-based pipelined function

November 18, 2012 1 comment

As a follow-up to How To : Flatten out an XML Hierarchical Structure, here’s a fourth approach using a pipelined function built over the Java InfosetReader interface.
The function only works on an XMLType column/table stored as binary XML. Since we directly decode the binary stream and pipe the rows to the SQL engine, this method is faster, much more scalable and less memory-intensive.


1. Set up

The ODCI set up is based on : Pipelined Table Functions Example: Java Implementation from the Data Cartridge Developer’s Guide.

We start by creating an object type and its collection. These are the structures that will be filled by the Java program at runtime and returned to the SQL engine via the pipelined function :

  node_id        integer
, node_name      varchar2(2000)
, node_type      varchar2(30)
, parent_node_id integer
, node_value     varchar2(4000)
, namespace_uri  varchar2(2000)



then the implementation type :
Read more…