Testing NamedQuery works fine, but system.db.runNamedQuery inserts NULL in all columns

I have a NamedQuery type=Update Query with couple of parameters. it works fine in Testing environment, but when I run system.db.runNamedQuery in client, I can see a row to database added with all NULL parameters.
I am using MySQL. The Query is:

INSERT INTO tasks
(Col1 , Col2 , Col3 , Col3 )
VALUES
(:V1, :V2, :V3, :V4)

Any idea What am I missing?

Script:
params = {“Col1”:“Test1”, “Col2”:“Test2”, “Col3”:1, “Col4”:2}
system.db.runNamedQuery(“MyNamedQuery”, params )

The Keys in your params dictionary must match what you have named them in the named query, not the column names.

params = {'V1': 'Test1', 'V2': 'Test2', 'V3': 1,'V4':2}
system.db.runNamedQuery('MyNamedQuery',params)
4 Likes

Thanks Irose, All good now.
What a silly mistake.

1 Like