An example
request.MainWork.classname=com.ai.db.PreTranslateArgsMultiRequestExecutor
request.MainWork.db=(your-database)
request.MainWork.query_type=update
request.MainWork.request.1=FirstSelect
request.MainWork.request.2=ConditionalUpdate
request.MainWork.request.3=AdditionalSelect
request.MainWork.request=AdditionalUpdate
request.FirstSelect.classname=com.ai.db.DBRequestExecutor2
request.FirstSelect.stmt=\
select column2 as id, * from table1 where column1 = {arg1}
request.ConditionalUpdate.classname=com.ai.parts.IfPart
request.ConditionalUpdate.expression=exists(id)
request.ConditionalUpdate.if=Insert1
request.ConditionalUpdate.else=Insert2
request.Insert1.classname=com.ai.db.DBRequestExecutor2
request.Insert1.query_type=update
request.Insert1.stmt=\
insert into table2 (col1, col2) values ({arg1}, {arg2})
request.Insert2.classname=com.ai.db.DBRequestExecutor2
request.Insert2.query_type=update
request.Insert2.stmt=\
insert into table3 (col1, col2) values ({arg1}, {arg2})
request.AdditionalUpdate.classname=com.ai.db.DBRequestExecutor2
request.Insert2.query_type=update
request.Insert3.stmt=\
insert into table4 (col1, col2) values ({arg1}, {arg2})
Required entries in aspire.properties file
request.Aspire.booleanfunction.exists.classname=com.ai.htmlgen.CommonBEEvaluator
Notable points
IfPart extends the functionality of the multi request executor (essentially an implementation of a sequential processing pipeline) for conditional purposes. In the example above, it checks the existence of a variable in the working variable set. If it exists then the "Insert1" is executed, and otherwise "Insert2" is executed.
The function "exists" is implemented by a class called CommonBEEvaluator. This class also supports the following functions
StringEquals(str1, str2)
whitespace(arg1)
gt(arg1-int,arg2-int)
gte(arg1-int, arg2-int)
lt(arg1-int,arg2-int)
lte(arg1-int, arg2-int)
numberequals(arg1-int, arg2-int)
You can extend this functionality by wrting your own class for additional functions. To make use of all of these functions you have declare them in aspire.properties file as follows
request.Aspire.booleanfunction.exists.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.StringEquals.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.NumberEquals.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.gt.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.gte.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.lt.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.lte.classname=com.ai.htmlgen.CommonBEEvaluator
request.Aspire.booleanfunction.whitespace.classname=com.ai.htmlgen.CommonBEEvaluator
Limitations
The Aspire processing pipeline is there for primarily working with straight forward cases. If you are using a number of if/else and conditional and loop structures then you may want to consider writing your own java procedure for accomplishing the complex logic. The included references at the end of the document specifies some references on this subject.
For example the current "ifpart" does not allow comaparison operators. And to add new functions might be a bit tedious. The key to writing the java procedures is familiarity with java and being able to use a java ide to help with this.
References
1. How to write database procedures in Java using Aspire
2. Writing Factory Parts in Aspire
Satya - Friday, October 07, 2005 5:09:18 PM
Make sure you remove the empty space(s) at the end of the ifpart expression
For example:
request.ConditionalUpdate.expression=exists(id)
In the above line make sure there is no space or any additional character after the closing bracket of (id). This may be fixed in a future release, but for now that is what you have to live with.