Db2约束查询给出错误 [英] Db2 constraint query giving error

查看:561
本文介绍了Db2约束查询给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加以下约束到我的DB2表,但它给出错误。

  ALTER TABLE Table_name ADD CONSTRAINT VALID_BINDING 
CHECK((LOWER(REQ_BINDING)IN('http-post','http-redirect'))
AND((LOWER(RESP_BINDING)IN('http-post','http-redirect') ));

错误堆栈跟踪



DB21034E该命令作为SQL语句处理,因为它不是
有效的命令行处理器命令。在SQL处理期间,它返回:
SQL0104N在',
'http-redirect')))之后找到一个意外的令牌END-OF-STATEMENT。预期标记可以包括:)。 SQLSTATE = 42601

SQL0104N在','http-redirect')))之后找到一个意外的令牌END-OF-STATEMENT。预期标记可以包括:)。

说明:

在指定的
标记处检测到SQL语句或输入命令字符串中的语法错误
的SYSPROC.ADMIN_CMD过程遵循文本< text>。 < text>字段表示
SQL语句的20个字符或在无效的
令牌之前的SYSPROC.ADMIN_CMD过程的输入命令
string。

作为辅助,在SQLCA的
SQLERRM字段中提供部分有效标记列表作为< token-list>。这个列表假设
语句是正确的。

无法处理语句。


解决方案

括号错过。



ALTER TABLE Table_name ADD CONSTRAINT VALID_BINDING
CHECK((LOWER(REQ_BINDING)IN('http-post','http-redirect'))
AND((LOWER(RESP_BINDING)IN('http-post','http-redirect'))));


I am trying to add following constraint to my DB2 table but it gives error.

    ALTER TABLE Table_name ADD CONSTRAINT VALID_BINDING 
    CHECK((LOWER(REQ_BINDING) IN ('http-post','http-redirect'))
    AND ((LOWER(RESP_BINDING) IN ('http-post','http-redirect')));

Error stack trace

DB21034E  The command was processed as an SQL statement because it was not a 
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "',
'http-redirect')))".  Expected tokens may include:  ")".  SQLSTATE=42601

SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "','http-redirect')))".  Expected tokens may include:  ")                               ".

Explanation: 

A syntax error in the SQL statement or the input command string 
for the SYSPROC.ADMIN_CMD procedure was detected at the specified 
token following the text "<text>".  The "<text>" field indicates 
the 20 characters of the SQL statement or the input command 
string for the SYSPROC.ADMIN_CMD procedure that preceded the 
token that is not valid.  

 As an aid, a partial list of valid tokens is provided in the 
SQLERRM field of the SQLCA as "<token-list>".  This list assumes 
the statement is correct to that point.  

 The statement cannot be processed. 

解决方案

Parentheses missed.

ALTER TABLE Table_name ADD CONSTRAINT VALID_BINDING 
    CHECK((LOWER(REQ_BINDING) IN ('http-post','http-redirect'))
    AND ((LOWER(RESP_BINDING) IN ('http-post','http-redirect'))));

这篇关于Db2约束查询给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆