Insert Errored Record into another Table

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

Mveluru

Posts: 5
Joined: Mon Jan 28, 2013 6:05 pm
Location: Austin

Post by Mveluru » Mon Jan 28, 2013 6:34 pm
Hi All :
I looking for your guidence.
How to Error Module when Error occured . I tried as shown below it's not calling the error module


Code: Select all
<project name="DBInsert" mainModule="Main" version="2.0" logLevel="verbose" threadSafe="true" onError="call:ErrorModule">

	<module name="Main" description="DB Insert" logLevel="debug">

		<readFixedWidth inputFile="C:\BatchOutput\processzone\GoAnywhere\GoEmp.txt" outputRowSetVariable="Fixeddata" skipInvalidRecords="false" skipFirstRow="false" recordDelimiter="CR" version="1.0" logLevel="debug">
			<data trim="left" nullIndicator="${IsEmpty(&apos; &apos;)}">
				<column index="1" name="EMP" size="6" type="CHAR" trim="both" alignment="left" />
				<column index="2" name="EMPNAME" size="10" type="VARCHAR" trim="both" alignment="left" />
				<column index="3" name="DEPT" size="3" type="CHAR" trim="both" alignment="left" />
				<column index="4" name="DEPTNAME" size="8" type="VARCHAR" trim="both" alignment="left" />
				<column index="5" name="MGRNO" size="6" type="CHAR" trim="both" alignment="left" />
			</data>
		</readFixedWidth>

		<forEachLoop itemsVariable="${FixedData}" currentItemVariable="ThisRec" logLevel="debug">

			<sql label="DB" resourceId="LocalDBConnect" autoCommit="true" driver="com.ibm.db2.jcc.DB2Driver" url="jdbc:db2://localhost:50000/sample" user="db2admin" password="db2admin" passwordIsEncrypted="false" version="1.0" logLevel="normal" onError="continue">
				<query label="InsetINTOEMP" whenNoDataFound="error">
					<statement>INSERT INTO MT2BATCH.EMP VALUES (&apos;${ThisRec[1]}&apos; , &apos;${ThisRec[2]}&apos;)

</statement>
				</query>
				<query label="InsertINTODEPT" whenNoDataFound="error">
					<statement>INSERT INTO MT2BATCH.DEPT1(DEPTNO,DEPTNAME,MGRNO) VALUES (&apos;${ThisRec[3]}&apos;,&apos;${ThisRec[4]}&apos;,&apos;${ThisRec[5]}&apos;)
</statement>
				</query>
			</sql>

		</forEachLoop>
	</module>


	<module name="ErrorModule" description="Error Module" logLevel="debug" onError="abort">

		<sql label="ErrorInsert" resourceId="LocalDBConnect" autoCommit="true" driver="com.ibm.db2.jcc.DB2Driver" url="jdbc:db2://localhost:50000/sample" user="db2admin" password="db2admin" passwordIsEncrypted="false" version="1.0" logLevel="debug" onError="abort">
			<query label="InsertError" whenNoDataFound="error">
				<statement>INSERT INTO MT2BATCH.GAW_ERRORRECORD(ERRORRECORD) VALUES (&apos;Error&apos;)

</statement>
			</query>
		</sql>


		<raiseError label="ErrorTask" version="1.0">
			<message>Error Occurred while inserting data ${system.job.error}</message>
		</raiseError>

	</module>

	<description>Insert Into EMP table</description>
</project>

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Jan 29, 2013 10:24 am
Mveluru,

Adding the “call:Error Module” on the Project Header changes the performance of the "Main" module.

Processing for a Project will always start & end in the “Main” Module (as defined on the Basic Tab in the Project Header). Each task in the “Main” Module will be executed in order per logic conditions. If an Error is thrown during the normal processing of a Project AND you have indicated for the Project to call an “Error Module” in that event, processing is passed from the "Main" module to the “Error Module” identified on the Error Tab in the Project Header to complete execution and then end the project execution.

This allows you to do things like Log an error or send an email notification of the error for someone to address the issue.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1