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.
编辑:我试着选择*和所有的作品。我肯定漏掉了一些东西。我只是不知道它是什么。
2 个解决方案
#1
5
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 > N的Char M中。
#2
3
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.
当我通过。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。方向= ParameterDirection.Output;oparamProjectId。大小= 100;
#1
5
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 > N的Char M中。
#2
3
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.
当我通过。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。方向= ParameterDirection.Output;oparamProjectId。大小= 100;