Question : Oracle cursor loop gives error ora-06502

The following code works for small amounts of data
but gives this error with alot of data..

BEGIN
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 68
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
...
declare
v_body clob;
cursor c is
 select * from tables;
...
---- START OF TABLE
v_body := v_body||'<table border="1" cellspacing="1" cellpadding="1">';

--headers
v_body:= v_body||'<tr>'||
'<td width="150">PO ID#</td>'||
'<td width="100">Vendor ID#</td>'||
'<td width="80">Vendor Loc#</td>'||
'<td width="80">Project#</td>'||
'<td width="95">Activity#</td>'||
'<td width="75">PO Line#</td>'||
'</tr>';

for v in c loop       --(this is where the error occurs)

v_body:= v_body||'<tr>'||
'<td>'||v.po_id||'</td>'||
'<td>'||v.ps_vendor_id||'</td>'||
'<td>'||v.ps_vendor_loc||'</td>'||
'<td>'||v.project_id||'</td>'||
'<td>'||v.activity_id||'</td>'||
'<td>'||v.po_line_no||'</td>'||
'</tr>';

end loop;
v_body := v_body||'</table>';
---- END OF TABLE
  
v_body := v_body||'</BODY></HTML>';

Answer : Oracle cursor loop gives error ora-06502

sorry I didn't notice this before...
one or more of the columns you are appending is not a string type

try wrapping them in to_char

'<td>'|| to_char(v.po_line_no) ||'</td>'||
Random Solutions  
 
programming4us programming4us