The sample given at that blog
worked for me good. Unfortunately in sample at this blog and others always read just one field from query. I got an error about index when try to read fields more than one. Later I learned I have to read fields in ascending numeric order from a Microsoft's page . Run method from server side. In the other case you wold be get a security error. For insert ve delete (however this's not an advicable way for Axapta tables)
instead of executeQuery you can use executeUpdate.
public server static InventRep FillSQL(DatePhysical _DatePhysical = today())
{
InventRep InventRep;
Connection connection;
Statement statement;
str query,dateStr;
Resultset resultSet;
;
dateStr = date2str(_DatePhysical,321,dateday::Digits2,dateseparator::None,
datemonth::Digits2,dateseparator::None,dateyear::Digits4);
connection = new Connection();
statement = connection.createStatement();
query =
"select ITEMID,SUM(QTY)"+
"from INVENTTRANS "+
"where DATAAREAID='TST'"+
"and DATEPHYSICAL <='"+dateStr+"' "+
"group by ITEMID "+
"having SUM(QTY) <>0";
new SqlStatementExecutePermission(query).assert();
resultSet = statement.executeQuery(query);
while(resultSet.next())
{
//---- fields shoud be in numeric order ------
InventRep.ItemId = resultSet.getString(1);
InventRep.Qty = resultSet.getReal(2);
InventRep.insert();
}
CodeAccessPermission::revertAssert();
}
Hiç yorum yok:
Yorum Gönder