R
R
Raushka2021-04-24 11:15:22
Oracle
Raushka, 2021-04-24 11:15:22

Why doesn't a function returning data from a table work (PL/SQL: numeric or value error: character string buffer too small)?

Hello! Please help me understand this situation:
In general, a package is written with a function that returns data from a table:

1. Package specification:

CREATE OR REPLACE PACKAGE z_026_TEST_blk AS
TYPE MEASURE_RECORD IS RECORD(l_CODE varchar(10), T_ID number, T_CODE varchar(10), T_NAME varchar(10), B_NFIRE   number, B_LONGNAME  varchar(10),  B_EXEC_COND varchar(10));
TYPE z_026_blkoper IS TABLE OF MEASURE_RECORD;
FUNCTION GET_blk(l_operblk varchar2) RETURN z_026_blkoper
PIPELINED;
END z_026_TEST_blk;


2. Package body
CREATE OR REPLACE PACKAGE BODY z_026_TEST_blk AS
FUNCTION GET_blk(l_operblk varchar2) RETURN z_026_blkoper PIPELINED IS
rec measure_record;
BEGIN
select S.CODE, T.ID, T.CODE, T.NAME, B.NFIRE, B.LONGNAME, B.EXEC_COND
COLLECT INTO rec
from SCEN T, SC_BLK B, BDSCR S
WHERE T.ID = B.ID
AND T.NORD = B.NORD
AND T.ID = S.ID
AND t.ARCFL = '0'
AND s.CODE = l_operblk
ORDER BY T.NAME, B.NFIRE;
RETURN;
END GET_blk;
END z_026_TEST_blk;


Running a query with a function:
SELECT z_026_TEST_blk.GET_blk('ACC_GL') FROM DUAL
SELECT *  FROM table(z_026_TEST_blk.GET_blk('ACC_GL'));


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

I suppose swears at the sample. Who can tell what could be the problem, where I need to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dmitriev, 2021-04-29
@Raushka

Well, it looks like the field in the record is not enough to receive the value passed to it. And it seems that there is a transfer of a non-string value to a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question