oracle PL/SQL:数字或值错误:字符串缓冲区太小 %ROWTYPE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17668631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PL/SQL: numeric or value error: character string buffer too small %ROWTYPE
提问by Incognito
I don't know if I am missing something but what I am doing is:
我不知道我是否遗漏了什么,但我正在做的是:
I have a function that returns a ROWTYPE
我有一个返回 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.
编辑:我试图 SELECT * 并且一切正常。我肯定在这里遗漏了一些东西。我只是不知道它是。
采纳答案by Florin Ghita
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.
我敢打赌这个问题源于使用 Char ,它是一个固定长度的字符串。不确定在哪里,但是在代码中的某个地方,您尝试将长度为 N 的 Char 或 varchar2 字符串放入长度为 M 的字符中,其中 M > N。
回答by Biki
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 parameterwould help solving the issue.
通过我的 .Net 代码访问 Oracle SP 时出现此错误。如果有人面临这个错误,那么他/她指定输入/输出参数的大小将有助于解决问题。
Sample code goes like this :
示例代码如下:
OracleParameter oparamProjectId = mycom.Parameters.Add("p_open_flag", OracleDbType.Varchar2); oparamProjectId.Direction = ParameterDirection.Output; oparamProjectId.Size = 100;
的OracleParameter oparamProjectId = mycom.Parameters.Add( “p_open_flag”,OracleDbType。VARCHAR2); oparamProjectId.Direction = ParameterDirection.Output; oparamProjectId.Size = 100;