Hi,
I tried to run runNamedQuery in a script with this parameters :
namedQuery = “select_***”
projectname = “project”
parameters = {“reference”:currentValue}
data = system.db.runNamedQuery(projectname, namedQuery, parameters)
But after, I want to read data received :
for row in data:
ref_temp = data.getValueAt(row,0)
desc_temp = data.getValueAt(row,1)
update = [ref_temp, desc_temp]
I doesn’t work…
Could you help me ?
Named Queries return a regular Dataset
, not a PyDataset
. You need the latter to use iteration. Convert it with system.dataset.toPyDataSet().
You are also mixing access methods. With the regular Dataset, you can do this:
for r in range(data.rowCount):
value1 = data.getValueAt(r, 0)
With a PyDataset, you’d do this:
for row in pyds:
value1 = row[0]
I have change to : data = system.dataset.toPyDataSet(system.db.runNamedQuery(projectname, namedQuery, parameters))
And
for row in data:
ref_temp = data[i][0]
des_temp = data[i][1]
update = {“ref”: ref_temp, “des”:des_temp}
system.tag.write("[.]Current_BOM/BOM",system.dataset.updateRow(dataset,i,update))
I want to save data to an another tag in dataset format but i have onnly the last line saved
It’s ok now
data = system.dataset.toPyDataSet(system.db.runNamedQuery(projectname, namedQuery, parameters))
system.tag.write("[.]Current_BOM/BOM",data)
Simply …
If you are writing to a dataset tag or dataset property, you don’t need to convert to PyDataset. The regular Dataset is expected.