oracle - ORA-06502: PL/SQL: numeric or value error: number precision too large
oracle - ORA-06502: PL/SQL: numeric or value error: number precision too large
我正在尝试 运行 在 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
age number(3,5)
抛出错误。
这不能容纳 4.572
要持有 4.572,您必须将声明更改为 number(5,3)。这意味着该数字将在句点之前有 2 位数字,在句点之后有 3 位数字。
问题出在具有小数精度的 NUMBER
数据类型上。
在NUMBER数据类型中,第一个Number表示小数点两边的总位数,第二个表示小数点后的位数。
例如:要保存 34.34434
的值,数据类型应为 NUMBER(7,5)
谢谢:)
我正在尝试 运行 在 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
age number(3,5)
抛出错误。
这不能容纳 4.572 要持有 4.572,您必须将声明更改为 number(5,3)。这意味着该数字将在句点之前有 2 位数字,在句点之后有 3 位数字。
问题出在具有小数精度的 NUMBER
数据类型上。
在NUMBER数据类型中,第一个Number表示小数点两边的总位数,第二个表示小数点后的位数。
例如:要保存 34.34434
的值,数据类型应为 NUMBER(7,5)
谢谢:)