You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Reg King <ma...@googlemail.com> on 2011/03/04 16:23:09 UTC

using SQL select results as a Variable

Hi All,
I am new to jmeter, and new to development so i am sorry if this is a simple
question, i am unfortunatly finding it a little hard to sus out.

I would like to use the results of a MySQL statement as a variable to later
call in a HTTP post Request. The basic test is this: As part of the test
plan i need to delete a record from the DB (via the HTTP Request), however
the delete function uses the table ID as a hidden value. Each time a record
is created the ID changes in the DB, so I cannot use a constant value and
need to select the record ID value and use it as a variable for the HTTP
Request to call.

SQL = select ID from orderdetails where userno = 'AA044' and and accno =
99999999;

I have set up a JDBC request to get this from the DB which is returning ‘ID
XXXXXX’. This is where i am getting a little lost. I have set up a regex
after this but am unable to sus out what the settings should be, or what
else i need to do to.
Would it be possible for someone to give me a really basic ABC step guide to
how i can get this to work?
Thank you very much for your time with this, after 3 hours of staring at
jmeter im getting a little frazzled


--
View this message in context: http://jmeter.512774.n5.nabble.com/using-SQL-select-results-as-a-Variable-tp3409634p3409634.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: using SQL select results as a Variable

Posted by Reg King <ma...@googlemail.com>.
Hi Deepak,

That works a treat, thank you very much for the help

Cool start to a Monday morning :0)

Thanks again 
Reg

--
View this message in context: http://jmeter.512774.n5.nabble.com/using-SQL-select-results-as-a-Variable-tp3409634p3412146.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: using SQL select results as a Variable

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request
You should specify variable names  on the JDBC request (Assuming that you
are getting these values as columns in a resultset).
Then you can put a debug sampler  after your JDBC request to see your
variables being populated .
To use these variables you typically could use a ForEach Controller (so if
you specified the variables names as Col1List,Col2List in JDBCRequest ,
inputVar will be Col1List  and returnVar can be say Col1)
Then your HTTP sampler will be a child of the ForEachController and in the
value ${Col1} --> i.e. the name you specified in returnVar.

You only need use regex if you are using Stored Procs with output variables
or if you only want one thing when you are actually returning lots of
data(why?). In this case also you just use ${variableName} in the value
field for the parameter in your http request. There are lots of examples of
using regex post processors in these mail archives


Note also if you have a web application the *ID* is usually present
somewhere in the HTML so you could always create a regex under the HTTP
Sample and extract the ID from there

reggards
deepak

On Fri, Mar 4, 2011 at 7:23 AM, Reg King <ma...@googlemail.com> wrote:

> Hi All,
> I am new to jmeter, and new to development so i am sorry if this is a
> simple
> question, i am unfortunatly finding it a little hard to sus out.
>
> I would like to use the results of a MySQL statement as a variable to later
> call in a HTTP post Request. The basic test is this: As part of the test
> plan i need to delete a record from the DB (via the HTTP Request), however
> the delete function uses the table ID as a hidden value. Each time a record
> is created the ID changes in the DB, so I cannot use a constant value and
> need to select the record ID value and use it as a variable for the HTTP
> Request to call.
>
> SQL = select ID from orderdetails where userno = 'AA044' and and accno =
> 99999999;
>
> I have set up a JDBC request to get this from the DB which is returning ‘ID
> XXXXXX’. This is where i am getting a little lost. I have set up a regex
> after this but am unable to sus out what the settings should be, or what
> else i need to do to.
> Would it be possible for someone to give me a really basic ABC step guide
> to
> how i can get this to work?
> Thank you very much for your time with this, after 3 hours of staring at
> jmeter im getting a little frazzled
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/using-SQL-select-results-as-a-Variable-tp3409634p3409634.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>