Ignition database

Hi, is it possible to have and INSERT INTO SELECT STATEMENT in ignition?
how about its syntax in scripting?

It is a perfectly acceptable query for system.db.runPrepUpdate() or any of the other update query forms. (“Update” includes “Insert” as far as JDBC is concerned.)

1 Like

I have an sql statement that goes like this
INSERT INTO rp_transformation_slip(item_code2,item_desc2,scan_code,cat1,cat2,item_code1,item_desc1,weight_origin,total_crates,no_crates_from,total_weight,no_print,slip_series_no)
select distinct item_code2,item_desc2,scan_code,cat1,cat2,item_code1,item_desc1,weight_origin,sum(no_crates_tr)as total_crates,no_crates_from,sum(weight)as total,‘2’,‘TS-00001’

from transaction_to where scan_code = ‘2002316’
group by item_code2,item_desc2,scan_code,cat1,cat2,item_code1,item_code2,item_desc1,weight_origin,no_crates_tr,no_crates_from

how do i contruct a syntax that dynamically passed the paramaters from a text field of scan code ?

For runPrepUpdate, place a un-quoted question mark where the quoted constant would be in your query, and supply the value in the list of args. Syntax would be a bit different for named queries, as they take a dictionary instead of a list. I recommend keeping the manual open in a browser tab while working on new scripts.

2 Likes

Thank you so much