Does anyone know a way in which I can execute PL/SQL statements in a VB.NET program? Any input is appreciated.
Thanks.
Does anyone know a way in which I can execute PL/SQL statements in a VB.NET program? Any input is appreciated.
Thanks.
What have you done so far? (If you mean Presentation Layer in VB to communicate with SQL.)
I am trying to read an SQL file from an external source on my harddrive. The SQL file is written in pl/sql so when I try to execute it in vb.net I receive a lot of errors (for example it won't register REM as a proper comment command).
So far I have tried various imports with no luck.
Could it be that the file does not only contain PL/SQL? Comments in PL/SQL are
/* comment
comment */
or -- comment
Calling PL/SQL from VB .NET may basically be performed by executing the PL/SQL text like:
Dim sSQL As String
Try
'create and use a function
sSQL = "CREATE OR REPLACE FUNCTION MyMultiply( " & vbLf & _
"ifactor1 IN NUMBER, " & vbLf & _
"ifactor2 IN NUMBER " & vbLf & _
") RETURN NUMBER IS" & vbLf & _
" iResult NUMBER;" & vbLf & _
"BEGIN" & vbLf & _
" iResult:=iFactor1*iFactor2;" & vbLf & _
" RETURN iResult;" & vbLf & _
"END;"
Dim aCmd As New OracleCommand(sSQL, OracleConnection1)
aCmd.CommandType = CommandType.Text
OracleConnection1.Open()
aCmd.ExecuteNonQuery()
'
aCmd.CommandText = "SELECT MyMultiply(5, 7) FROM dual"
MessageBox.Show(aCmd.ExecuteScalar().ToString)
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
OracleConnection1.Close()
End Try
but there are traps for example using multiple PL/SQL statements in one call to "Execute...".
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.