i have a power table and i want to insert a value at selected row at particular column.
i created one named query :
insert into [test]
([complete_date])
values (GETDATE())
i want to insert this current date in particular one column at selected row.
i tried this script:
sel_row = event.source.parent.getComponent('Power Table').selectedRow
id = event.source.parent.getComponent('Power Table').data.getValueAt(sel_row, "complete_date")
system.db.runNamedQuery("complete task", {"complete_date":id})
event.source.parent.getComponent('Power Table').data = system.db.runNamedQuery("All_task_Query")
but values are updated in new row not at selected row.
You're using an INSERT statement. You need to use an UPDATE.
Also, it looks like you're trying to update the value of the row id? That's a bad idea. You should use an id in the row which is unique to that row and never changes.
UPDATE [test]
SET [complete_date] = GETDATE()
WHERE id = :id
You need to use an ID in your query which is unique to the row you want to update. You will have issues otherwise. The UPDATE will update all rows which match the where clause.