Sql oracle错误:没有足够的值

Sql oracle错误:没有足够的值,sql,oracle,Sql,Oracle,我有一张桌子,你的主人: create table donor_master ( donor_id number(10) primary key not null, dob date not null, age number(3) not null, gender char(1) not null, blood_group char(3), contact_no number(10), address varchar(50) not null, city va

我有一张桌子,你的主人:

create table donor_master  
(  
donor_id number(10) primary key not null,  
dob date not null,  
age number(3) not null,  
gender char(1) not null,  
blood_group char(3),  
contact_no number(10),  
address varchar(50) not null,  
city varchar(10) not null,  
pin number(10) not null,  
state varchar(10) not null,  
branch_registration_id number(5) references branch_master(branch_id)  
);  
当我尝试在过程insert\u PRODUCTOR\u master中插入到表中时,在编译时出现“值不足”错误

程序如下:

create or replace procedure insert_donor_master(  
vdob donor_master.dob%type,  
vage donor_master.age%type,  
vgender donor_master.gender%type,  
vblood_group donor_master.blood_group%type,  
vcontact_no donor_master.contact_no%type,  
vaddress donor_master.address%type,  
vcity donor_master.city%type,  
vpin donor_master.pin%type,  
vstate donor_master.state%type,  
vbranch_registration_id donor_master.branch_registration_id%type  
)  
is  

begin  

    insert into donor_master values (sq_donor_master.nextval, vdob, vage, vgender, vblood_group, vcontact_no, vaddress, vcity, vpin, vstate, vbranch_registration_id);  
    commit;  

end;
有什么问题


谢谢。

当我们指定INSERT语句时,Oracle会抛出ORA-00947,该语句没有为表中的每一列指定值

现在,您发布的CREATETABLE语句显示了一个包含11列的表。您发布的存储过程代码显示了一个insert语句,在values(…)子句中有11个值

因此,解释如下:

  • 存在配置管理问题,并且运行的存储过程版本或表版本错误
  • 您有一个配置管理问题,表的实际结构与您认为的不同(与创建表脚本不匹配)
  • 您并没有真正收到ORA-00947错误
  • 请注意,如果不想填充每一行,可以在VALUES子句之前指定相关列的投影。例如,如果您只想填充必填列,您可以编写以下代码:

    insert into  donor_master 
        (donor_id, dob, age, gender, address, city, pin, state )
       values (sq_donor_master.nextval, vdob, vage, vgender, vaddress, vcity, vpin, vstate) 
    
    重要的是,值的数量与列的数量匹配


    INSERT语句的完整语法在文档中。了解更多信息。

    在您的创建或替换过程中,您没有提到捐赠者id??是的,因为我刚才正在使用序列插入捐赠者id,所以我尝试在上面的insert语句中提及“values”之前的列名,令我惊讶的是,它被编译了。但是当我删除列名列表时,它又出现了错误。@Neal:然后检查表的实际结构。@Mat:你说得对,Mat,实际的表结构还有一列。应该始终信任“desc”,而不是创建表代码。我猜有人添加了一列,但没有更改CREATETABLE语句。我不能接受评论作为回答,那么我该怎么办?@Neal-正如我在回答中所建议的,这是一个配置管理问题:实际的表结构与您发布的代码版本不匹配。所以请接受我的回答:)