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
No comments:
Post a Comment