我有这种类型的代码,我想批量运行。 如果我在客户端上运行,它运行正常,但是批处理,它不起作用。批处理作业已完成错误状态,但没有日志。
你能帮帮我吗?
sNewLine = #newLine;
sqlStr = "Set Language British " + sNewLine;
sqlStr += "UPDATE p " + sNewLine;
sqlStr += "SET " + amountStr + " = ct.sumLA, " + qtyStr + " = ct.sumQ, ItemStatRecordType = " + int2str(DSDItemStatRecordType::Item) + " " + sNewLine;
sqlStr += "FROM ";
sqlStr += SysSQLSystemInfo::construct().getloginDatabase();
sqlStr += ".DBO.DSDITEMSALESSTATISTICS AS p " + sNewLine;
sqlStr += "INNER JOIN ( " + sNewLine;
sqlStr += " SELECT " + sNewLine;
sqlStr += "a.ItemId, " + sNewLine;
sqlStr += "SUM(a.LINEAMOUNTMST) sumLA, " + sNewLine;
sqlStr += "SUM(a.QTY) sumQ, " + sNewLine;
sqlStr += "cj.InvoiceAccount Customer, " + sNewLine;
sqlStr += "a.DATAAREAID ctDataAreaId, " + sNewLine;
sqlStr += "a.PARTITION ctPartitionId " + sNewLine;
sqlStr += "FROM ";
sqlStr += SysSQLSystemInfo::construct().getloginDatabase();
sqlStr += ".DBO.CUSTINVOICETRANS as a " + sNewLine;
sqlStr += "inner join ";
sqlStr += SysSQLSystemInfo::construct().getloginDatabase();
sqlStr += ".DBO.CUSTINVOICEJOUR as cj " + sNewLine;
sqlStr += "on cj.INVOICEID = a.INVOICEID " + sNewLine;
sqlStr += "and cj.INVOICEDATE = a.INVOICEDATE " + sNewLine;
sqlStr += "and cj.DATAAREAID = a.DATAAREAID " + sNewLine;
sqlStr += "and cj.PARTITION = a.PARTITION " + sNewLine;
sqlStr += "where a.INVOICEDATE ";
sqlStr += strFmt("between '%1' ", date2str(_fromDate, 123, 2, 3, 2, 3, 4) );
//sqlStr += "between '01-01-2011' ";
sqlStr += strFmt("and '%1' ", date2str(_toDate, 123, 2, 3, 2, 3, 4));
sqlStr += sNewLine;
//sqlStr += "and '01-01-2012' ";
sqlStr += "GROUP BY ItemId, cj.INVOICEACCOUNT, cj.DATAAREAID, cj.PARTITION, a.DATAAREAID, a.PARTITION " + sNewLine;
sqlStr += ") as ct " + sNewLine;
sqlStr += "ON ct.ItemId = p.ItemId " + sNewLine;
sqlStr += "and ct.Customer = p.CustAccount " + sNewLine;
sqlStr += "and p.DATAAREAID = ct.ctDataAreaId " + sNewLine;
sqlStr += "and p.PARTITION = ct.ctPartitionId " + sNewLine;
connection = new Connection();
perm = new SqlStatementExecutePermission(sqlStr);
// Check for permission to use the statement.
perm.assert();
statement = connection.createStatement();
updatedRows = statement.executeUpdate(sqlStr);
CodeAccessPermission::revertAssert();
答案 0 :(得分:1)
当您批量运行时,它作为AOS用户运行,而在客户端,它很可能作为您的域用户帐户运行(取决于设置)。
我猜测AOS用户没有适当的SQL权限。