Insert dataset into database

Hi Guys, I am just new here. I need your help on how to insert the dataset to my database.
and this is my code.[code]#
import sys

Operator = event.source.parent.parent.getComponent(‘Container 1’).getComponent(‘lblOperator’).text
if Operator == ‘’:
system.gui.messageBox(“Please enter/scan valid badge ID for Operator!.”,“Invalid Badge ID”)
sys.exit()
Status_ID = ‘3’
EntryDate = event.source.parent.parent.getComponent(‘Container 1’).getComponent(‘lblDateTime’).text
RecordID = event.source.parent.parent.RecordID
ProgramID = event.source.parent.parent.Program
WO_Num = event.source.parent.parent.WO_List
call = system.db.createSProcCall(“usp_Trolley_Allocation_Status_History”)
call.registerInParam(1, system.db.INTEGER, RecordID)
call.registerInParam(2, system.db.INTEGER, Status_ID)
call.registerInParam(3, system.db.VARCHAR, Operator)
call.registerInParam(4, system.db.INTEGER, ProgramID)
call.registerInParam(5, system.db.DATA, WO_Num)
system.db.execSProcCall(call)

system.nav.closeWindow(‘Testing (tme)/Oven_Tracking_WO_Entry_Test’)

window = system.gui.getWindow(‘Testing (tme)/Oven_Tracking_Main_Test’)
table = window.getRootContainer().getComponent(‘Table’)
system.db.refresh(table, “data”)

system.nav.closeParentWindow(event)

[/code]


This looks OK. What do you want help with?

It has an error about inserting the Work Orders(WO) how can I insert multiple data in my database?

That depends on how your database is set up. Assuming WO_Num is a dataset, you will have to loop through all the values in the dataset. Your script will end up looking something like this (you’ll have to adapt it to run correctly with your stored procedure):[code]import sys

Operator = event.source.parent.parent.getComponent(‘Container 1’).getComponent(‘lblOperator’).text
if Operator == ‘’:
system.gui.messageBox(“Please enter/scan valid badge ID for Operator!.”,“Invalid Badge ID”)
sys.exit()
Status_ID = ‘3’
EntryDate = event.source.parent.parent.getComponent(‘Container 1’).getComponent(‘lblDateTime’).text
RecordID = event.source.parent.parent.RecordID
ProgramID = event.source.parent.parent.Program
WO_Num = event.source.parent.parent.WO_List
WO_NumPy = system.dataset.toPyDataSet(WO_Num)
call = system.db.createSProcCall(“usp_Trolley_Allocation_Status_History”)
call.registerInParam(1, system.db.INTEGER, RecordID)
call.registerInParam(2, system.db.INTEGER, Status_ID)
call.registerInParam(3, system.db.VARCHAR, Operator)
call.registerInParam(4, system.db.INTEGER, ProgramID)
for row in WO_NumPy:
call.registerInParam(5, system.db.DATA, row[0])
system.db.execSProcCall(call)

system.nav.closeWindow(‘Testing (tme)/Oven_Tracking_WO_Entry_Test’)

window = system.gui.getWindow(‘Testing (tme)/Oven_Tracking_Main_Test’)
table = window.getRootContainer().getComponent(‘Table’)
system.db.refresh(table, “data”)

system.nav.closeParentWindow(event)[/code]