Friday 22 May 2015

Form - VB.net get next available value for column

To get the nex available value for a column - example:

 Public Overrides Sub Button_Click()  
   dim nummerfeld as Autodesk.Map.IM.Forms.DialogControls.TextBox  
   nummerfeld = Me.Dialog.Controls.Item("NUMMER")   
   dim maxNummer as Long = Me.Document.ConnectionTools.LngValue("select max(NUMMER)+1 from wse_br_wohnen")  
   nummerfeld.Value = maxNummer   
 End Sub  

Tuesday 19 May 2015

Execute stored procedure from form

I was asked to figure out how to execute a stored procedure from a form. Here is a working sample (VB.net):


 Public Overrides Sub Button_Click()  
   
      ' prepare SQL execution  
      Dim MyCommand As Autodesk.Map.IM.Data.Provider.Command = New Autodesk.Map.IM.Data.Provider.Command("", Me.Document.Connection)  
   
      ' define input/output parameters for stored procedure  
      Dim ParameterOut as Autodesk.Map.IM.Data.Provider.DataParameter  
      Dim ParameterIn1 as Autodesk.Map.IM.Data.Provider.DataParameter  
      Dim Parameterin2 as Autodesk.Map.IM.Data.Provider.DataParameter  
      Dim returnValue as String  
   
      ' set up SQL command - type StoredProcedure  
      MyCommand.CommandType = System.Data.CommandType.StoredProcedure  
      ' PackageName.ProcedureName  
      MyCommand.CommandText = "emp_eval.eval_department"  
   
      ' assign values to input parameters  
      ParameterIn1 = MyCommand.CreateParameter()    
      ParameterIn1 .DbType = System.Data.DbType.Int32  
      ParameterIn1 .ParameterName = "DEPARTMENT_ID"  
      ParameterIn1 .Value = 100  
      ParameterIn1 .Direction = System.Data.ParameterDirection.Input  
      ParameterIn2= MyCommand.CreateParameter()    
      ParameterIn2.DbType = System.Data.DbType.Int32  
      ParameterIn2.ParameterName = "DUMMY_ID"  
      ParameterIn2.Value = 101  
      ParameterIn2.Direction = System.Data.ParameterDirection.Input  
        
      ' set up output parameter - return value   
      ParameterOut= MyCommand.CreateParameter()    
      ParameterOut.DbType = System.Data.DbType.String  
      ParameterOut.ParameterName = "TEXT"  
      'Direction needs to be Output and not ReturnValue   
      ParameterOut.Direction = System.Data.ParameterDirection.Output   
   
      ' add parameters to sql command, keep order of parameters in mind  
      MyCommand.Parameters.Add(ParameterIn1 )   
      MyCommand.Parameters.Add(ParameterIn2 )  
      MyCommand.Parameters.Add(ParameterOut )  
        
      ' execute SQL   
      MyCommand.ExecuteNonQuery()  
         
      ' get output/return value  
       returnValue = MyCommand.Parameters.Item("TEXT").Value  
       MyCommand.Dispose()  
       MsgBox("ok --> " & returnValue)  
         
      'refresh dialog   
      me.Dialog.Requery()  
  End Sub  

In Oracle the procedure is defined as:

PROCEDURE eval_department(department_id IN NUMBER , dummy_id IN NUMBER, text OUT VARCHAR2) ;

I found a presentation from the 2007 Oracle Spatial user Conference with some sample code but I needed to adapt it a bit:

http://download.oracle.com/otndocs/products/spatial/pdf/osuc2007_presentations/gita07200a_lvvwd.pdf

Map 2013

AutoCAD Map and AIMS - addtional log files

Map and AIMS provide additional log files related to industry models. Log files are created automatically and saved in the "LOG" sub-folder of the installation, e.g.:

C:\Program Files\Autodesk\AutoCAD Map 3D 2013\Log

In the past I used java based Chainsaw to view the logfiles. A few weeks ago I was pointed to another viewer for these log files called YALV!. It is easier to install and provides more comfort viewing/filtering error messages: