getRowsInViewOrder()

Version: 7.6.6
OS: Win7

I have a table bound to a SQL query that works great.

SELECT ID, STRING, t_stamp FROM TFL{Root Container.CP FAULTS.Line}CPFAULTS WHERE t_stamp > '{Root Container.CP FAULTS.Date Range.startDate}' AND t_stamp < '{Root Container.CP FAULTS.Date Range.endDate}'

I’d like to add an additional dynamic column to simply number the rows and getRowsInViewOrder() appears to be the solution. I’ve attempted to implement a “propertyChange” event script on the table to add this column.

if event.propertyName == "data": system.dataset.addColumn(event.source.data[0], [b]Type PySequence[/b], "Error", [b]Type PyType[/b]) getRowsInViewOrder()

I’m not sure how to obtain the appropriate PySequence and PyType arguments in the addColumn function. Maybe there’s an easier way?

This should work in MySQL.

SELECT @curRow := @curRow + 1 AS row_number, ID, STRING, t_stamp FROM TFL{Root Container.CP FAULTS.Line}CPFAULTS JOIN (SELECT @curRow := 0) r WHERE t_stamp > '{Root Container.CP FAULTS.Date Range.startDate}' AND t_stamp < '{Root Container.CP FAULTS.Date Range.endDate}'

The following query worked under property binding:

SELECT ROW_NUMBER() OVER(ORDER BY t_stamp) AS Row, ID, STRING, t_stamp FROM TFL{Root Container.Faults.Line}CPFAULTS WHERE t_stamp >= '{Root Container.Faults.Date Range.startDate}' AND t_stamp <= '{Root Container.Faults.Date Range.endDate}'