error [message #597711] |
Mon, 07 October 2013 14:10 |
|
nataliafoster26
Messages: 64 Registered: October 2013
|
Member |
|
|
I have this query
FUNCTION RENDER_SEG_AVAIL_DD(
PvProperty P_PM_PROPERTY.PROPERTY_ID%TYPE,
pvUnitTypeID P_PM_UNIT_TYPE.PM_UNIT_TYPE_ID%TYPE,
pvName VARCHAR2,
pvAttrib VARCHAR2,
pvUsageDate DATE,
pvDefaultSeg VARCHAR2 --15388 Hybrid 1.1 - Added parameter to support default segment logic
)
RETURN VARCHAR2
IS
TYPE SegRec IS RECORD
(
DDValue VARCHAR2(50),
DDDesc VARCHAR2(50)
);
TYPE SegTabType IS TABLE OF SegRec;
vSegData SegTabType;
vIndex INTEGER;
vRecs INTEGER;
vRetval VARCHAR2(30000);
vUnallCount INTEGER;
vUnallOpt VARCHAR(100) := '';
BEGIN
vUnallCount := AVAILABLE.GET_UNALLOCATED_COUNT(pvUnitTypeID,pvUsageDate);
IF vUnallCount > 0 THEN
vUnallOpt := '<option value="---" SELECTED>Unallocated / '||TO_CHAR(vUnallCount)||'</option>'||CHR(10);
END IF;
SELECT Main.SEGMENT_CODE,Main.DDDesc
BULK COLLECT INTO vSegData
FROM
(
SELECT cc.SEGMENT_CODE,cc.SEGMENT_CODE || ' - ' ||s.SEGMENT_DESC||' / ' || TO_CHAR(ALLOCATION-UNITS_RESERVED) || ' Avail' DDDesc
FROM P_PM_CONTROL_COUNT cc,
P_PM_SEGMENT s,
S_PM_PROP_SEG ps
WHERE cc.SEGMENT_CODE = s.SEGMENT_CODE
AND s.SEGMENT_CODE = ps.SEGMENT_CODE
AND ps.PROPERTY_ID = PvProperty
AND s.SEGMENT_ACTIVE = 'Y'
AND cc.PM_UNIT_TYPE_ID = pvUnitTypeID
AND cc.Usage_Date = pvUsageDate
AND cc.ALLOCATION-cc.UNITS_RESERVED > 0
AND cc.SEGMENT_CODE IN
this is the log error i got
MODPLSQL-00261: mod_plsql: /auslive/unit_maint_pkg.maint_results
HTTP-404 Failed to execute target procedure ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated
Bind\nORA-06512: at "ATLAS.UNIT_MAINT_PKG", line 1652\nORA-06512: at "ATLAS.UNIT_MAINT_PKG", line 1037\nORA-06512:
at "ATLAS.UNIT_MAINT_PKG", line 366\nORA-06512: at "ATLAS.UNIT_MAINT_PKG", line 2048\nORA-06512: at line 33\n,
has you can see i get error on line 1652 which is this line
SELECT cc.SEGMENT_CODE,cc.SEGMENT_CODE || ' - ' ||s.SEGMENT_DESC||' / ' || TO_CHAR(ALLOCATION-UNITS_RESERVED) || ' Avail' DDDesc
due with truncated bind
this is a old error i got, with some specific data, Now when i run it with the same data, it actually works, even when DDDesc goes beyond 50 char it still works example:
DDDesc ="IEX - Internal Exchange-ow trading datess / 10000000 Avail" which is 58 in length
from what i have been reading online in about the error "truncated bind"
like from this article Jared Still's Ramblings: ORA-6502 "Bulk Bind: Truncated Bind" error
it can just be changing the lenght of dddesc which from what i can conclude its 50 right now , so its not even bothering about it right now, it doesnt care is 50 its by passing it
When i run this query
declare
TYPE SegRec IS RECORD
(
DDValue VARCHAR2(50),
DDDesc VARCHAR2(50)
);
TYPE SegTabType IS TABLE OF SegRec;
vSegData SegTabType;
BEGIN
SELECT Main.SEGMENT_CODE,Main.DDDesc
BULK COLLECT INTO vSegData
FROM
(
SELECT 'IEX' SEGMENT_CODE,'IEX - InternalHHHHHHH/ 10000000 Avail' DDDesc
FROM DUAL
) Main;
END;
/
i will get no error, but lets say SELECT 'IEX' SEGMENT_CODE,'IEX - InternalHHHHHHHHHHHHHHHHHHHHH/ 10000000 Avail' DDDesc
the length is bigger than 50 it will give me a error on
ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind
ORA-06512: at line 13
any tips will help thanks
|
|
|
|
|
|
|
Re: error [message #597830 is a reply to message #597828] |
Tue, 08 October 2013 11:03 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
As far as we can tell the problem is that you are trying to put a value that's greater than 50 chars in length in a VARCHAR2(50).
So you either need to make the variable bigger, or substr the data you're trying to put in it to 50 chars.
Why do you think the problem is something else?
|
|
|
Re: error [message #597832 is a reply to message #597830] |
Tue, 08 October 2013 11:15 |
|
nataliafoster26
Messages: 64 Registered: October 2013
|
Member |
|
|
i think is something else because right now i dont even get a error, i dont get the truncate error anymore, and i didnt change anything
code looks the same. when i run this query
SELECT cc.SEGMENT_CODE,cc.SEGMENT_CODE || ' - ' ||s.SEGMENT_DESC||' / ' || TO_CHAR(ALLOCATION-UNITS_RESERVED) || ' Avail' DDDesc
FROM P_PM_CONTROL_COUNT cc,
P_PM_SEGMENT s,
S_PM_PROP_SEG ps
WHERE cc.SEGMENT_CODE = s.SEGMENT_CODE
AND s.SEGMENT_CODE = ps.SEGMENT_CODE
AND ps.PROPERTY_ID =:PvProperty
AND s.SEGMENT_ACTIVE = 'Y'
AND cc.PM_UNIT_TYPE_ID =:pvUnitTypeID
AND cc.Usage_Date =:pvUsageDate
AND cc.ALLOCATION-cc.UNITS_RESERVED > 0
it works, even when a length of DDDesc is greater than 50 for example
IEX - Internal Exchange-ow trading datess / 10000000 Avail (which is 58 in length)
from my conclusion , i may be wrong it should not work, but i am new to this
[Updated on: Tue, 08 October 2013 11:16] Report message to a moderator
|
|
|
Re: error [message #597833 is a reply to message #597832] |
Tue, 08 October 2013 11:18 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Are you fetching the results of that query into a variable that is varchar2(50)?
if not, then it'll work, otherwise it must fail. You can't put 58 chars in a varchar2(50).
|
|
|
|
Re: error [message #597835 is a reply to message #597834] |
Tue, 08 October 2013 11:25 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Define works. Is there data of length 58 in the array variable?
Or is the problem data not in the array? In which case are you really sure it matches the where clause?
|
|
|
|
Re: error [message #597837 is a reply to message #597836] |
Tue, 08 October 2013 11:33 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Either you've encountered a rather strange oracle bug or you're not checking what you think you're checking.
How exactly are you checking the contents of the array variable?
And what exact version of oracle are you using?
|
|
|
|
|
Re: error [message #597840 is a reply to message #597839] |
Tue, 08 October 2013 11:58 |
|
nataliafoster26
Messages: 64 Registered: October 2013
|
Member |
|
|
maybe i should run this query but i can get it to work
declare
TYPE SegRec IS RECORD
(
DDValue VARCHAR2(50),
DDDesc VARCHAR2(50)
);
TYPE SegTabType IS TABLE OF SegRec;
vSegData SegTabType;
BEGIN
SELECT Main.SEGMENT_CODE,Main.DDDesc
BULK COLLECT INTO vSegData
FROM
(
SELECT cc.SEGMENT_CODE,cc.SEGMENT_CODE || ' - ' ||s.SEGMENT_DESC||' / ' || TO_CHAR(ALLOCATION-UNITS_RESERVED) || ' Avail' DDDesc
FROM P_PM_CONTROL_COUNT cc,
P_PM_SEGMENT s,
S_PM_PROP_SEG ps
WHERE cc.SEGMENT_CODE = s.SEGMENT_CODE
AND s.SEGMENT_CODE = ps.SEGMENT_CODE
AND ps.PROPERTY_ID =:PvProperty
AND s.SEGMENT_ACTIVE = 'Y'
AND cc.PM_UNIT_TYPE_ID =:pvUnitTypeID
AND cc.Usage_Date =:pvUsageDate
AND cc.ALLOCATION-cc.UNITS_RESERVED > 0
FROM dual
) Main;
END;
/
gives me error on line 28
[Error] Execution (28: 9): ORA-06550: line 28, column 9:
PL/SQL: ORA-00907: missing right parenthesis
ORA-06550: line 13, column 5:
PL/SQL: SQL Statement ignored
[Updated on: Tue, 08 October 2013 12:02] Report message to a moderator
|
|
|
|
|
|
|
Re: error [message #597847 is a reply to message #597844] |
Tue, 08 October 2013 13:12 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
Ok, do one thing. Open a SQL*Plus session, copy paste what exactly you are doing alongwith the error message you get. Do include the case when the DDDesc length is > 50 characters length.
|
|
|
|
|
Re: error [message #597859 is a reply to message #597838] |
Tue, 08 October 2013 17:39 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
nataliafoster26 wrote on Tue, 08 October 2013 17:48version 12.0.0.61, i use toad for oracle
as you can see if from FUNCTION RENDER_SEG_AVAIL_DD(
If i run this query
SELECT cc.SEGMENT_CODE,cc.SEGMENT_CODE || ' - ' ||s.SEGMENT_DESC||' / ' || TO_CHAR(ALLOCATION-UNITS_RESERVED) || ' Avail' DDDesc
FROM P_PM_CONTROL_COUNT cc,
P_PM_SEGMENT s,
S_PM_PROP_SEG ps
WHERE cc.SEGMENT_CODE = s.SEGMENT_CODE
AND s.SEGMENT_CODE = ps.SEGMENT_CODE
AND ps.PROPERTY_ID =:PvProperty
AND s.SEGMENT_ACTIVE = 'Y'
AND cc.PM_UNIT_TYPE_ID =:pvUnitTypeID
AND cc.Usage_Date =:pvUsageDate
AND cc.ALLOCATION-cc.UNITS_RESERVED > 0
a result that is bigger than 50 in length come on, maybe when i run this query alone i should say DDDesc should be varchar2(50) but i dont know if that would be a issue
Are you saying you ran that query exactly as is in toad? with no into clause?
Because toad doesn't care how long the data is.
I asked how you are checking the contents of the array variable.
Running the above in toad does not check the contents of the variable, it doesn't even use the variable.
|
|
|
|
|
Re: error [message #597865 is a reply to message #597860] |
Wed, 09 October 2013 00:00 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
nataliafoster26 wrote on Wed, 09 October 2013 05:05im actually trying out this one, which i dont get any erros, but right now im trying to get a output
DBMS_OUTPUT.PUT_LINE, but every thing i try doesn't work
Ok, I have a small demo of your code.
1. I declare the placeholder size for DDDESC as VARCHAR2(50). So, I expect numeric or value error.
SQL> set serveroutput on;
SQL>
SQL> DECLARE
2 TYPE SEGREC IS RECORD(
3 DDVALUE VARCHAR2(50),
4 DDDESC VARCHAR2(50));
5
6 TYPE SEGTABTYPE IS TABLE OF SEGREC;
7
8 VSEGDATA SEGTABTYPE;
9
10 BEGIN
11 SELECT MAIN.SEGMENT_CODE, MAIN.DDDESC BULK COLLECT
12 INTO VSEGDATA
13 FROM (WITH DATA AS (SELECT 'IEX' SEGMENT_CODE,
14 'IEX - Internal Exchange-ow trading datess / 10000000 Avail' SEGMENT_DESC
15 FROM DUAL)
16 SELECT SEGMENT_CODE, SEGMENT_DESC DDDESC FROM DATA) MAIN;
17
18
19 DBMS_OUTPUT.PUT_LINE(VSEGDATA(1).DDVALUE || ' , ' || VSEGDATA(1).DDDESC);
20 END;
21 /
ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind
ORA-06512: at line 12
2. Now I increase the size to VARCHAR2(60). I expect it to return an output.
SQL> DECLARE
2 TYPE SEGREC IS RECORD(
3 DDVALUE VARCHAR2(50),
4 DDDESC VARCHAR2(60));
5
6 TYPE SEGTABTYPE IS TABLE OF SEGREC;
7
8 VSEGDATA SEGTABTYPE;
9
10 BEGIN
11 SELECT MAIN.SEGMENT_CODE, MAIN.DDDESC BULK COLLECT
12 INTO VSEGDATA
13 FROM (WITH DATA AS (SELECT 'IEX' SEGMENT_CODE,
14 'IEX - Internal Exchange-ow trading datess / 10000000 Avail' SEGMENT_DESC
15 FROM DUAL)
16 SELECT SEGMENT_CODE, SEGMENT_DESC DDDESC FROM DATA) MAIN;
17
18
19 DBMS_OUTPUT.PUT_LINE(VSEGDATA(1).DDVALUE || ' , ' || VSEGDATA(1).DDDESC);
20 END;
21 /
IEX , IEX - Internal Exchange-ow trading datess / 10000000 Avail
PL/SQL procedure successfully completed
3. Or else, with the size as VARCHAR2(50), I use a SUBSTR.
SQL> DECLARE
2 TYPE SEGREC IS RECORD(
3 DDVALUE VARCHAR2(50),
4 DDDESC VARCHAR2(50));
5
6 TYPE SEGTABTYPE IS TABLE OF SEGREC;
7
8 VSEGDATA SEGTABTYPE;
9
10 BEGIN
11 SELECT MAIN.SEGMENT_CODE, SUBSTR(MAIN.DDDESC, 1, 50) BULK COLLECT
12 INTO VSEGDATA
13 FROM (WITH DATA AS (SELECT 'IEX' SEGMENT_CODE,
14 'IEX - Internal Exchange-ow trading datess / 10000000 Avail' SEGMENT_DESC
15 FROM DUAL)
16 SELECT SEGMENT_CODE, SEGMENT_DESC DDDESC FROM DATA) MAIN;
17
18
19 DBMS_OUTPUT.PUT_LINE(VSEGDATA(1).DDVALUE || ' , ' || VSEGDATA(1).DDDESC);
20 END;
21 /
IEX , IEX - Internal Exchange-ow trading datess / 100000
PL/SQL procedure successfully completed
So, this proves the issue is with the size that you declare for DDDESC.
If you say it has to do any thing with the tool(TOAD), well I don't think so. I don't have TOAD, but I did the same thing in PL/SQL Developer, and it bahaved like SQL*Plus. If the problem is strictly due to any bind variable, then I am not sure if there are any variances due to tool.
Regards,
Lalit
[Updated on: Wed, 09 October 2013 00:06] Report message to a moderator
|
|
|
Re: error [message #597869 is a reply to message #597860] |
Wed, 09 October 2013 00:24 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Hi, you have posted code that doesn't really relate to your problem. Your issue is that you have tried dbms_output but 'it doesn't work'. Problem is, you haven't shown us how you have used dbms_output.
DECLARE
var VARCHAR2(10):= 'Data';
BEGIN
--do some stuff
dbms_output.put_line(var);
--do some other stuff
END;
/
|
|
|
|
Re: error [message #598029 is a reply to message #598026] |
Wed, 09 October 2013 16:54 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Hi Natalia, people have spent a lot of their own time for free, trying to help you. A common courtesy would be for you to show us how you solved your issue. (It may also help other people who may search for similar issues that you have had. It is very unlikely that it is actually too long to explain (you can fit a lot of text into these posts
Cheers.
|
|
|