如何从 JMeter 中的 1 元素集合中提取一个值?

How to extract one value from 1-element collection in JMeter?

首先,我这样做 select: SELECT TOP 1 ID FROM Person where Name=${NAME} AND YOB=${YOB}; 我需要在 JMeter 中执行 SQL 请求:
select * from Person where ID=${ID},其中 ${ID} 是第一个 select 中返回的全局变量。第一个 select returns 集合,但只有 1 个值。如何提取此值并将其分配给变量?

您可以使用其中一种 post-processor components to extract values from your response. In your case the Regular Expression extractor 可能是最合适的。

根据 JDBC Request Sampler Documentation,您可以将值引用为 $A1

A_#=2 (number of rows)
A_1=column 1, row 1
A_2=column 1, row 2
C_#=2 (number of rows)
C_1=column 3, row 1
C_2=column 3, row 2

有关使用 Apache JMeter 进行数据库测试的更多提示和技巧,请参阅 The Real Secret to Building a Database Test Plan With JMeter