本文介绍了JMeter-将多个值从1个JDBC传递到另一个JDBC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:JMeter v2.11,Oracle 12,JDK 7

Environment: JMeter v2.11, Oracle 12, JDK 7

我需要将2个值从一个JDBC Request采样器传递给另一个.尽管我可以看到两个值都已成功传递,但我已经关注了先前的帖子和Jmeter帮助,但是第二个JDBC Request采样器查询并未使用第二个变量值.

I need to pass 2 values from one JDBC Request sampler to another. I've followed previous posts and the Jmeter help but the second variable value is not being used by the 2nd JDBC Request samplers query, despite the fact that I can see both values are successfully passed.

我的工作如下:

Thread Group: Number of Users-->1, Loop Count-->1
-JDBC Request_1: select appid from (select appid from tableZ order by appid desc) where rownum<= 2;    
VariableName: appid

JDBC Request_2: select A.date, B.appid, A.status from tableA A
inner join TableB on A.id = B.id
where A.status in ('Start', 'End')
and B.appid in (?,?); 
ParameterName: ${appid_1}, ${appid_2}, ParameterType: VARCHAR, VARCHAR

JDBC Request_1返回其结果为2 appid's ('0001' and '0002')-因此{appid_1} = '0001'{appid_2} = '0002'

JDBC Request_1 returns 2 appid's ('0001' and '0002') for it's result - so {appid_1} = '0001' and {appid_2} = '0002'

JDBC Request_2请求如下:

JDBC Request_2 request is as follows:

select A.date, B.appid, A.status from tableA A
inner join TableB on A.id = B.id
where A.status in ('Start', 'End')
and B.appid in (?,?)
0001, 0002
VARCHAR, VARCHAR

因此您可以看到似乎变量已成功从JDBC Request_1传递到Request_2(请注意上面的值'0001,0002'),但是Request_2执行且响应如下:

So you can see it appears the variables are passed successfully from JDBC Request_1 to Request_2 here (note the values '0001, 0002' above) but Request_2 executes and the response is as follows:

DATE        APPID   NODENAME
2015-03-20  0001    Start
2015-03-20  0001    End

也就是说-查询仅针对变量/参数{appid_1}而不是{appid_2}(这是第二个逗号分隔的变量)执行-有人可以建议我做错了吗?

查询在Oracle SQL Developer中执行没有问题,因此我证明了SQL很好-而且使用JMeter实在令人不快!

The query executes with no problems in Oracle SQL Developer so I've proved the SQL is fine - and that I'm rubbish at using JMeter!

如上所述,我环顾四周,反复试验并阅读了帮助-但我只是看不到自己在做什么错.

As I mention above - I've had a look around, trial and error, and read the help - but I just cannot see what I am doing wrong.

感谢任何人可能提供的任何提示/提示!

Thanks for any hints/tips anyone might have!

推荐答案

最终得出答案.

如果前面的ParameterName值的逗号和下一个ParameterName值之间有空格,则下一个ParameterName不包含在后续查询中

If there is a space between the comma of the preceeding ParameterName value and the next ParameterName value, the next ParameterName is NOT included in the subsequent query

  • 即逗号后没有空格,以逗号分隔参数名称,所以不要用'$ {appid_1},$ {appid_2}'代替(您可以在其中看到一个分隔ParameterName值的空格,请指定$ {appid_1},$ {appid_2}而是作为ParameterName列表中的值-否则在此示例中,将不包括$ {appid_2}.

这篇关于JMeter-将多个值从1个JDBC传递到另一个JDBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 21:08