Manmohan Agrawal 3 Posted October 19, 2022 Share Posted October 19, 2022 I have a requirement where I need to insert multiple lines through a single click to database. I am using an Information link where in pre-updates I have written a "Insert into" SQL and passing on parameters through on-demand data table.I have written a Iron-Python where in for loop it will iterate over all rows of table and when the condition is met it should refresh on demand data table which in return should insert into DB.Consider Data set as shown belowtable1----------column1 column2No A001Yes A002Yes A003Yes A004------------------------------------------------------------------Script as below------------------------------------------------------------------from Spotfire.Dxp.Data import DataValueCursortable1=Document.Data.Tables["table1"]InsertToDBTable=Document.Data.Tables["table2"]Column1 = DataValueCursor.CreateFormatted(table.Columns["Column1"])Column2 = DataValueCursor.CreateFormatted(table.Columns["Column2"])Counter=0ErrorMsg=""for row in table.GetRows(Column1, Column2): if Column1.CurrentValue=="Yes": Document.Properties["prop1"]=Column2.CurrentValue Document.Properties["prop2"]=Column2.CurrentValue InsertToDBTable.Refresh() Counter=Counter+1print Counter-----------------------------------------------------As an outcome it prints 3- because Counter value is 3, it insert 3 rows of data into database(sometimes 2 rows and 1 row as well) all of them with "Yes A004" value. It is not inserting any row for "Yes A002" or "Yes A003".Any help Link to comment Share on other sites More sharing options...
Magnus Rylander Posted October 24, 2022 Share Posted October 24, 2022 Hi! A couple of things that might cause the issues:Do you have correct indentation in the for loop?The first argument of table.GetRows should be the row indexes to enumerate, an IEnumerable<int>. (https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/?topic=html/M_Spotfire_Dxp_Data_DataTable_GetRows_1.htm)Here's an example of that uses only one cursor, but I think it worls the same with multiple cursors:https://community.spotfire.com/s/article/How-to-read-Column-Values-in-TIBCO-Spotfire-Using-IronPython-Scripting Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now