Hi - I have been trying to think of the best way to do this:
I have an input form with a button that then runs a script and passes parameters to a named Query that then inserts data in to a SQL table.
I would like to add some code before the current script runs that does the following:
Lookup the SQL table and if two fields are present and a boolean value open up an error message saying record already submitted
if no boolean or NULL returned then open up Warning dialog box else continue the script.
I initially thought about using tags to store the result - but the vision client could be used on many stations and I want to keep it local to the client and not tied to a tag.
my current code before any lookup conformation (simply the insert data code) is below
params = { 'CUTTING_TICKET_INPUT' :event.source.parent.getComponent('CUTTING_TICKET_SCAN_Form Text Field').getComponent('CUTTING_TICKET_Text Field').text,
'LENGTH_ISSUED_INPUT' :event.source.parent.getComponent('LENGTH_ISSUED_INPUT').text,
'ROLL_NUMBER_INPUT' :event.source.parent.getComponent('ROLL_Number_Scan_Text Field').text,
'DATE_INSERT' :event.source.parent.getComponent('DATE_LABEL_').text,
'FAULTS_INSERT' :event.source.parent.getComponent('FAULTS_LOOKUP').text,
'PLANT_INSERT' :event.source.parent.getComponent('PLANT_LABEL_YATE').text,
'SUPPLIER_ITEM_INSERT' :event.source.parent.getComponent('SUPPLIER_ITEM_NUMBER_LOOKUP').text,
'USER_ID_INSERT' :event.source.parent.getComponent('USER_ID_LABEL').text,
'WIDTH_INSERT' :event.source.parent.getComponent('WIDTH_LOOKUP').text
}
print(params)
system.db.runNamedQuery("CREATE_KITTING_ISSUE", params)
My Named Query is below
INSERT INTO CUTTING_TICKET_TABLE (
[CUTTING_TICKET_NO],
[LENGTH_ISSUED],
[ROLL_NUMBER],
[DATE_INPUT],
[FAULTS],
[PLANT],
[SUPPLIER_ITEM_NUMBER],
[USER_ID],
[WIDTH],
[LENGTH_CUT],
[LENGTH_RETURNED],
[DATE_ISSUED],
[ISSUED]
)
VALUES
(
:CUTTING_TICKET_INPUT,
:LENGTH_ISSUED_INPUT,
:ROLL_NUMBER_INPUT,
:DATE_INSERT,
:FAULTS_INSERT,
:PLANT_INSERT,
:SUPPLIER_ITEM_INSERT,
:USER_ID_INSERT,
:WIDTH_INSERT,
0,
0,
current_timestamp,
1)
I have done many google and forum searches & I am giving myself a bit of a headache — There may be a much easier way to do a verification that a record doesn’t already exist and notify user — but I just cant think of it.