PL/SQL: numeric or value error: character string buffer too small %ROWTYPE

拟墨画扇 提交于 2019-12-07 02:54:51

问题


I don't know if I am missing something but what I am doing is:

I have a function that returns a ROWTYPE

  FUNCTION myFunc(pChar CHAR) RETURN myTable%ROWTYPE AS
    myTable_rec myTable%ROWTYPE;
  BEGIN
    SELECT col1, col2, col3
    INTO myTable_rec.col1 
      , myTable_rec.col2
      , myTable_rec.col3
    FROM myTable
    WHERE col4 = pChar;

    RETURN(myTable_rec);
  END B001_03;

then in my procedure (which calls the function above), I declared:

myTable_rec myTable%ROWTYPE;

but when I call in the procedure:

...
myTable_rec := myFunc(someChar);
...

I get

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

Aren't the fields supposed to be FROM the same table and OF THE SAME datatype (as of my little understanding)?

EDIT: I tried to SELECT * and every works. I am definitely missing something here. I just don't know that it is.


回答1:


I bet the problem originates from using Char which is a fixed length string. Not sure where, but somewhere in your code you try to put a Char or varchar2 string of length N into a char of lengh M where M > N.




回答2:


I was getting this error while accessing Oracle SP through my .Net code. If someone is facing this error then for him/her specifying the size of the input / output parameter would help solving the issue.

Sample code goes like this :

OracleParameter oparamProjectId = mycom.Parameters.Add("p_open_flag", OracleDbType.Varchar2); oparamProjectId.Direction = ParameterDirection.Output; oparamProjectId.Size = 100;



来源:https://stackoverflow.com/questions/17668631/pl-sql-numeric-or-value-error-character-string-buffer-too-small-rowtype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!