警告:使用编译错误创建的函数

时间:2017-04-15 12:42:15

标签: oracle plsql

我现在有一个非常沮丧的错误。我认为由于这个错误,我还有另一个错误,在表中添加检查约束时无法引用其他列。我必须在检查约束中使用此函数来与结束时间进行比较。

  1  create or replace function timing(dat in date, bran in varchar2(30), audi in number)
  2  return number is time number
  3  begin
  4  select s_end into time from checking
  5  where s_date=dat and branch=bran and a_id = audi;
  6  return time;
  7* end timing
SQL> /

我的桌子是

 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/46 PLS-00103: Encountered the symbol "(" when expecting following: := . ) , @ % default character The symbol ":=" was substituted for "(" to continue. 
3/1 PLS-00103: Encountered the symbol "BEGIN" when expecting the following: := . ( @ % ; not null range default character 
The symbol ";" was substituted for "BEGIN" to continue. 
7/10 PLS-00103: Encountered the symbol "end-of-file" when expecting 

2 个答案:

答案 0 :(得分:2)

您以略微不同的形式发布了同样的问题。我会以稍微不同的形式回答这里。检查约束不能引用用户定义的函数。 Oracle不允许这样做,所以你的争论“必须在check约束中使用这个函数”不能!

答案 1 :(得分:0)

试试这个

int mark_sum;