Obtain the number of rows update with a JDBC Request in JMeter - jdbc

I am using Jmeter in order to perform an update on a table. It is working fine in the sense it is updating the rows but I am not able to find out how to get acknowledge of how many rows were updated.
As an example I'm using this query:
Update MIG_LOT set STATE='LIBRE' where LOT=2033
On the JDBC Request I used UPDATED on the field Result variable name but it doesn't seem to put in it the number of rows updated or any other information

Well it was easier.
Just attach a Regular expression extractor:
Using in Reference name the name I want for the variable, ([0-9]+) updatesas the Regular Expression, $1$ on the Template and 1 as the Match number.
And I can access the number of updated rows through the UPDATESREGEXP variable.

Related

JMeter: Regular expression extractor gets the name of the column after JDBC request returned data

I faced some issue:
I use JDBC request for selecting usernames data and reuse it in the login request
The JDBC request returns correct data from the table
But the issue that my login request uses the column name as data, so it tries to login with the username businessId instead of the correct one. So when randomly JDBC request returns the first row which is businessId value the test returns 401 error.
Do you have any ideas on how can I get the correct values within JDBC request or extract values without column name?
As per JDBC Request sampler documentation
If the Variable Names list is provided, then for each row returned by a Select statement, the variables are set up with the value of the corresponding column (if a variable name is provided), and the count of rows is also set up. For example, if the Select statement returns 2 rows of 3 columns, and the variable list is A,,C, then the following variables will be set up:
A_#=2 (number of rows)
A_1=column 1, row 1
A_2=column 1, row 2
So you don't need the Regular Expression Extractor, you need to define "Variable names" like:
and first row value can be referenced as businessId_1, second as businessId_2, etc.
More information: Debugging JDBC Sampler Results in JMeter
Actually, the problem was in the column name which was included in the businessId results. So my JDBC Request returned the values including the column name and the column name was stored as the businessId value.
For solving the issue I use ForEach Controller where Input Variable Prefix: businessId and Output variable name: currentId

How to fetch parameters of same array randomly using regular expression in jmeter

Like there are lots of values in array
{"profile":"qa","job":"active","status":"green"}
{"profile":"dba","job":"non-active","status":"yellow"}
So there are multiple rows like this, I want to fetch profile and job of all the arrays randomly and it should be like that, if profile is selected as qa randomly say by regular expression post processor, then job value should also be "active" i.e
Same for dba profile, that if dba is fetched , then job value should be non active
Can this be achieved using regular expression for random fetch??i. giving match no as 0
As you are dealing with JSON responses, hence would recommend you to use JSON extractor post processor as $..['job','profile'] and set Match number to 0. This way you can extract values from array in one go.
You can use this variable name highlighted in subsequent requests like - ${entryJson}
For Regular expression you can use profile": "(.?)" and job": "(.?)"
in two of the expressions but using zero will return different values for each run.

How can I add static values in a column in grafana/influxdb

I'm using grafana, influxdb and jmeter. I have this table.
I need to add a column that says "Base Line" with a value different for each request name. I have tried the following:
- Grafana does not seem to have a way to add static values for columns, or a query equivalent of sql for "select 'value' as 'columnName'"
- I tried creating a new time series for static data (base lines) and do a join of the results from jmeter with the series I created, but I get this error:
error parsing query: found AS, expected ;
I'm having a hard time trying to create an extra column with fixed data for each request... my last resort is to modify or create a jmeter plugin for that matter, but before going for that, there might be something I could be missing.
The easiest solution I can think of is adding a Dummy Sampler which will be doing nothing but "sleeping" for specified amount of time which is your "baseline".
JMeter's Backend Listener will collect this sampler metrics and you will either see a straight horizontal line identifying your baseline in the chart or the baseline value in the table or will be able to aggregate as a vertical column.
You can install Dummy Sampler using JMeter Plugins Manager

Extract value from JDBC request and use in next jdbc request

I am writing a JDBC test plan for Add and Delete records.
I have extracted queries from SQL Express Profiler for ADD and Delete.
Now when i run JDBC request for add and delete then record is added but same record not deleted. because delete query having different unique key (e.g.35) of record which was added when query was taken from express profiler. Every time i run add jdbc request then new record having different value i.e. incremented.
Is there any way to extract unique key from Jdbc request of ADD and use it in Delete JDBC request so that same record could be deleted?
Response of ADD JDBC Request:
Delete query where i want to use unique value from response of ADD request:
In JDBC Request sampler you have Variable Names input where you can specify the JMeter Variables which will hold the results values. So given you put ScopeIdentity there most likely you will be able to refer its value later on as ${ScopeIdentity_1}
References:
JDBC PostProcessor Example in Jmeter for Response assertion
Debugging JDBC Sampler Results in JMeter
You can solve this using the varible field that you have in your JDBC Request sampler.
More information on the parameters used in JDBC requests are found here:
https://jmeter.apache.org/usermanual/component_reference.html#JDBC_Request
Let me explain how to use them with your problem as an example:
For the ADD query enter the variable name in the Variables Names field:
ScopeIdentity
This will result in the thread local value for Scopeidentity being saved in a variable named "Scopeidentity" with a suflix of the thread-number. So for one-thread scenario the variable is ScopeIdentity_1
For the DELETE query enter this where you want to refer to the value:
${__V(Scopeidentity_${__threadNum})}
Where ${__threadNum} gives the number of the current thread.
https://jmeter.apache.org/usermanual/functions.html#__threadNum
Where ${__V()} is used to nest the variable name and the result of __threadNum.
https://jmeter.apache.org/usermanual/functions.html#what_can_do
Response for Add request wouldn't retrieve your unique_id.
Add an additional step between ADD and DELETE as below:
SELECT TOP 1 unique_id
FROM table
WHERE condition
order by unique_id desc;
Store this response to a variable and use it in the DELETE statement.

Jmeter regular expression for Oracle DB output

In Jmeter , I have created a DB connection with Oracle, and executing below query.
select address , city , zip from table where city='Delhi';
Now this is giving result as:
212 Kamla nagar Delhi 11011
Now I want to use this into 3 variable using regular expression and pass all these 3 parameters to another soap request.
I tried to use regular expression as (\d+) but it only stored value in variable 1.
How to extract values and use them in another request?
you can use JDBC preprocessor and from which you use either Variable names or Result variable name
The ones you specify in the Variable names box map to individual columns returned by your query and these you can access by saying columnVariable_{index}.
OR
The one you specify in the Result variable name contains the entire result set and in practice this is a list of maps to values. The above syntax will obviously not work in this case. you will have to access it by BeanShell and create variables.
...and then you can use these variables as ${name_1}, ${city_1}, ${zip_1} in soap request to access value from DB. or as ${name}, ${city}, ${zip} if you use Result variable name object
Configure your JDBC Sampler as follows:
i.e. add the next line to "Variable Names" input:
address, city, zip
You will be able to access the extracted values as:
${address_1}
${city_1}
${zip_1}
later in the script. 1 stands for Result Set row, i.e. if there will be 2 rows in JDBC response - ${address_1} will stand for 1st row address, ${address_2} - for 2nd row address, etc.
See Debugging JDBC Sampler Results in JMeter article for details.

Resources