Pull an entire row from a sql dataset tag using expression

I am currently bringing an entire table from a SQL database to a dataset.
I want pull an entire row from that dataset to another dataset where index = variable

I’m not sure if you can directly from an expression function, but this can be done through scripting by first converting the dataset to a pydataset and making use of the getslice method to return a single row dataset like:

def get_row(dataset, index):
	pydata = system.dataset.toPyDataSet(dataset)
	row = pydata.__getslice__(index, index+1)
	return row

If it has to be in an expression, then you can make use of the runScript() expression function. Just make sure that if this is for an expression tag that the script exists in the gateway scripting project.

Try the view() expression binding:

view("Select * Where index == args[0]", {Path.To.Dataset}, {Path.To.Variable})

…after installing my Simulation Aids Module. (:

1 Like

This does seem like exactly what I am looking for but I had some issues trying to get it working.
Where is there more information about the simulation aide module.
I downloaded it yesterday after looking at a few of your other responses to people having some of the same questions but the link to the sample project seemed broken and the documentation is hard to follow.

Thanks

The posted demo project is for Ignition v8. For v7.9, you’d want this older demo.

I’m open to content donated to improve the documentation. It is a free module, after all. (:

Thank you for the link.