我試圖在SQL命令 此行運行,這是我的計劃:甲骨文 - ORA-06502:PL/SQL:數字或值錯誤:數字精度太大
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
我的問題是這樣的即使我改變輸入我得到這個錯誤:
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at line 15
所以這是我輸入 而這一點,我是想輸入,我想這個問題是距離,所以我決定改變「1」 「1.6。 你能幫我嗎?
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
讓從基礎開始:http://www.oracle.com/technetwork/issue-archive/ 2011/11-nov/o61plsql-512011.html。我建議你使用'PLS_INTEGER'或'SIMPLE_INTEGER',而不是'int'(因爲這不是plsql),或者只是普通的舊NUMBER而沒有精確性。其次,當輸入如下數字時:'distance:='&inputdistance';',您可以將它作爲距離:=&inputdistance ;,因爲它會隱式地將字符串轉換爲數字,以便插入它。從這一點開始,請參閱您可能遇到的下一個問題,但請記住,您得到的錯誤是由精度引起的。 – g00dy