Call Direct SQL in X++
static void TestDirectSQLInXpp(Args _args)
{
    str sqltxt = "select * from custtable where custtable.accountnum == '4001'";
    source sqlcmd;
    XppCompiler compiler = new XppCompiler();
    custtable ct;
    ExecutePermission executePermission;
    common com;
    ;
    if (sqltxt)
    {
        sqlcmd = 'CustTable SQLSTMT(CustTable CustTable' +')\n{\n'+sqltxt+';\nreturn CustTable;\n}\n';
        if (compiler.compile(sqlcmd))
        {
            executePermission = new ExecutePermission();
            executePermission.assert();
com = runbuf(sqlcmd,ct);
ct = com;
            print ct.AccountNum;
        }
        else
        {
            setprefix("@SYS57538");
            info (sqlcmd);
            error (compiler.errorText());
        }
    }
    else
    {
        sqlcmd = '';
}
    pause;
}
posted on 2008-07-15 10:59 lingdanglfw 阅读(275) 评论(1) 收藏 举报
 
                    
                     
                    
                 
                    
                 
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号