JDBC request with table name as a variable?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

JDBC request with table name as a variable?

o haya
Hi,

I want to implement at test plan where I am executing "select" statements but against different table names, where the set of table names is in a CSV file.

Say I have a CSV file:

table1
table2
table3

and I run the test plan, then this causes the following:

select count(*) from table1

then the next iteration in the loop does:

select count(*) from table2

then the next iteration in the loop does:

select count(*) from table3

then the next iteration in the loop does:

select count(*) from table1

etc.

If the CSV file has:

table10
table11
table12
table13

Then I run the test plan it will do:

select count(*) from table10

then the next iteration in the loop does:

select count(*) from table11

then the next iteration in the loop does:

select count(*) from table12

then the next iteration in the loop does:

select count(*) from table13

then the next iteration in the loop does:

select count(*) from table10

etc.

I tried using

select count(*) from ${tablename}

but that appears to become:

select count(*) from "table1"

rather than:

select count(*) from table1

Is there a way to do what I'm trying to do with Jmeter?

Thanks,
Jim



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JDBC request with table name as a variable?

Riji K
Hi,

When a value is passed from CSV it is considered as string. After getting
the value from CSV write a beanshell and convert it to a table name. Or use
a beanshell program to retrieve the table count values.

Thanks,
Riji

On Dec 7, 2016 07:48, "o haya" <[hidden email]> wrote:

> Hi,
>
> I want to implement at test plan where I am executing "select" statements
> but against different table names, where the set of table names is in a CSV
> file.
>
> Say I have a CSV file:
>
> table1
> table2
> table3
>
> and I run the test plan, then this causes the following:
>
> select count(*) from table1
>
> then the next iteration in the loop does:
>
> select count(*) from table2
>
> then the next iteration in the loop does:
>
> select count(*) from table3
>
> then the next iteration in the loop does:
>
> select count(*) from table1
>
> etc.
>
> If the CSV file has:
>
> table10
> table11
> table12
> table13
>
> Then I run the test plan it will do:
>
> select count(*) from table10
>
> then the next iteration in the loop does:
>
> select count(*) from table11
>
> then the next iteration in the loop does:
>
> select count(*) from table12
>
> then the next iteration in the loop does:
>
> select count(*) from table13
>
> then the next iteration in the loop does:
>
> select count(*) from table10
>
> etc.
>
> I tried using
>
> select count(*) from ${tablename}
>
> but that appears to become:
>
> select count(*) from "table1"
>
> rather than:
>
> select count(*) from table1
>
> Is there a way to do what I'm trying to do with Jmeter?
>
> Thanks,
> Jim
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JDBC request with table name as a variable?

sebb-2-2
In reply to this post by o haya
On 7 December 2016 at 02:18, o haya <[hidden email]> wrote:

> Hi,
>
> I want to implement at test plan where I am executing "select" statements but against different table names, where the set of table names is in a CSV file.
>
> Say I have a CSV file:
>
> table1
> table2
> table3
>
> and I run the test plan, then this causes the following:
>
> select count(*) from table1
>
> then the next iteration in the loop does:
>
> select count(*) from table2
>
> then the next iteration in the loop does:
>
> select count(*) from table3
>
> then the next iteration in the loop does:
>
> select count(*) from table1
>
> etc.
>
> If the CSV file has:
>
> table10
> table11
> table12
> table13
>
> Then I run the test plan it will do:
>
> select count(*) from table10
>
> then the next iteration in the loop does:
>
> select count(*) from table11
>
> then the next iteration in the loop does:
>
> select count(*) from table12
>
> then the next iteration in the loop does:
>
> select count(*) from table13
>
> then the next iteration in the loop does:
>
> select count(*) from table10
>
> etc.
>
> I tried using
>
> select count(*) from ${tablename}
>
> but that appears to become:
>
> select count(*) from "table1"
>
> rather than:
>
> select count(*) from table1
>
> Is there a way to do what I'm trying to do with Jmeter?

That should work.
Are you sure that quotes are added to the table name in the query?
Check that they are not present in the input by using the Debug
element to display the value of the tablename variable.

> Thanks,
> Jim
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JDBC request with table name as a variable?

o haya
In reply to this post by o haya
Hi sebb,

WOW!  You were EXACTLY right!

In the CSV file, I had double-quotes around the table names :(!!!

I got rid of the double quotes in the CSV file, and used this in the JDBC request:

select count(*) from ${tablename}

and it works now :)!!

Thanks!

Jim


--------------------------------------------
On Wed, 12/7/16, sebb <[hidden email]> wrote:

 Subject: Re: JDBC request with table name as a variable?
 To: "JMeter Users List" <[hidden email]>, "o haya" <[hidden email]>
 Date: Wednesday, December 7, 2016, 4:35 AM
 
 On 7 December 2016 at
 02:18, o haya <[hidden email]>
 wrote:
 > Hi,
 >
 > I want to implement at test plan where I
 am executing "select" statements but against
 different table names, where the set of table names is in a
 CSV file.
 >
 > Say I
 have a CSV file:
 >
 >
 table1
 > table2
 >
 table3
 >
 > and I run
 the test plan, then this causes the following:
 >
 > select count(*) from
 table1
 >
 > then the
 next iteration in the loop does:
 >
 > select count(*) from table2
 >
 > then the next
 iteration in the loop does:
 >
 > select count(*) from table3
 >
 > then the next
 iteration in the loop does:
 >
 > select count(*) from table1
 >
 > etc.
 >
 > If the CSV file
 has:
 >
 > table10
 > table11
 > table12
 > table13
 >
 > Then I run the test plan it will do:
 >
 > select count(*) from
 table10
 >
 > then the
 next iteration in the loop does:
 >
 > select count(*) from table11
 >
 > then the next
 iteration in the loop does:
 >
 > select count(*) from table12
 >
 > then the next
 iteration in the loop does:
 >
 > select count(*) from table13
 >
 > then the next
 iteration in the loop does:
 >
 > select count(*) from table10
 >
 > etc.
 >
 > I tried using
 >
 > select count(*) from
 ${tablename}
 >
 > but
 that appears to become:
 >
 > select count(*) from "table1"
 >
 > rather than:
 >
 > select count(*) from
 table1
 >
 > Is there a
 way to do what I'm trying to do with Jmeter?
 
 That should work.
 Are you sure that quotes are added to the table
 name in the query?
 Check that they are not
 present in the input by using the Debug
 element to display the value of the tablename
 variable.
 
 > Thanks,
 > Jim
 >
 >
 >
 >
 ---------------------------------------------------------------------
 > To unsubscribe, e-mail: [hidden email]
 > For additional commands, e-mail: [hidden email]
 >
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...