dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OraclePackage Class / GetVariable Method
Name of the variable in the package.
One of the OracleDbType values.
Example

In This Topic
    GetVariable Method
    In This Topic
    Returns a value of the variable in the package mapped to the specified type.
    Syntax
    'Declaration
     
    Public Function GetVariable( _
       ByVal variableName As String, _
       ByVal dbType As OracleDbType _
    ) As Object
    public object GetVariable( 
       string variableName,
       OracleDbType dbType
    )

    Parameters

    variableName
    Name of the variable in the package.
    dbType
    One of the OracleDbType values.

    Return Value

    A value of the variable in the package.
    Remarks
    Use GetVariable method to obtain the value of a package variable or constant declared within Oracle package. If the name does not exist an exception will be thrown.
    Example
    The following example obtains and then prints the variable value.
    public void GetPackageVariableValue(OracleConnection conn)
    {
      OraclePackage package = new OraclePackage();
    
      // Set active connection
      // Connection must be opened
      package.Connection = conn;
    
      // Set package name where stored procedure exists
      package.PackageName = "oranet_pack";
    
      // Get variable value
      object pkgVar = package.GetVariable("package_variable", OracleDbType.VarChar);
    
      // Print variable value
      Console.WriteLine(pkgVar);
    
      // Set variable to specific value
      package.SetVariable("package_variable", "test string");
    
      // Get variable value
      pkgVar = package.GetVariable("package_variable", OracleDbType.VarChar);
    
      // Print variable value
      Console.WriteLine(pkgVar);
    }
    Public Sub GetPackageVariableValue(conn As OracleConnection)
      Dim package As New OraclePackage()
    
      ' Set active connection
      ' Connection must be opened
      package.Connection = conn
    
      ' Set package name where stored procedure exists
      package.PackageName = "oranet_pack"
    
      ' Get variable value
      Dim pkgVar As Object
      pkgVar = package.GetVariable("package_variable", OracleDbType.VarChar)
    
      ' Print variable value
      Console.WriteLine(pkgVar)
    
      ' Set variable to specific value
      package.SetVariable("package_variable", "test string")
    
      ' Get variable value
      pkgVar = package.GetVariable("package_variable", OracleDbType.VarChar)
    
      ' Print variable value
      Console.WriteLine(pkgVar)
    End Sub 'GetPackageVariableValue
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also