SqlStatementExecutePermission.new Method

Creates a new instance of the SQLStatementExecutePermission class.

Syntax

public void new(str sqlStatement)

Run On

Called

Parameters

  • sqlStatement
    Type: str
    The SQL string to be executed.

Examples

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(); 
        } 
}

See Also

SqlStatementExecutePermission Class

SqlStatementExecutePermission Class

CodeAccessPermission Class

How to: Secure an API on the AOS

Secured APIs