SqlStatementExecutePermission.new Method [AX 2012]
Creates a new instance of the SQLStatementExecutePermission class.
The following example performs an SQL query on the CustTable table, which runs on the server. The result of the query is stored in the resultSet object.
server static void main(Args _args)
{
DictTable dictTable;
Connection connection;
Statement statement;
str sql;
ResultSet resultSet;
SqlStatementExecutePermission perm;
dictTable = new DictTable(tableNum(CustTable));
if (dictTable != null)
{
connection = new Connection();
sql = strfmt( "SELECT * FROM %1", dictTable.name(DbBackend::Sql) );
//Instantiate the permission class
perm = new SqlStatementExecutePermission(sql);
//check for permission to use statement
perm.assert();
statement = connection.createStatement();
resultSet = statement.executeQuery(sql);
//end the scope of the assert call
CodeAccessPermission::revertAssert();
}
}
Community Additions
ADD
Show: