Home > Back-end >  Variable Storage - JDBC request in Jmeter
Variable Storage - JDBC request in Jmeter

Time:04-20

I have the following problem:

When adding a JDBC Request, query type "Select Statement", I add a variable name, but it doesn't save successfully.

Could anyone tell the reason?

Code below and print below.

Script to select:

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;

enter image description here

Can you help me?

CodePudding user response:

We cannot because on JDBC level it's not possible to execute Select statement which calls Statement.executeQuery() under the hood which doesn't produce a ResultSet.

So you need to transform your query to something like:

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')

so it would issue single Select statement which would return a result.

More information: The Real Secret to Building a Database Test Plan With JMeter

  • Related