Показать сообщение отдельно
Старый 05.12.2017, 13:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
alirazazaidi: ODBC connection and Null value Handling Dynamics Ax 2012 R3.
Источник: https://www.tech.alirazazaidi.com/od...cs-ax-2012-r3/
==============

Today I have very small tip to share. I noted down, some odbc connection posts in my blog. All these post shares the code snippets , that used to open odbc connection and did query on SQL server directly. Couple of days ago, I need similar code snippet to read data from SQL server and Insert into another connect. But that code did not had reference to handling null values. So I note down that code snippet too, for future reference.



These all odbc connection , command return results in “ResultSet” class.



This ResultSet  class has method  “wasnull”. According to documentation, its behavior is strange. First we have to call the get method and then we call “WasNull” to verify that value appears is null or not.

https://msdn.microsoft.com/en-us/lib...t.wasnull.aspx



So whole code snippet will be like.

public void run()   { Connection Con = new Connection(); ResultSet R; str sql; Statement Stmt; SqlStatementExecutePermission permission; Real _RealValue; sql = "SELECT * FROM InventTrans "; Stmt = Con.createStatement(); permission = new SqlStatementExecutePermission(sql); permission.assert(); R =Stmt.executeQuery(sql);   while ( R.next() ) { _RealValue =R.getReal(1); if (  R.wasNull(1) ==boolean::false) {   info (" Not null"); } Else { Info (" Null "); }       } CodeAccessPermission::revertAssert();   }

Источник: https://www.tech.alirazazaidi.com/od...cs-ax-2012-r3/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.