SQL formatting problem

What can I do to resolve this?

My script for the Delete button running onClick()

MyText = self.parent.parent.getChild(Table).props.selection.data[0].id
ID = MyText
MyFunc.MsgBox(ID)
system.db.runNamedQuery(Lot/MaterialDel,{ID:ID})

My message box returns 4, and that is the row I selected in the table. Before pressing the Delete Button.

SQL is getting this from Ignition:

exec sp_executesql N'DELETE FROM [dbo].[LotMaterial] WHERE id = @P0 ',N'@P0 nvarchar(4000)',NULL

whoops: Found the issue.

ID is lower case in the Named Query.

DELETE FROM [dbo].[LotMaterial]
WHERE id = :id

Good work. I think we would have needed to see the query to be able to help.

Tip: use the </> button when pasting code - not the ‘>’ quotation syntax. You can use the 🖉 edit link to fix your post.

2 Likes

It sounds like you got it working, but I would have expected these to be problems too:

system.db.runNamedQuery("Lot/MaterialDel",{"ID":ID})

Path of the named query needs to be in quotes.
Parameter name needs to be in quotes (this assumes you defined a paramter called ID in your named query).

1 Like