Hi Kevin, I have another question.
This is what I am trying to do... In postgresql, is the query I am doing where the Col named Good_Parts takes an integer Array. So in PGAdmin, the following would be the correct sintax :
INSERT INTO oee_history ("Good_Parts")
VALUES ( '{0,1,2,3,4,0,1,2,3,4,1,2,3,4,5,6}' );
Using the Ignition Script Console, this is also a correct sintax which works for me by reading the integer array type of tag:
v = system.tag.readBlocking("[default]TestArray")[0].value
Col1 = "\"Good_Parts\""
system.db.runPrepUpdate("INSERT INTO oee_history ("+Col1+") VALUES (?);", [v], "DatabaseConnection")
However, when I try to insert to the database an array of integers I created using a list, it does not work... how can I convert the list type to an integer array type?
The following code does not work, how can I make it work with a list in the Script Console?
# I already tried using the following lists (list1, list2, list3, list4) but none of them work so far
list1 = [0,1,2,3,4,0,1,2,3,4,1,2,3,4,5,6]
list2 = "\'{0,1,2,3,4,0,1,2,3,4,1,2,3,4,5,6}\'"
list3 = "{0,1,2,3,4,0,1,2,3,4,1,2,3,4,5,6}"
list4 = '{0,1,2,3,4,0,1,2,3,4,1,2,3,4,5,6}'
system.db.runPrepUpdate("INSERT INTO oee_history ("+Col1+") VALUES (?);", [list1], "Historian")
And these are some of the errors I am getting in the script console:
#Error for List1
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to decode arguments
#Error for List2
Caused by: org.postgresql.util.PSQLException: ERROR: column "Good_Parts" is of type integer[] but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Caused by: java.io.InvalidClassException: failed to read class descriptor
#Error for List3
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: SQL error for "INSERT INTO oee_history ("Good_Parts") VALUES (?);": ERROR: column "Good_Parts" is of type integer[] but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
#Error for List4
Caused by: org.postgresql.util.PSQLException: ERROR: column "Good_Parts" is of type integer[] but expression is of type character varying
Hint: You will need to rewrite or cast the expression.