Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to execute sets of DDL Statements in 1 command?

Allen SandiegoApr 13 2008 — edited Apr 14 2008
Hi All,

I've been trying to look for a way to run a set of DDL statements. I normally have text files with DDL Statements on it. So what I do is load the contents of this text file into a Textbox and then set the Textbox.Text as the CommandText of my command object. Unfortunately I get errors.

Here's my code...
    Private Sub btnLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OpenDiag As New OpenFileDialog
        Dim txtReader As StreamReader

        OpenDiag.ShowDialog()
        If OpenDiag.FileName <> "" Then
            txtReader = File.OpenText(OpenDiag.FileName)
            CommandTextBox.Text = txtReader.ReadToEnd
        End If
    End Sub


    Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim myConn As New OracleConnection(My.Settings.ConnectionString)
        Dim myComm As New OracleCommand(CommandTextBox.Text, myConn)
        Try
            myConn.Open()
            myComm.ExecuteNonQuery()
            myConn.Close()
        Catch ex As OracleException
            MessageBox.Show(ex.Code & ": " & ex.Message)
        End Try
    End Sub
The errors that I get are
"ORA-00900: Invalid SQL Statement"
- Not sure how I get this but I noticed that if i had remarks/comments in my text file, this is the error that i get. Although i don't get this error if i execute in SQL Plus.
"ORA-00911: Invalid Character"
- after removing the remarks/comments, i get this error. i tried removing the semi-colon ";" then it works okay if i'm running 1 DDL statement in my file.. but if i my file contains to DDL statements for example, then i get the this error "ORA-00922: Missing or Invalid Options".

can anyone help me with this?
thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 12 2008
Added on Apr 13 2008
2 comments
1,669 views