Getting output buffer from DBMS_OUTPUT.GET_LINES in C#












9














I'm trying to get the output from the DBMS_OUTPUT.PUT_LINE() method in my anonymous PL/SQL block through C#. I've looked at a couple of other related questions here, but am still having trouble. The return code of executing the anonymous block is returning -1, which should be correct based on the docs.



I'm setting the DBMS_OUTPUT.ENABLE() to NULL in order to not set a specific buffer size, then using the DBMS_OUTPUT.GET_LINES() method in order to get the lines from that buffer.



It returns nothing in the buffer (An empty OracleString) and returns 0 lines. My anonymous PL/SQL block is simple like this, but should work for any.



DECLARE
lvsName VARCHAR2(6) := 'Oracle';
BEGIN
DBMS_OUTPUT.PUT_LINE('Do you see me?');
DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName);
END;


What am I missing?



using (OracleDataAdapter oda = new OracleDataAdapter())
using (OracleCommand cmd = new OracleCommand(sql, _connection))
{
// Execute anonymous PL/SQL block
cmd.CommandType = CommandType.Text;
var res = cmd.ExecuteNonQuery();

// Set output Buffer
cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();

// Get output
cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
cmd.CommandType = CommandType.Text;
cmd.Parameters.Clear();
cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
cmd.Parameters["outString"].Size = sql.Length;
cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];
cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
cmd.Parameters["numLines"].Value = 10; // Get 10 lines
cmd.ExecuteNonQuery();

int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
string outString = string.Empty;

// Try to get more lines until there are zero left
while (numLines > 0)
{
for (int i = 0; i < numLines; i++)
{
OracleString s = (OracleString)cmd.Parameters["outString"].Value;
outString += s.ToString();
}

cmd.ExecuteNonQuery();
numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
}

return outString;
}









share|improve this question





























    9














    I'm trying to get the output from the DBMS_OUTPUT.PUT_LINE() method in my anonymous PL/SQL block through C#. I've looked at a couple of other related questions here, but am still having trouble. The return code of executing the anonymous block is returning -1, which should be correct based on the docs.



    I'm setting the DBMS_OUTPUT.ENABLE() to NULL in order to not set a specific buffer size, then using the DBMS_OUTPUT.GET_LINES() method in order to get the lines from that buffer.



    It returns nothing in the buffer (An empty OracleString) and returns 0 lines. My anonymous PL/SQL block is simple like this, but should work for any.



    DECLARE
    lvsName VARCHAR2(6) := 'Oracle';
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Do you see me?');
    DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName);
    END;


    What am I missing?



    using (OracleDataAdapter oda = new OracleDataAdapter())
    using (OracleCommand cmd = new OracleCommand(sql, _connection))
    {
    // Execute anonymous PL/SQL block
    cmd.CommandType = CommandType.Text;
    var res = cmd.ExecuteNonQuery();

    // Set output Buffer
    cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();

    // Get output
    cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.Clear();
    cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
    cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    cmd.Parameters["outString"].Size = sql.Length;
    cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];
    cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
    cmd.Parameters["numLines"].Value = 10; // Get 10 lines
    cmd.ExecuteNonQuery();

    int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
    string outString = string.Empty;

    // Try to get more lines until there are zero left
    while (numLines > 0)
    {
    for (int i = 0; i < numLines; i++)
    {
    OracleString s = (OracleString)cmd.Parameters["outString"].Value;
    outString += s.ToString();
    }

    cmd.ExecuteNonQuery();
    numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
    }

    return outString;
    }









    share|improve this question



























      9












      9








      9


      0





      I'm trying to get the output from the DBMS_OUTPUT.PUT_LINE() method in my anonymous PL/SQL block through C#. I've looked at a couple of other related questions here, but am still having trouble. The return code of executing the anonymous block is returning -1, which should be correct based on the docs.



      I'm setting the DBMS_OUTPUT.ENABLE() to NULL in order to not set a specific buffer size, then using the DBMS_OUTPUT.GET_LINES() method in order to get the lines from that buffer.



      It returns nothing in the buffer (An empty OracleString) and returns 0 lines. My anonymous PL/SQL block is simple like this, but should work for any.



      DECLARE
      lvsName VARCHAR2(6) := 'Oracle';
      BEGIN
      DBMS_OUTPUT.PUT_LINE('Do you see me?');
      DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName);
      END;


      What am I missing?



      using (OracleDataAdapter oda = new OracleDataAdapter())
      using (OracleCommand cmd = new OracleCommand(sql, _connection))
      {
      // Execute anonymous PL/SQL block
      cmd.CommandType = CommandType.Text;
      var res = cmd.ExecuteNonQuery();

      // Set output Buffer
      cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
      cmd.CommandType = CommandType.Text;
      cmd.ExecuteNonQuery();

      // Get output
      cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
      cmd.CommandType = CommandType.Text;
      cmd.Parameters.Clear();
      cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
      cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
      cmd.Parameters["outString"].Size = sql.Length;
      cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];
      cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
      cmd.Parameters["numLines"].Value = 10; // Get 10 lines
      cmd.ExecuteNonQuery();

      int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
      string outString = string.Empty;

      // Try to get more lines until there are zero left
      while (numLines > 0)
      {
      for (int i = 0; i < numLines; i++)
      {
      OracleString s = (OracleString)cmd.Parameters["outString"].Value;
      outString += s.ToString();
      }

      cmd.ExecuteNonQuery();
      numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
      }

      return outString;
      }









      share|improve this question















      I'm trying to get the output from the DBMS_OUTPUT.PUT_LINE() method in my anonymous PL/SQL block through C#. I've looked at a couple of other related questions here, but am still having trouble. The return code of executing the anonymous block is returning -1, which should be correct based on the docs.



      I'm setting the DBMS_OUTPUT.ENABLE() to NULL in order to not set a specific buffer size, then using the DBMS_OUTPUT.GET_LINES() method in order to get the lines from that buffer.



      It returns nothing in the buffer (An empty OracleString) and returns 0 lines. My anonymous PL/SQL block is simple like this, but should work for any.



      DECLARE
      lvsName VARCHAR2(6) := 'Oracle';
      BEGIN
      DBMS_OUTPUT.PUT_LINE('Do you see me?');
      DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName);
      END;


      What am I missing?



      using (OracleDataAdapter oda = new OracleDataAdapter())
      using (OracleCommand cmd = new OracleCommand(sql, _connection))
      {
      // Execute anonymous PL/SQL block
      cmd.CommandType = CommandType.Text;
      var res = cmd.ExecuteNonQuery();

      // Set output Buffer
      cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
      cmd.CommandType = CommandType.Text;
      cmd.ExecuteNonQuery();

      // Get output
      cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
      cmd.CommandType = CommandType.Text;
      cmd.Parameters.Clear();
      cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
      cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
      cmd.Parameters["outString"].Size = sql.Length;
      cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];
      cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
      cmd.Parameters["numLines"].Value = 10; // Get 10 lines
      cmd.ExecuteNonQuery();

      int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
      string outString = string.Empty;

      // Try to get more lines until there are zero left
      while (numLines > 0)
      {
      for (int i = 0; i < numLines; i++)
      {
      OracleString s = (OracleString)cmd.Parameters["outString"].Value;
      outString += s.ToString();
      }

      cmd.ExecuteNonQuery();
      numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
      }

      return outString;
      }






      c# .net oracle odp.net oracle-manageddataaccess






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 at 17:43









      jsanalytics

      11.1k41537




      11.1k41537










      asked Nov 20 at 22:09









      Jimenemex

      1,9851421




      1,9851421
























          3 Answers
          3






          active

          oldest

          votes


















          3





          +100









          The main problem with your code was that it was not setting the bind size for each element of your output buffer. Also it was not properly indexing the output buffer when retrieving the results. And finally, the order of execution also plays a role: you have to first enable your output before executing your anonymous block of code. Every single change made is commented in the following MCVE. Only necessary changes to get it working were made.



          static void Main(string args)
          {
          string str = "User Id=xxx; password=xxx; Data Source=localhost:1521/xxx;";
          string sql = @"DECLARE lvsName VARCHAR2(6) := 'Oracle'; BEGIN DBMS_OUTPUT.PUT_LINE('Do you see me?'); DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName); END;";

          OracleConnection _connection = new OracleConnection(str);

          try
          {
          _connection.Open();

          //adapter not being used
          //using (OracleDataAdapter oda = new OracleDataAdapter())

          using (OracleCommand cmd = new OracleCommand(sql, _connection))
          {
          // First enable buffer output
          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Then execute anonymous block
          // Execute anonymous PL/SQL block
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();


          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
          cmd.CommandType = CommandType.Text;

          cmd.Parameters.Clear();

          cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
          cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          cmd.Parameters["outString"].Size = sql.Length;
          cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];

          // set bind size for each array element
          for (int i = 0; i < sql.Length; i++)
          {
          cmd.Parameters["outString"].ArrayBindSize[i] = 32000;
          }


          cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
          cmd.Parameters["numLines"].Value = 10; // Get 10 lines
          cmd.ExecuteNonQuery();

          int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          string outString = string.Empty;

          // Try to get more lines until there are zero left
          while (numLines > 0)
          {
          for (int i = 0; i < numLines; i++)
          {
          // use proper indexing here
          //OracleString s = (OracleString)cmd.Parameters["outString"].Value;
          OracleString s = ((OracleString)cmd.Parameters["outString"].Value)[i];
          outString += s.ToString();

          // add new line just for formatting
          outString += "rn";
          }

          cmd.ExecuteNonQuery();
          numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          }

          Console.WriteLine(outString);
          }
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.ToString());
          }

          _connection.Close();
          _connection.Dispose();

          Console.WriteLine("Press RETURN to exit.");
          Console.ReadLine();
          }


          And the output result is:



          Do you see me?
          My name is: Oracle

          Press RETURN to exit.





          share|improve this answer



















          • 1




            I knew I was close, Thanks!
            – Jimenemex
            Dec 3 at 14:20










          • I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
            – Felypp Oliveira
            Dec 3 at 16:16



















          1














          I don't speak C# but i don't see in your code where you are assigning value to the numLines variable.



            DBMS_OUTPUT.GET_LINES (
          lines OUT CHARARR,
          numlines IN OUT INTEGER);


          Example in plsql:



          DECLARE
          v_array DBMS_OUTPUT.CHARARR;
          v_lines NUMBER;
          BEGIN
          DBMS_OUTPUT.PUT_LINE ('aaaaa');
          DBMS_OUTPUT.put_line ('bbbb');
          DBMS_OUTPUT.put_line ('ccccc');
          v_lines := 1000; -- Number of lines you want to retrieve from the buffer.
          DBMS_OUTPUT.GET_LINES (v_array, v_lines);

          DBMS_OUTPUT.put_line(v_lines); -- Lines retrieved from buffer.
          FOR idx IN nvl(v_array.FIRST,1) .. nvl(v_array.LAST,-1)
          LOOP
          DBMS_OUTPUT.put_line (v_array (idx));
          END LOOP;
          END;





          share|improve this answer

















          • 1




            The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
            – Jimenemex
            Nov 21 at 15:03





















          1














          It looks to me that you're doing it in the wrong order...



          // Execute anonymous PL/SQL block
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();

          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";


          Between setting (enabling) the DBMS_OUTPUT and getting the output using GET_LINES should be your write command, but instead, it's the first thing you're executing.



          Try to change the order. Let me know if it works cause I didn't try it (I'm not used to C#... I have it in Java).






          share|improve this answer

















          • 1




            I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
            – Jimenemex
            Nov 26 at 16:02










          • I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
            – Felypp Oliveira
            Nov 26 at 18:14













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402356%2fgetting-output-buffer-from-dbms-output-get-lines-in-c-sharp%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3





          +100









          The main problem with your code was that it was not setting the bind size for each element of your output buffer. Also it was not properly indexing the output buffer when retrieving the results. And finally, the order of execution also plays a role: you have to first enable your output before executing your anonymous block of code. Every single change made is commented in the following MCVE. Only necessary changes to get it working were made.



          static void Main(string args)
          {
          string str = "User Id=xxx; password=xxx; Data Source=localhost:1521/xxx;";
          string sql = @"DECLARE lvsName VARCHAR2(6) := 'Oracle'; BEGIN DBMS_OUTPUT.PUT_LINE('Do you see me?'); DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName); END;";

          OracleConnection _connection = new OracleConnection(str);

          try
          {
          _connection.Open();

          //adapter not being used
          //using (OracleDataAdapter oda = new OracleDataAdapter())

          using (OracleCommand cmd = new OracleCommand(sql, _connection))
          {
          // First enable buffer output
          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Then execute anonymous block
          // Execute anonymous PL/SQL block
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();


          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
          cmd.CommandType = CommandType.Text;

          cmd.Parameters.Clear();

          cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
          cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          cmd.Parameters["outString"].Size = sql.Length;
          cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];

          // set bind size for each array element
          for (int i = 0; i < sql.Length; i++)
          {
          cmd.Parameters["outString"].ArrayBindSize[i] = 32000;
          }


          cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
          cmd.Parameters["numLines"].Value = 10; // Get 10 lines
          cmd.ExecuteNonQuery();

          int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          string outString = string.Empty;

          // Try to get more lines until there are zero left
          while (numLines > 0)
          {
          for (int i = 0; i < numLines; i++)
          {
          // use proper indexing here
          //OracleString s = (OracleString)cmd.Parameters["outString"].Value;
          OracleString s = ((OracleString)cmd.Parameters["outString"].Value)[i];
          outString += s.ToString();

          // add new line just for formatting
          outString += "rn";
          }

          cmd.ExecuteNonQuery();
          numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          }

          Console.WriteLine(outString);
          }
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.ToString());
          }

          _connection.Close();
          _connection.Dispose();

          Console.WriteLine("Press RETURN to exit.");
          Console.ReadLine();
          }


          And the output result is:



          Do you see me?
          My name is: Oracle

          Press RETURN to exit.





          share|improve this answer



















          • 1




            I knew I was close, Thanks!
            – Jimenemex
            Dec 3 at 14:20










          • I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
            – Felypp Oliveira
            Dec 3 at 16:16
















          3





          +100









          The main problem with your code was that it was not setting the bind size for each element of your output buffer. Also it was not properly indexing the output buffer when retrieving the results. And finally, the order of execution also plays a role: you have to first enable your output before executing your anonymous block of code. Every single change made is commented in the following MCVE. Only necessary changes to get it working were made.



          static void Main(string args)
          {
          string str = "User Id=xxx; password=xxx; Data Source=localhost:1521/xxx;";
          string sql = @"DECLARE lvsName VARCHAR2(6) := 'Oracle'; BEGIN DBMS_OUTPUT.PUT_LINE('Do you see me?'); DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName); END;";

          OracleConnection _connection = new OracleConnection(str);

          try
          {
          _connection.Open();

          //adapter not being used
          //using (OracleDataAdapter oda = new OracleDataAdapter())

          using (OracleCommand cmd = new OracleCommand(sql, _connection))
          {
          // First enable buffer output
          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Then execute anonymous block
          // Execute anonymous PL/SQL block
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();


          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
          cmd.CommandType = CommandType.Text;

          cmd.Parameters.Clear();

          cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
          cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          cmd.Parameters["outString"].Size = sql.Length;
          cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];

          // set bind size for each array element
          for (int i = 0; i < sql.Length; i++)
          {
          cmd.Parameters["outString"].ArrayBindSize[i] = 32000;
          }


          cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
          cmd.Parameters["numLines"].Value = 10; // Get 10 lines
          cmd.ExecuteNonQuery();

          int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          string outString = string.Empty;

          // Try to get more lines until there are zero left
          while (numLines > 0)
          {
          for (int i = 0; i < numLines; i++)
          {
          // use proper indexing here
          //OracleString s = (OracleString)cmd.Parameters["outString"].Value;
          OracleString s = ((OracleString)cmd.Parameters["outString"].Value)[i];
          outString += s.ToString();

          // add new line just for formatting
          outString += "rn";
          }

          cmd.ExecuteNonQuery();
          numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          }

          Console.WriteLine(outString);
          }
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.ToString());
          }

          _connection.Close();
          _connection.Dispose();

          Console.WriteLine("Press RETURN to exit.");
          Console.ReadLine();
          }


          And the output result is:



          Do you see me?
          My name is: Oracle

          Press RETURN to exit.





          share|improve this answer



















          • 1




            I knew I was close, Thanks!
            – Jimenemex
            Dec 3 at 14:20










          • I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
            – Felypp Oliveira
            Dec 3 at 16:16














          3





          +100







          3





          +100



          3




          +100




          The main problem with your code was that it was not setting the bind size for each element of your output buffer. Also it was not properly indexing the output buffer when retrieving the results. And finally, the order of execution also plays a role: you have to first enable your output before executing your anonymous block of code. Every single change made is commented in the following MCVE. Only necessary changes to get it working were made.



          static void Main(string args)
          {
          string str = "User Id=xxx; password=xxx; Data Source=localhost:1521/xxx;";
          string sql = @"DECLARE lvsName VARCHAR2(6) := 'Oracle'; BEGIN DBMS_OUTPUT.PUT_LINE('Do you see me?'); DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName); END;";

          OracleConnection _connection = new OracleConnection(str);

          try
          {
          _connection.Open();

          //adapter not being used
          //using (OracleDataAdapter oda = new OracleDataAdapter())

          using (OracleCommand cmd = new OracleCommand(sql, _connection))
          {
          // First enable buffer output
          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Then execute anonymous block
          // Execute anonymous PL/SQL block
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();


          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
          cmd.CommandType = CommandType.Text;

          cmd.Parameters.Clear();

          cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
          cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          cmd.Parameters["outString"].Size = sql.Length;
          cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];

          // set bind size for each array element
          for (int i = 0; i < sql.Length; i++)
          {
          cmd.Parameters["outString"].ArrayBindSize[i] = 32000;
          }


          cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
          cmd.Parameters["numLines"].Value = 10; // Get 10 lines
          cmd.ExecuteNonQuery();

          int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          string outString = string.Empty;

          // Try to get more lines until there are zero left
          while (numLines > 0)
          {
          for (int i = 0; i < numLines; i++)
          {
          // use proper indexing here
          //OracleString s = (OracleString)cmd.Parameters["outString"].Value;
          OracleString s = ((OracleString)cmd.Parameters["outString"].Value)[i];
          outString += s.ToString();

          // add new line just for formatting
          outString += "rn";
          }

          cmd.ExecuteNonQuery();
          numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          }

          Console.WriteLine(outString);
          }
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.ToString());
          }

          _connection.Close();
          _connection.Dispose();

          Console.WriteLine("Press RETURN to exit.");
          Console.ReadLine();
          }


          And the output result is:



          Do you see me?
          My name is: Oracle

          Press RETURN to exit.





          share|improve this answer














          The main problem with your code was that it was not setting the bind size for each element of your output buffer. Also it was not properly indexing the output buffer when retrieving the results. And finally, the order of execution also plays a role: you have to first enable your output before executing your anonymous block of code. Every single change made is commented in the following MCVE. Only necessary changes to get it working were made.



          static void Main(string args)
          {
          string str = "User Id=xxx; password=xxx; Data Source=localhost:1521/xxx;";
          string sql = @"DECLARE lvsName VARCHAR2(6) := 'Oracle'; BEGIN DBMS_OUTPUT.PUT_LINE('Do you see me?'); DBMS_OUTPUT.PUT_LINE('My name is: ' || lvsName); END;";

          OracleConnection _connection = new OracleConnection(str);

          try
          {
          _connection.Open();

          //adapter not being used
          //using (OracleDataAdapter oda = new OracleDataAdapter())

          using (OracleCommand cmd = new OracleCommand(sql, _connection))
          {
          // First enable buffer output
          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Then execute anonymous block
          // Execute anonymous PL/SQL block
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();


          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";
          cmd.CommandType = CommandType.Text;

          cmd.Parameters.Clear();

          cmd.Parameters.Add(new OracleParameter("outString", OracleDbType.Varchar2, int.MaxValue, ParameterDirection.Output));
          cmd.Parameters["outString"].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          cmd.Parameters["outString"].Size = sql.Length;
          cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length];

          // set bind size for each array element
          for (int i = 0; i < sql.Length; i++)
          {
          cmd.Parameters["outString"].ArrayBindSize[i] = 32000;
          }


          cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput));
          cmd.Parameters["numLines"].Value = 10; // Get 10 lines
          cmd.ExecuteNonQuery();

          int numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          string outString = string.Empty;

          // Try to get more lines until there are zero left
          while (numLines > 0)
          {
          for (int i = 0; i < numLines; i++)
          {
          // use proper indexing here
          //OracleString s = (OracleString)cmd.Parameters["outString"].Value;
          OracleString s = ((OracleString)cmd.Parameters["outString"].Value)[i];
          outString += s.ToString();

          // add new line just for formatting
          outString += "rn";
          }

          cmd.ExecuteNonQuery();
          numLines = Convert.ToInt32(cmd.Parameters["numLines"].Value.ToString());
          }

          Console.WriteLine(outString);
          }
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.ToString());
          }

          _connection.Close();
          _connection.Dispose();

          Console.WriteLine("Press RETURN to exit.");
          Console.ReadLine();
          }


          And the output result is:



          Do you see me?
          My name is: Oracle

          Press RETURN to exit.






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 3 at 17:40

























          answered Dec 3 at 3:17









          jsanalytics

          11.1k41537




          11.1k41537








          • 1




            I knew I was close, Thanks!
            – Jimenemex
            Dec 3 at 14:20










          • I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
            – Felypp Oliveira
            Dec 3 at 16:16














          • 1




            I knew I was close, Thanks!
            – Jimenemex
            Dec 3 at 14:20










          • I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
            – Felypp Oliveira
            Dec 3 at 16:16








          1




          1




          I knew I was close, Thanks!
          – Jimenemex
          Dec 3 at 14:20




          I knew I was close, Thanks!
          – Jimenemex
          Dec 3 at 14:20












          I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
          – Felypp Oliveira
          Dec 3 at 16:16




          I couldn't get why this is the accepted answer since it's just reproducing the comment I added to my answer one week ago. Maybe cause you got a working code here, but it was clear enough in my comment where you should change your code and those were minor changes, just as you noted in your comment above. In reality, you're free to choose what's the right answer and this one is correct, it just wasn't the first to point you the entire solution, although it's not mandatory to choose the first, just would be fair imo, but I'm glad to help. Just hope I can get the points next time...
          – Felypp Oliveira
          Dec 3 at 16:16













          1














          I don't speak C# but i don't see in your code where you are assigning value to the numLines variable.



            DBMS_OUTPUT.GET_LINES (
          lines OUT CHARARR,
          numlines IN OUT INTEGER);


          Example in plsql:



          DECLARE
          v_array DBMS_OUTPUT.CHARARR;
          v_lines NUMBER;
          BEGIN
          DBMS_OUTPUT.PUT_LINE ('aaaaa');
          DBMS_OUTPUT.put_line ('bbbb');
          DBMS_OUTPUT.put_line ('ccccc');
          v_lines := 1000; -- Number of lines you want to retrieve from the buffer.
          DBMS_OUTPUT.GET_LINES (v_array, v_lines);

          DBMS_OUTPUT.put_line(v_lines); -- Lines retrieved from buffer.
          FOR idx IN nvl(v_array.FIRST,1) .. nvl(v_array.LAST,-1)
          LOOP
          DBMS_OUTPUT.put_line (v_array (idx));
          END LOOP;
          END;





          share|improve this answer

















          • 1




            The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
            – Jimenemex
            Nov 21 at 15:03


















          1














          I don't speak C# but i don't see in your code where you are assigning value to the numLines variable.



            DBMS_OUTPUT.GET_LINES (
          lines OUT CHARARR,
          numlines IN OUT INTEGER);


          Example in plsql:



          DECLARE
          v_array DBMS_OUTPUT.CHARARR;
          v_lines NUMBER;
          BEGIN
          DBMS_OUTPUT.PUT_LINE ('aaaaa');
          DBMS_OUTPUT.put_line ('bbbb');
          DBMS_OUTPUT.put_line ('ccccc');
          v_lines := 1000; -- Number of lines you want to retrieve from the buffer.
          DBMS_OUTPUT.GET_LINES (v_array, v_lines);

          DBMS_OUTPUT.put_line(v_lines); -- Lines retrieved from buffer.
          FOR idx IN nvl(v_array.FIRST,1) .. nvl(v_array.LAST,-1)
          LOOP
          DBMS_OUTPUT.put_line (v_array (idx));
          END LOOP;
          END;





          share|improve this answer

















          • 1




            The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
            – Jimenemex
            Nov 21 at 15:03
















          1












          1








          1






          I don't speak C# but i don't see in your code where you are assigning value to the numLines variable.



            DBMS_OUTPUT.GET_LINES (
          lines OUT CHARARR,
          numlines IN OUT INTEGER);


          Example in plsql:



          DECLARE
          v_array DBMS_OUTPUT.CHARARR;
          v_lines NUMBER;
          BEGIN
          DBMS_OUTPUT.PUT_LINE ('aaaaa');
          DBMS_OUTPUT.put_line ('bbbb');
          DBMS_OUTPUT.put_line ('ccccc');
          v_lines := 1000; -- Number of lines you want to retrieve from the buffer.
          DBMS_OUTPUT.GET_LINES (v_array, v_lines);

          DBMS_OUTPUT.put_line(v_lines); -- Lines retrieved from buffer.
          FOR idx IN nvl(v_array.FIRST,1) .. nvl(v_array.LAST,-1)
          LOOP
          DBMS_OUTPUT.put_line (v_array (idx));
          END LOOP;
          END;





          share|improve this answer












          I don't speak C# but i don't see in your code where you are assigning value to the numLines variable.



            DBMS_OUTPUT.GET_LINES (
          lines OUT CHARARR,
          numlines IN OUT INTEGER);


          Example in plsql:



          DECLARE
          v_array DBMS_OUTPUT.CHARARR;
          v_lines NUMBER;
          BEGIN
          DBMS_OUTPUT.PUT_LINE ('aaaaa');
          DBMS_OUTPUT.put_line ('bbbb');
          DBMS_OUTPUT.put_line ('ccccc');
          v_lines := 1000; -- Number of lines you want to retrieve from the buffer.
          DBMS_OUTPUT.GET_LINES (v_array, v_lines);

          DBMS_OUTPUT.put_line(v_lines); -- Lines retrieved from buffer.
          FOR idx IN nvl(v_array.FIRST,1) .. nvl(v_array.LAST,-1)
          LOOP
          DBMS_OUTPUT.put_line (v_array (idx));
          END LOOP;
          END;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 12:08









          Arkadiusz Łukasiewicz

          4,7691613




          4,7691613








          • 1




            The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
            – Jimenemex
            Nov 21 at 15:03
















          • 1




            The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
            – Jimenemex
            Nov 21 at 15:03










          1




          1




          The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
          – Jimenemex
          Nov 21 at 15:03






          The Parameter is added here: cmd.Parameters.Add(new OracleParameter("numLines", OracleDbType.Int32, ParameterDirection.InputOutput)); The value is set here: cmd.Parameters["numLines"].Value = 10; // Get 10 lines I've just added the actual addition for the .Value of the Parameter and have the same results.
          – Jimenemex
          Nov 21 at 15:03













          1














          It looks to me that you're doing it in the wrong order...



          // Execute anonymous PL/SQL block
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();

          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";


          Between setting (enabling) the DBMS_OUTPUT and getting the output using GET_LINES should be your write command, but instead, it's the first thing you're executing.



          Try to change the order. Let me know if it works cause I didn't try it (I'm not used to C#... I have it in Java).






          share|improve this answer

















          • 1




            I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
            – Jimenemex
            Nov 26 at 16:02










          • I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
            – Felypp Oliveira
            Nov 26 at 18:14


















          1














          It looks to me that you're doing it in the wrong order...



          // Execute anonymous PL/SQL block
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();

          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";


          Between setting (enabling) the DBMS_OUTPUT and getting the output using GET_LINES should be your write command, but instead, it's the first thing you're executing.



          Try to change the order. Let me know if it works cause I didn't try it (I'm not used to C#... I have it in Java).






          share|improve this answer

















          • 1




            I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
            – Jimenemex
            Nov 26 at 16:02










          • I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
            – Felypp Oliveira
            Nov 26 at 18:14
















          1












          1








          1






          It looks to me that you're doing it in the wrong order...



          // Execute anonymous PL/SQL block
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();

          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";


          Between setting (enabling) the DBMS_OUTPUT and getting the output using GET_LINES should be your write command, but instead, it's the first thing you're executing.



          Try to change the order. Let me know if it works cause I didn't try it (I'm not used to C#... I have it in Java).






          share|improve this answer












          It looks to me that you're doing it in the wrong order...



          // Execute anonymous PL/SQL block
          cmd.CommandType = CommandType.Text;
          var res = cmd.ExecuteNonQuery();

          // Set output Buffer
          cmd.CommandText = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();

          // Get output
          cmd.CommandText = "BEGIN DBMS_OUTPUT.GET_LINES(:outString, :numLines); END;";


          Between setting (enabling) the DBMS_OUTPUT and getting the output using GET_LINES should be your write command, but instead, it's the first thing you're executing.



          Try to change the order. Let me know if it works cause I didn't try it (I'm not used to C#... I have it in Java).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 at 13:52









          Felypp Oliveira

          1,686917




          1,686917








          • 1




            I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
            – Jimenemex
            Nov 26 at 16:02










          • I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
            – Felypp Oliveira
            Nov 26 at 18:14
















          • 1




            I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
            – Jimenemex
            Nov 26 at 16:02










          • I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
            – Felypp Oliveira
            Nov 26 at 18:14










          1




          1




          I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
          – Jimenemex
          Nov 26 at 16:02




          I tried this. I get :numLines to return 1, but the value of :outString is DbNull. {null}.
          – Jimenemex
          Nov 26 at 16:02












          I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
          – Felypp Oliveira
          Nov 26 at 18:14






          I still think you should write after enabling the DBMS_OUTPUT and before calling the GET_LINES. Also, in the line cmd.Parameters["outString"].ArrayBindSize = new int[sql.Length]; you're assigning an empty array to the ArrayBindSize... maybe you should initialize each position of this array. And also, in the line OracleString s = (OracleString)cmd.Parameters["outString"].Value; the return should be an array, shouldn't it? Can you confirm?
          – Felypp Oliveira
          Nov 26 at 18:14




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402356%2fgetting-output-buffer-from-dbms-output-get-lines-in-c-sharp%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          To store a contact into the json file from server.js file using a class in NodeJS

          Redirect URL with Chrome Remote Debugging Android Devices

          Dieringhausen