dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OraclePackage Class / SetVariable Method
Name of the variable in the package.
A value that will be assigned to the variable.
Example

In This Topic
    SetVariable Method
    In This Topic
    Assigns specified value to a variable from the package.
    Syntax
    'Declaration
     
    Public Sub SetVariable( _
       ByVal variableName As String, _
       ByVal value As Object _
    ) 
    public void SetVariable( 
       string variableName,
       object value
    )

    Parameters

    variableName
    Name of the variable in the package.
    value
    A value that will be assigned to the variable.
    Remarks
    Use SetVariable method to set 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 sets the new 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