If you need to execute sql query inside your X++ code then below example can help you. To pass value to SQL query we need to use strfmt() function.
str sql;
Connection conn;
SqlStatementExecutePermission permission;
;
sql= strFmt("update ProdBOM set InventDimId = '%1' where RecId = %2", inventDim.inventDimId,ProdBOM.RecId);
permission = new SqlStatementExecutePermission(sql);
conn = new Connection();
permission = new SqlStatementExecutePermission(sql);
permission.assert();
conn.createStatement().executeUpdate(sql);
CodeAccessPermission::revertAssert();
No comments:
Post a Comment