You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Alexander Wallace <aw...@rwmotloc.com> on 2007/01/11 00:42:56 UTC

variable substitution in data from csv file?

Is it possible by any chance that if i read data from a csv file,  
that strings of the type ${whatever} would be substituted by the  
value in jmeter?

such that

SELECT * FROM table WHERE id = ${__threadNum};

would actually but a number for the id?

Thanks!


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


Re: variable substitution in data from csv file?

Posted by Alexander Wallace <aw...@rwmotloc.com>.
Man, that is marvelous. Forgive me for not thinking about such  
things, I still have not learned the ways of jmeter, but it is  
starting to look like a superb tool.

thanks!

On Jan 11, 2007, at 8:23 AM, sebb wrote:

> On 11/01/07, Alexander Wallace <aw...@rwmotloc.com> wrote:
>> I think i didn't express what I meant well... In this case, the whole
>>
>> SELECT * FROM table WHERE id = ${__threadNum};
>>
>> is contained in a ${query} variable, read from a file using a csv
>> data set
>>
>> the ${query} var is being read by a jdbc sampler ...  but the $
>> {__threadNum} portion of the value of ${query} is not being replaced
>> with the thread number ( i assume it is because the whole string is
>> inside a variable)... Is this replacing of a var with a value inside
>> of another var value at all possible?   I'll research more on the
>> functions still...
>
> JMeter does not replace variables referenced in lines read from csv  
> files.
>
> However, you could use the Javascript, BeanShell or Jexl functions to
> do your own string replacement.
>
> Might be easiest to code the data using a different variable  
> marker, e.g.
>
> SELECT * FROM table where id = ~1
>
> you can then do something like
>
> "${query}".replace("~1","${varname}")
>
> depending on the language.
>
> For testing functions and variables etc, the Java Sampler is very
> useful - you can even put the function call in the Label field, and it
> will show up in a Listener - e.g. Table Listener.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


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


Re: variable substitution in data from csv file?

Posted by sebb <se...@gmail.com>.
On 11/01/07, Alexander Wallace <aw...@rwmotloc.com> wrote:
> I think i didn't express what I meant well... In this case, the whole
>
> SELECT * FROM table WHERE id = ${__threadNum};
>
> is contained in a ${query} variable, read from a file using a csv
> data set
>
> the ${query} var is being read by a jdbc sampler ...  but the $
> {__threadNum} portion of the value of ${query} is not being replaced
> with the thread number ( i assume it is because the whole string is
> inside a variable)... Is this replacing of a var with a value inside
> of another var value at all possible?   I'll research more on the
> functions still...

JMeter does not replace variables referenced in lines read from csv files.

However, you could use the Javascript, BeanShell or Jexl functions to
do your own string replacement.

Might be easiest to code the data using a different variable marker, e.g.

SELECT * FROM table where id = ~1

you can then do something like

"${query}".replace("~1","${varname}")

depending on the language.

For testing functions and variables etc, the Java Sampler is very
useful - you can even put the function call in the Label field, and it
will show up in a Listener - e.g. Table Listener.

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


Re: variable substitution in data from csv file?

Posted by Alexander Wallace <aw...@rwmotloc.com>.
I think i didn't express what I meant well... In this case, the whole

SELECT * FROM table WHERE id = ${__threadNum};

is contained in a ${query} variable, read from a file using a csv  
data set

the ${query} var is being read by a jdbc sampler ...  but the $ 
{__threadNum} portion of the value of ${query} is not being replaced  
with the thread number ( i assume it is because the whole string is  
inside a variable)... Is this replacing of a var with a value inside  
of another var value at all possible?   I'll research more on the  
functions still...

Thanks!


On Jan 11, 2007, at 4:59 AM, sebb wrote:

> On 10/01/07, Alexander Wallace <aw...@rwmotloc.com> wrote:
>> Is it possible by any chance that if i read data from a csv file,
>> that strings of the type ${whatever} would be substituted by the
>> value in jmeter?
>>
>> such that
>>
>> SELECT * FROM table WHERE id = ${__threadNum};
>>
>> would actually but a number for the id?
>
> The SQL text is a string - parameters are not numbers - so it will  
> work OK.
>
> See:
>
> http://jakarta.apache.org/jmeter/usermanual/functions.html#Where
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>


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


Re: variable substitution in data from csv file?

Posted by sebb <se...@gmail.com>.
On 10/01/07, Alexander Wallace <aw...@rwmotloc.com> wrote:
> Is it possible by any chance that if i read data from a csv file,
> that strings of the type ${whatever} would be substituted by the
> value in jmeter?
>
> such that
>
> SELECT * FROM table WHERE id = ${__threadNum};
>
> would actually but a number for the id?

The SQL text is a string - parameters are not numbers - so it will work OK.

See:

http://jakarta.apache.org/jmeter/usermanual/functions.html#Where

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