Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Inserting Multiple instances into a databse

Aditya_S_
Level 7
Level 7
I am using MySQL to capture the form data. In the form I have a Driver License section which can have multiple instances.



In the workflow I am using the "Execute SQL query" module to insert data. Initially I can insert information from the non-repeating subforms, successfully. However, workflow inserts no information from repeating subforms. Below is an example of the XPATH used.



/process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate



Is the above format correct ? How can I insert the second and third instances ?



Thanks

Aditya
5 Replies
Jasmin_Charbonn
Level 10
Level 10
You would need to call the "Execute SQL query" a second time and pass the information for the second driver licence section.



Something like /process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate[2]



Jasmin
Aditya_S_
Level 7
Level 7
In my workflow, there could be different results of driver license information. Sometimes there could be one or more instances.



Are you suggesting that I will need one SQL query for every instance ? Is there a way to created a loop ?



"Something like /process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate[2]"

Just to clarify - would it be the DiverLicense[2] or drvlicstate[2] ? In other words, would I specify the instance on the subform or the field ?



Aditya
Ryan_Lunka
Level 5
Level 5
Yes you can and will have to set up a loop in your process. Use an integer process variable as your loop increment start it at 1 (I'm pretty sure the indexing begins at 1...could be 0). You'll have to use the count() XPath function to count the number of nodes. Something like...



count(/process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense/drvlicstate)



Compare that number with the index value to know if you've looped through every node (and inserted each, one at a time) or if you need to loop again. Email me and I'd be glad to discuss this further with you if need be. It's not as complicated as it sounds.



Hope this helps!



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com
Jasmin_Charbonn
Level 10
Level 10
"Just to clarify - would it be the DiverLicense[2] or drvlicstate[2] ? In other words, would I specify the instance on the subform or the field ?"



I think you'll need to get to use DriverLicense to get the count of how many driver licenses you have.



count(/process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense)



then you can have a loop (just a route coming back to a previous step) that get the value using something like:

/process_data/xfaform/object/data/xdp/datasets/data/App/DriverLicense[i]/drvlicstate



Jasmin
HowardTreisman
Level 9
Level 9
You can set up a loop as described, or you can do it in a single step using the following custom component:

Docs: http://avoka.dnsalias.com/confluence/display/Public/XML+to+SQL+DSC

Download: http://www.avoka.com/avoka/escomponents.shtml

Howard

http://www.avoka.com