.Net special characters within strings cause Oracle problems

Without the string replaces, running this string against an Oracle database will result in the procedure getting created, but with a compile error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
string s = @"
create or replace procedure MYTEST (
    myNumber IN Varchar2,
    myString OUT Varchar2 ) AS

BEGIN
    myString := 'hello world';
    EXCEPTION
        WHEN OTHERS THEN
            dbms_output.put_line('ERROR>> ' || SQLERRM);
END MYTEST ;
";
s = s.Replace(System.Environment.NewLine, "\r");
s = s.Replace("\t", "     ");

Leave a Reply