Thursday, January 17, 2008

Miscellaneous Tasks - ant - SQL

I was going through misc tasks of ant while working on build script for one our release. I found SQL task and was wondering why do we need this?

But today i could use this for one of our daily verification script, used this to get failure count from one of the table. what a great usage :)

Link

Sample:


<target name="queue" if="oracle.url" >
<sql
driver="${oracle.driver}"
url="${oracle.url}"
userid="${oracle.user}"
password="${oracle.password}"
print="yes"
showheaders="false"
showtrailers="false"
onerror="continue"
>
<classpath refid="common.classpath"/><![CDATA[

select 'No of item to be processed : ' || count(sqno)
from Queue where processedtime is null ;

select 'Seq number : ' || sqno || CHR(10) ||
'Total time in queue : ' || numtodsinterval(sysdate-queuecreated,'day') || CHR(10) ||
' (day hour:minute:seconds.milliseconds) ' || CHR(10) ||
'Total number of failure(s) : ' || FAILURECOUNT
from QUEUE where SQNO =
( select min(SQNO) from Queue
where processedtime is null );

]]>
</sql>
</target>