简体   繁体   中英

PL/SQL: numeric or value error: character string buffer too small - app remotely published

I have following stored procedure:

create or replace PROCEDURE TEST_REQUEST(
   outHTML OUT VARCHAR2,
   varParameters IN XMLTYPE)
IS
   tmpVar   NUMBER;
BEGIN
   outHTML :=
      '<table><tr><td>Test!</td></tr></table>';
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      NULL;
   WHEN OTHERS
   THEN
      -- Consider logging the error and then re-raise
      RAISE;
END TEST_REQUEST;

input parameter 'varParameters'=

'<test>
  <testid>3DA736A8A4562E053D6</testid>
  <testaction>Reject</testaction>
</test>'

And when I call the above stored procedure:

using (OracleConnection connection = new OracleConnection())
{
      connection.ConnectionString = this.ConnectionString;
      connection.Open();

      using (OracleCommand command = new OracleCommand())
      {
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.BindByName = true;
            command.CommandText = "TEST_OWNER.TEST_REQUEST ";

            OracleParameter outHtml = command.Parameters.Add("outHTML", OracleDbType.Varchar2);
            outHtml.Direction = ParameterDirection.Output;
            outHtml.Size = Int16.MaxValue;
            command.Parameters.Add("varParameters", OracleDbType.XmlType).Value = doc;

            command.ExecuteNonQuery();
            ....               

        }
        connection.Close();
   }

Everything works fine when I run it on localhost but once app is remotely published I receive following error:

ORA-06502: PL/SQL: numeric or value error: character string buffer too >small\\nORA-06512: at \\"TEST_REQUEST \\"

I have no clue what might causing the exception. Size of out parameter is set to pretty high, I checked ODAC drivers and everything looks ok. Any ideas?

You can look for this 3 solutions.

1) Try setting the buffer size before you run your script.

SQL > set serveroutput on buffer 2560000

2) else check the data which you are processing. it seems that there is some string data which are not properly quoted and because of that it is crashing.

3) or may be the size is the problem. See below code.

SQL>

DECLARE
  2     v_test VARCHAR2(1);
  3  BEGIN
  4     v_test := 'bananas';
  5  END;
  6  /

DECLARE * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 4

SQL> CREATE TABLE bananas (name VARCHAR2(1));

Table created.

SQL> INSERT INTO bananas (name) VALUES ('One banana two banana');
INSERT INTO bananas (name) VALUES ('One banana two banana')
                               *

ERROR at line 1: ORA-01401: inserted value too large for column

Try this one:

OracleParameter outHtml = command.Parameters.Add("outHTML", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output;

Hope this helps !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM