See Also

OracleScript Members  | Devart.Data.Oracle Namespace  | OracleCommand Class

Language

Visual Basic

C#

Show All

See AlsoLanguagesDevart.Data.OracleSend comments on this topic.

OracleScript Class

Devart.Data.Oracle Namespace : OracleScript Class

Serves to execute series of SQL statements separated by special symbols, like SQL*Plus scripts.

For a list of all members of this type, see OracleScript members.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         Devart.Common.DbScript
            Devart.Data.Oracle.OracleScript

Syntax

[Visual Basic]
Public Class OracleScript    Inherits DbScript    Implements IComponentIDisposable 
[C#]
public class OracleScript : DbScript, IComponentIDisposable 

Remarks

Often it is necessary to execute several SQL statements one by one. Sometimes it can be performed by anonymous PL/SQL block. But unfortunately it doesn't work always. For example DDL statements cannot be used in PL/SQL. Another way is using a lot of components such as OracleCommand. Usually it isn't a good solution. With only one OracleScript component you can execute several SQL statements as one. This sequence of statements is named script. To separate single statements use semicolon (;) or slash (/) symbols and for PL/SQL only slash. Note: Slash must be the first character in the line.

If you are SQL*Plus user or need to execute scripts written for SQL*Plus with OracleScript, you may find some useful hints in the OracleScript Hints for SQL*Plus Users article.

Example

Following example executes a script and handles script errors.

[C#] 

public void ExecuteScript(string sql, OracleConnection conn) { 
    OracleScript script = new OracleScript(sql, conn); 
    script.Error += new ScriptErrorEventHandler(this.OnError); 
    script.Execute(); 

 
public void OnError(object sender, Devart.Common.ScriptErrorEventArgs e) { 
    Console.WriteLine(e.Exception.Message); 
    e.Ignore = true; 

[Visual Basic] 

Public Sub ExecuteScript(ByVal Sql As String, ByVal conn As OracleConnection)
    Dim Script As OracleScript = New OracleScript(Sql, conn)
    AddHandler Script.Error, AddressOf OnError
    Script.Execute()
End Sub

Public Sub OnError(ByVal Sender As Object, ByVal e As Devart.Common.ScriptErrorEventArgs)
    Console.WriteLine(e.Exception.Message)
    e.Ignore = True
End Sub

See Also

OracleScript Members  | Devart.Data.Oracle Namespace  | OracleCommand Class

 

 


© 2002 - 2014 Devart. All Rights Reserved.