Inserting Multiple instances into a databse

Avatar

Avatar
Validate 1
Level 4
Aditya_S_
Level 4

Like

1 like

Total Posts

315 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 4
Aditya_S_
Level 4

Like

1 like

Total Posts

315 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
Aditya_S_
Level 4

16-01-2009

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

Replies

Avatar

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile
Jasmin_Charbonn
Level 10

19-01-2009

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

Avatar

Avatar
Validate 1
Level 4
Aditya_S_
Level 4

Like

1 like

Total Posts

315 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 4
Aditya_S_
Level 4

Like

1 like

Total Posts

315 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
Aditya_S_
Level 4

20-01-2009

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

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

20-01-2009

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

Avatar

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile
Jasmin_Charbonn
Level 10

20-01-2009

"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

Avatar

Avatar
Boost 5
Level 9
HowardTreisman
Level 9

Likes

5 likes

Total Posts

936 posts

Correct reply

9 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile

Avatar
Boost 5
Level 9
HowardTreisman
Level 9

Likes

5 likes

Total Posts

936 posts

Correct reply

9 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile
HowardTreisman
Level 9

21-02-2009

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