So I would like to execute an oracle plsql script from Visual Studio. I installed Oracle’s visual studio tools and opened up a new query window in VS2010 connected to an oracle db instance. Here’s a sample script that I’m trying to run:
DECLARE
BEGIN
DBMS_OUTPUT.put_line ('Hello World!'); --tried various types of statements here
END;
and no matter what I try to put into the body of the begin/end block I get the following:
ERROR
ORA-06550: line 4, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.
I don’t get the same issue when running from other tools like sql developer or toad. What gives?
Make sure you’ve added the new line character after
END;, i.e. line no. 4 must not be the last one:Oracle data client (
Oracle.DataAccess.Client) is really picky about that.Update: As I suspected, the problem had to do with line endings. It turns out that Oracle does not accept the
\r(0x0d) characters within PL/SQL script blocks (but seems to ignore them when processing normal SQL), yet the Query window uses standard Windows line endings\r\n(0x0d 0x0a), and this is exactly what causes the problem.I used Wireshark to see what’s transferred over the wire when I hit
Execute Querytoolbar button and when I selectMenu -> Tools -> Execute SQL *Plus Scriptmenu item. The result is strange, but predictable: Execute Query sends the query text as-is (and I gotPLS-00103), while Execute SQL *Plus Script does translate\r\nto\n(The command(s) successfully completed.)So it seems you’ve got these options:
Hope this helps.