Dear All.I can connect to odbc and fetch the data from external db(which can see in infolog),but how can I insert the data in my staging table in ax. I need help of some coding example on how to import the data to my staging table.
I use code below to connect and get data from external db, but cant insert the data into staging stable.
----------------------
void clicked()
{
ODBCConnection myODBC;
Statement myStatement;
LoginProperty myLP;
ResultSet myRs;
str mySQLStatement,st2;
str myConnStr;
str myDSN = "xx";
str myUserName = "xxxxxx";
str myPassword = "xxxxxxx";
CTG stagingTbl;
;
myConnStr = strfmt("DSN=%1;UID=%2;PWD=%3", myDSN, myUserName, myPassword);
myLP = new LoginProperty();
myLP.setOther(myConnStr);
try
{
myODBC = new ODBCConnection(myLP);
myStatement = myODBC.createStatement();
mySQLStatement = "Select * from CTG";
myRs = myStatement.executeQuery(mySQLStatement);//szs
while(myRs.next())
{
info(strfmt("%1 %2 %3 %4", myRs.getString(1), myRs.getString(2), myRs.getString(3), myRs.getString(4)));
//stagingTbl.clear();//szs
stagingTbl.createdDate = myRs.getDateTime(1);
stagingTbl.changedDate = myRs.getDateTime(2);
stagingTbl.CTG = myRs.getString(3);
stagingTbl.CTGDescription = myRs.getString(4);
stagingTbl.insert();
}
}
catch
{
error('unexpected error');
}
//super();
}
---------------
My staging table is CTG. But the code to insert data into staging table did not work.
Thank You