如何选择仅显示不相等的数据结果,而只显示负数或盲目的相等数据结果?

时间:2019-01-08 11:08:23

标签: robotframework

这是我的机器人代码

两个表上都有22条记录,但是只有1条记录具有不相等的数据,我想显示该结果,并减去或盲目相等的数据结果。

 connect to database using custom params  cx_Oracle    ${DB_CONNECT_STRING}
 @{queryResultsA}=   Query  Select count (*) from QA_USER.SealTest_Security_A order by SECURITY_ID
 Log  ${queryResultsA}
 @{queryResultsB}=   Query  Select count (*) from QA_USER.SealTest_Security_B order by SECURITY_ID
 Log  ${queryResultsB}

should not contain match    ${queryResultsB}  ${queryResultsA}

1 个答案:

答案 0 :(得分:2)

  1. 使用循环

     # Assuming your table has values like this
    @{queryResultsA}=   Create List     a   b   c   d   e
    @{queryResultsB}=   Create List     a   z   c   d   e
    
    ${Length}=  Get Length      ${queryResultsA}
    ${count}=   Set Variable
    
    :FOR     ${count}   IN RANGE     ${Length}      
    \       Run Keyword If  '@{queryResultsA}[${count}]'!='@{queryResultsB}[${count}]'      Log To Console      @{queryResultsA}[${count}] @{queryResultsB}[${count}]
    

    输出
    b z

  2. 使用SET

    ${z} =  Evaluate    (set(${queryResultsA}) - set(${queryResultsB}))
    Log     ${z}
    

    输出
    b

    请注意,这里从集合A中减去了集合B的差异,所以在集合A中不匹配的内容将作为输出。