I'm working on a procedure to take rows from a table and change the names slightly to make 50 rows total... as you'll see in code.
However, I'm having an issue
a numeric or value error, as you'll see in code I try using
dbms_output.put_line('some message');
but my output doesn't want to work so finding the issue is becoming troublesome.
an error says
"PL/SQL: numeric or value error"
*Cause: An arithmetic, numeric, string, conversion, or constraint error
occurred. For example, this error occurs if an attempt is made to
assign the value NULL to a variable declared NOT NULL, or if an
attempt is made to assign an integer larger than 99 to a variable
declared NUMBER(2).
*Action: Change the data, how it is manipulated, or how it is declared so
that values do not violate constraints.
If anyone can point me in the right direction (or even how to get dbms to work) it would be greatly appreciated
(I have opened dbms and connected to server and set serverouput on;)
Code:
create or replace procedure bbt_phone_users (n in number) authid current_user
as
cursor r10 is select firstname, lastname, password_ from bbt_users_temp;
r10type r10%rowtype;
fn bbt_users_temp.firstname%type;
ln bbt_users_temp.lastname%type;
pass bbt_users_temp.password_%type;
tel varchar2(15);
keymap_ln varchar(4);
phone_end number(4);
name_end number;
begin
phone_end := 1000;
dbms_output.put_line('hey');
for i in 1 .. n
loop
open r10;
fetch r10 into fn, ln, pass;
close r10;
for oneRow in r10
loop
name_end := name_end + 1;
dbms_output.put_line('works pre-1');
--1
-- each row gets the phone_end, which increments on each iteration
phone_end := phone_end + 1;
tel := '(317) 456-' || to_char(phone_end);
dbms_output.put_line('works after 1');
--2
-- takes the last name, and adds 000 and some number if its less than 10 OR
-- adds (concatinates) 00 and the numbers if its > 10
if name_end < 10 then
ln := ln || '000' || to_char(phone_end, '9');
else
ln := ln || '00' || to_char(phone_end, '99');
end if;
dbms_output.put_line('works after 2');
--3
-- calls the KEYMAP function and passes it the lastname
keymap_ln := KEYMAP(ln);
dbms_output.put_line('works after 3');
--4
-- inserts all our values
insert into phone_users values(tel, fn, ln, keymap_ln, pass);
--5
--rest are ignored since we don't do anything with them
end loop;
end loop;
end;
/
call bbt_phone_users(10);
select * from phone_users;