2016-09-14 44 views
2

我想使用附加条件来更新事件表(RDBMS),即其中的一列不为空。表名是MSISDNProfileDB,它在oracle数据库中。使用wso2 CEP处理空值

from incomingStream#window.length(1) 
select correlation_MSISDN as MSISDN, 
     INTERACTION_DT as INTERACTION_DT 
update MSISDNProfileDB 
on MSISDNProfileDB.MSISDN == MSISDN 
and not(MSISDNProfileDB.column1 is null); 

它验证代码,但不更新INTERACTION_DT。出于测试目的,我将其更改为检查列是否为空,并手动从column1中删除数据。

from incomingStream#window.length(1) 
select correlation_MSISDN as MSISDN, 
     INTERACTION_DT as INTERACTION_DT 
update MSISDNProfileDB 
on MSISDNProfileDB.MSISDN == MSISDN 
and MSISDNProfileDB.column1 is null; 

...它仍然无法正常工作。但是,当我将列值更改为1并执行此操作时:

from incomingStream#window.length(1) 
select correlation_MSISDN as MSISDN, 
     INTERACTION_DT as INTERACTION_DT 
update MSISDNProfileDB 
on MSISDNProfileDB.MSISDN == MSISDN 
and MSISDNProfileDB.column1 == '1'; 

它的工作原理!所以,结论是cep与oracle db的空值有问题。有谁知道如何处理空值?

亲切的问候, 斯特凡

+0

嗨,你得到类似'org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException任何异常:错误同时更新数据库事件,您的SQL语法错误; ... ',当你发送一个事件? – Grainier

+0

嗨Granier,当我尝试使用此行更新...和MSISDNProfileDB.column1为空...在碳日志中有错误:“由...引起:java.sql.SQLSyntaxErrorException:ORA-00936:缺少表达式” – StStojanovic

回答

1

我碰到类似的问题就来了与MySQL。这个问题似乎是CEP将Siddhi查询解析为SQL的方式。我为此做了一个快速的fix,并且适用于我的场景。它应该也适用于你的情况,但还没有通过Oracle测试过。使用修复程序(假设您使用的是CEP 4.2.0);

  1. 删除siddhi-extension-event-table_3.1.2.jar<cep>/repository/components/plugins/目录。

  2. compiled jar添加到<cep>/repository/components/lib/的模具。

  3. 使用以下查询;

    from incomingStream 
    select 
        correlation_MSISDN as MSISDN, 
        INTERACTION_DT as INTERACTION_DT 
    update MSISDNProfileDB 
    on MSISDNProfileDB.MSISDN == MSISDN and not (MSISDNProfileDB.column1 is null); 
    
+0

感谢你Grainier为你的支持!我正在使用CEP 4.1.0,我还可以在4.1.0版本上编译这个jar吗? – StStojanovic

+0

CEP 4.2.0使用Siddhi 3.1.2,CEP 4.1.0使用Siddhi 3.0.5。因此,您可能需要将更改应用到[v3.0.5 tag](https://github.com/wso2/siddhi/tree/v3.0.5)。这是[v3.0.5的补丁版](https://mega.nz/#!Qx8zRbTD!-_JySYc0KHT-pmRWGy31GX0rbF_hHIjv-eAs_SLwloE)。试试看看。 – Grainier

+0

现在一切正常。非常感谢你!亲切的问候,斯蒂芬 – StStojanovic