变量存储- Jmeter中的JDBC请求



我有以下问题:

在添加JDBC Request时,查询类型为"Select statement",我添加了一个变量名,但是保存不成功。

谁能告诉我原因?

在下面编码,并在下面打印。

选择脚本:

USE ${DATABASE};
Declare @ID_SOLICITACAO_RSP as int
Declare @NM_ARQUIVO_RET as varchar (50)
set @ID_SOLICITACAO_RSP =
(
SELECT
VLR_SEQUENCIA
FROM
TBJD_SEQUENCIA
WHERE
CD_NEGOCIO = 'JDCTC'
AND CD_OBJETO = 'IDSOLIC'
)
SET @NM_ARQUIVO_RET =
(
SELECT substring(cat.nm_arqv, len(cat.nm_arqv)-30, 31) + '_RET.XML'
FROM TBJDCTCPRO_SOLIC_ARQV_TRANS SAT
JOIN TBJDCTCCIP_ARQV_TRANS CAT ON (SAT.ID_ARQV_TRANS = CAT.ID_ARQV_TRANS)
JOIN TBJDCTCPRO_SOLIC SOL ON (SOL.ID_SOLICITACAO = SAT.ID_SOLICITACAO)
WHERE SAT.ID_SOLICITACAO = @ID_SOLICITACAO_RSP
AND CAT.TP_ARQV IN ('ACTC101', 'ACTC201', 'ACTC301', 'ACTC401', 'ACTC501', 'ACTC601', 'ACTC701', 'ACTC801', 'ACTC851')
)
PRINT @NM_ARQUIVO_RET;

输入图片描述

你能帮我吗?

我们不能,因为在JDBC级别上不可能执行Select语句,该语句在底层调用statement . executequery(),而不会产生ResultSet。

所以你需要把你的查询转换成这样的东西:

SELECT substring(cat.nm_arqv, len(cat.nm_arqv) - 30, 31) + '_RET.XML'
FROM TBJDCTCPRO_SOLIC_ARQV_TRANS SAT
JOIN TBJDCTCCIP_ARQV_TRANS CAT ON (SAT.ID_ARQV_TRANS = CAT.ID_ARQV_TRANS)
JOIN TBJDCTCPRO_SOLIC SOL ON (SOL.ID_SOLICITACAO = SAT.ID_SOLICITACAO)
WHERE SAT.ID_SOLICITACAO = (
SELECT VLR_SEQUENCIA
FROM TBJD_SEQUENCIA
WHERE CD_NEGOCIO = 'JDCTC'
AND CD_OBJETO = 'IDSOLIC'
)
AND CAT.TP_ARQV IN ('ACTC101', 'ACTC201', 'ACTC301', 'ACTC401', 'ACTC501', 'ACTC601', 'ACTC701', 'ACTC801', 'ACTC851')

所以它会发出一个Select语句,返回一个结果。

更多信息:使用JMeter构建数据库测试计划的真正秘密

相关内容

  • 没有找到相关文章

最新更新