我需要一些帮助。这是我第一次在这里寻求帮助,所以请原谅我的英语不好。我很生气,因为我不知道如何解决这个错误。我在Oracle 10g
. 输出是:
Function created.
No errors.
Function created.
Enter value for v_numes: 'SECTIA1' --SECTIA1 is the name of section(department) from sectii table
Sectia exista in baza de date SECTIA1
Numele sectiei este: SECTIA1 --the name of the department(v_numes)
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "SYSTEM.FUNCTION0", line18
ORA-01403: no data found
ORA-06512: at line 17
这是我的代码:
set serveroutput on
set verify off
CREATE OR REPLACE FUNCTION function0(p_section_name VARCHAR) RETURN NUMBER IS
v_procent1 CONSTANT REAL:=0.01;
v_cods sectii.cods%TYPE;--the table is named sectii, which means sections
v_ok1 NUMBER:=1;
BEGIN
DBMS_OUTPUT.PUT_LINE('Numele sectiei este: '||p_section_name);
SELECT cods
INTO v_cods
FROM sectii
WHERE den=UPPER(p_section_name);
DBMS_OUTPUT.PUT_LINE('Codul sectiei pentru '||p_section_name||' este '||v_cods);
RETURN (v_ok1);
EXCEPTION
WHEN TOO_MANY_ROWS THEN
RETURN 'Prea multe sectii cu acest nume.';
WHEN NO_DATA_FOUND THEN
RETURN 'Nici o sectie cu acest nume.';
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20011,'Unknown Exception in function0');
END function0;
/
show errors;
/
DECLARE
v_numes VARCHAR2(255);
v_numesu VARCHAR2(255);
v_numesl VARCHAR2(255);
v_boool NUMBER:=1;
e_invalid_section EXCEPTION;
BEGIN
v_numes:=&v_numes;
IF SQL%NOTFOUND THEN
RAISE e_invalid_section;
ELSE
DBMS_OUTPUT.PUT_LINE('Sectia exista in baza de date '|| v_numes);
END IF;
v_numesu:=UPPER(v_numes);
v_numesl:=LOWER(v_numes);
IF v_numes=v_numesl OR v_numes=v_numesu THEN
DBMS_OUTPUT.PUT_LINE('FUNCTION0 '||function0(v_numes));
END IF;
--v_numes:=TO_CHAR(v_numes);
--DBMS_OUTPUT.PUT_LINE('RETURN FUNCTIE0: '||v_boool);
EXCEPTION
WHEN e_invalid_section THEN --exceptie definita de utilizator
DBMS_OUTPUT.PUT_LINE('Nu exista aceasta sectie in tabelul sectii.');
END;
/