Je suis en train d'exécuter cette ligne dans la commande SQL Voici mon programme:oracle - ORA-06502: PL/SQL: erreur numérique ou de la valeur: nombre de précision trop grande
set verify off;
set serveroutput on;
prompt
prompt
prompt ========================================
prompt E O N MULTIPLANETARY SYSTEM
prompt ========================================
prompt
accept inputstarname prompt "Enter the name of the star: "
accept inputdistance prompt "Enter the light year distance: "
accept inputspectral prompt "Enter the spectral type: "
accept inputmass prompt "Enter the mass: "
accept inputtemp prompt "Enter the temperature(kelvin): "
accept inputage prompt "Enter the age (Giga Year): "
accept inputconplanets prompt "Enter the confirmed planets: "
accept inputunconplanets prompt "Enter the unconfirmed planets: "
accept inputconstellation prompt "Enter the name of the constellation: "
DECLARE
starname varchar2(20);
distance number(10,2);
spectral varchar2(10);
mass number(2,4);
temp int;
age number(3,5);
conplanets int;
unconplanets int;
constellation varchar(25);
BEGIN
starname:='&inputstarname';
distance:='&inputdistance';
spectral:='&inputspectral';
mass:='&inputmass';
temp:='&inputtemp';
age:='&inputage';
conplanets:='&inputconplanets';
unconplanets:='&inputunconplanets';
constellation:='&inputconstellation';
INSERT INTO eonmultiplanetarysystem (ID, STAR_NAME, DISTANCE_LY, SPECTRAL_TYPE, MASS, TEMPERATURE_K, AGE, CONFIRMED_PLANETS, UNCONFIRMED_PLANETS, CONSTELLATION) VALUES (eonmultiplanetarysystem_seq.nextval, starname, distance, spectral, mass, temp, age, conplanets, unconplanets, constellation);
commit;
dbms_output.put_line(chr(20)||'Successfully Added!');
END;
/
prompt
prompt
@c:/CS325/index
Mon problème est même je change mon entrée, je reçois cette erreur:
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at line 15
C'est donc j'entrer Et cela, je tentais d'entrer, je pensais que le problème est la distance alors j'ai décidé de changer « 1 » à «1.6. Pouvez-vous m'aider s'il vous plaît?
Enter the name of the star: Sun
Enter the light year distance: 1.6
Enter the spectral type: G2V
Enter the mass: 1
Enter the temperature(kelvin): 5778
Enter the age (Giga Year): 4.572
Enter the confirmed planets: 8
Enter the unconfirmed planets: 1
Enter the name of the constellation: None
Laissent commencer par les bases: http://www.oracle.com/technetwork/issue-archive/ 2011/11-nov/o61plsql-512011.html. Je vous suggère d'utiliser 'PLS_INTEGER' ou' SIMPLE_INTEGER', au lieu de 'int' (puisque ce n'est pas plsql), ou tout simplement vieux NUMBER sans précision. Deuxièmement, lorsque vous entrez des nombres comme ça: 'distance: = '& inputdistance';', vous pouvez le laisser comme distance: = & inputdistance;, car il convertira implicitement la chaîne en nombre, afin de l'insérer. À partir de là, voyez les problèmes que vous pourriez avoir, mais gardez à l'esprit que l'erreur que vous avez rencontrée est due à la précision. – g00dy