0

I am trying to execute a PLSQL UTL_FILE command through an ASP.NET web app and keep encountering this error;

[Oracle][ODBC]Syntax error or access violation.

I am passing in a string (filename) into the sql (insql) and using the below code to execute the command. Note - I pass the sql string and an sql type (1 - UPDATE, 2 - UTL_FILE) into the sub SqlConn;

Public Sub SqlConn(insql, sql_type)

    Dim cn As New ADODB.Connection

    cn.ConnectionString = "Driver=[Microsoft driver for Oracle];Data Source=[Name];Persist Security Info=True;User ID=UID;Password=PWD"
    cn.ConnectionTimeout = 900
    cn.Open()

    If sql_type = 1 Then

        Dim rs As New ADODB.Recordset()

        Dim da As New OleDbDataAdapter()

        Dim ds As New DataSet()

        With rs
            .CursorLocation = ADODB.CursorLocationEnum.adUseClient
            .CursorType = ADODB.CursorTypeEnum.adOpenStatic
            .LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
            .Open(insql, cn.ConnectionString)
        End With
    ElseIf sql_type = 2 Then

        Dim cmd As New ADODB.Command
        cmd.CommandText = insql.ToString
        cmd.ActiveConnection = cn
        cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
        cmd.Execute()

    End If

    cn.Close()

End Sub

What does this specifically mean and what can I do to prevent this whilst executing the utl_file command successfully?

Through StackOverflow I found this helpful link; Here My driver, however, isn't the issue as all other commands execute without issue.

Appreciate anyone who can help.

chrisberry86
  • 35
  • 1
  • 1
  • 9
  • Please show the complete SQL being executed. If you are getting an access denied error, then the os account that the oracle service is running under does not have rights to access the folder/file. – OldProgrammer Apr 27 '15 at 14:42
  • Apologies; Call SqlConn("exec utl_file.fremove('CSV_IMPORT_DIR','" & KeyField.ToString & "');", 2) This query runs under oracle sql developer without issue under the same user credentials from the web app – chrisberry86 Apr 27 '15 at 14:53
  • 1
    Exec is not a SQL or PL/SQL command. Instead it is a client tool command. – Shannon Severance Apr 27 '15 at 17:54

0 Answers0