Developer

PL/XML - XML Based Scripting for PL/SQL

I started working on a

task for a project and decided that there were some very good

properties that I could use to help me teach people PL/SQL and XML. I

expanded a bit on the idea and ended up with a scripting language,

implemented in XML, that can be passed into a PL/SQL procedure. The

script can execute stored procedures, it has looping logic, conditional

(CASE) logic, user defined variables, etc.

The nice thing about

it is that it's very easy to read and modify. The XML structure is also

very easy to read. It's really a learning tool but it may have some

real life uses also. You can modify application

functionality on the fly just by changing XML. You could even write a

program that would generate XML for you that would then feed other

systems. Quite cool!

Here is a sample script:

<ROOT> 
<CMD type="variable">
<VAR name="$var1$" type="literal" datatype="char">MyValue</VAR>
</CMD>
<CMD type="variable">
<VAR name="$var2$" type="function" datatype="date" format="dd/mm/yyyy hh24:mi:ss">
<FUNCTION name="sysdate" />
</VAR>
</CMD>
<CMD type="for">
<FOR from="1" to="5">
<CMD type="proc">
<PROC name="dbms_output.put_line">
<PARAMETER name="a">$var1$ is $var2$</PARAMETER>
</PROC>
</CMD>
</FOR>
</CMD>
</ROOT>

That XML, when run through my script interpreter, will output:

MyValue is 25/08/2006 15:06:59
MyValue is 25/08/2006 15:06:59
MyValue is 25/08/2006 15:06:59
MyValue is 25/08/2006 15:06:59
MyValue is 25/08/2006 15:06:59

The script is run sequentially. So the first thing it does is declare a variable, $var1$ and assign it the value of "MyValue".

Read the rest of this post.

Editor's Picks