ORA-00904:“TIMING”:标识符无效

时间:2017-04-15 20:52:14

标签: sql oracle plsql oracle11g

我创建了以下函数名称时间:

create or replace function timing
    ( dat in date, bran in varchar2, audi in number )
    return number
as
    time number;
begin
    select s_end into time
    from   checking
    where  s_date = dat
    and    branch = bran
    and    a_id = audi;

    return time;
end;
/

Function created.

但是在使用此函数添加检查约束时,我有以下错误:

alter table checking add constraint chk check(s_start>timing(s_date,branch,a_id))
                                                      *
ERROR at line 1:
ORA-00904: "TIMING": invalid identifier

我的表格如下:

SQL> desc checking
 Name                                      Null?    Type
 ----------------------------------------- -------- -------------
 S_ID                                      NOT NULL NUMBER
 M_ID                                               NUMBER
 A_ID                                               NUMBER
 S_DATE                                             DATE
 S_START                                            NUMBER
 S_END                                              NUMBER
 BRANCH                                             VARCHAR2(30)

1 个答案:

答案 0 :(得分:1)

检查约束不能引用用户定义的函数。请参阅Oracle SQL Reference手册,然后执行浏览器查找"检查约束条件限制"。

但是您应该能够修改原始查询和函数以添加/包含函数作为谓词或预检查。