【问题标题】:ORA-00936: missing expression error when inserting valuesORA-00936: 插入值时缺少表达式错误
【发布时间】:2015-10-22 13:45:06
【问题描述】:

我花了很多时间搜索我出错的地方,但是当它要插入最后一条记录时我找不到它有一条错误消息显示“ORA-00936:缺少表达式”如何解决这个问题请帮助我

create type pearson_types as object(
name varchar2(50),
sysID char(6)
)NOT FINAL;

create type doctor_types under pearson_types(
regNo char(10),
specialization varchar2(25)
)

create table doctor of doctor_types(
regNo primary key 
)

create type hospVisits_types as object(
hosChg float,
vDate varchar2(20),
refDoc REF doctor_types,
docChg float
)

create type hospvisits_tbl_types as table of hospVisits_types

create type phone_arr as VARRAY(3) of char(10)

create type patient_types under pearson_types
(
id char(10),
dob varchar(20),
phone phone_arr,
hospVisits hospvisits_tbl_types
)

create table patients of patient_types(
id primary key
)nested table hospVisits store as Hospital_tables

alter table Hospital_tables add scope for (refDoc) is doctor

insert into doctor values ('Dr.k.perera','D001','1223441234','Gynecologist');
insert into doctor values ('Dr.p.weerasingha','D002','1234421131','Dermatalogist');
insert into doctor values ('Prof .S. Fernando','D003','2342111322','Pediatrician');
insert into doctor values ('Dr.k.Sathgunanathan','D004','2344114344','Pediatrician');


insert into patients values('Sampath Weerasingha','P001','732821122V','23-JAN-73',phone_arr('0332124222'),hospvisits_tbl_types(hospVisits_types(50.00,'24-MAY-06',select ref (a) from doctor a where a.regNo='1223441234',500.00)))

【问题讨论】:

    标签: sql oracle oracle11g sqlplus


    【解决方案1】:

    为 SQL 语句中的 SELECT 语句添加括号:

    insert into patients values(
        'Sampath Weerasingha','P001','732821122V','23-JAN-73',phone_arr('0332124222'),
        hospvisits_tbl_types(hospVisits_types(50.00,'24-MAY-06',
            ( -- ADD ME
                select ref (a) from doctor a where a.regNo='1223441234'
            ) -- ADD ME
        ,500.00))
    );
    

    【讨论】:

    • 非常感谢 Jon Heller 不幸的是,我没有足够的声誉来支持您的回答,对此感到抱歉..:/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 2018-08-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多