You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by aidy lewis <ai...@googlemail.com> on 2008/06/02 14:37:10 UTC

variablise embedded sql in the jdbc request

Hi,

In a JDBC request, is it possible to use variables in the sql query?

I have a file

15004781
15004782
15004783
15004784
15004785
15004786
15004787
15004788
....

That I read in the CSV data set config. The var has been assigned to
the name 'contractid'

Now, I know I can use this var in Jmeter like this; ${contractid}

But, how could I use this in my sql?

declare @contractId int,
	
set @contractId = 15004779

Thanks

Aidy

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


RE: variablise embedded sql in the jdbc request

Posted by "Anupindi, Satish" <Sa...@cable.comcast.com>.
Re-introducing it back on the forum. 
Thanks!


>        I am a bit lost. When I do a
>
> C:\Program Files\jakarta-jmeter-2.3.4\bin>java -version java version 
> "1.5.0_19"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02) 
> Java HotSpot(TM) Client VM (build 1.5.0_19-b02, mixed mode, sharing)
>
> This is my classpath:
> .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
>
> This is my Path:
> C:\Program Files\Java\jre1.5.0_19\bin;C:\oracle\ora92\bin;C:\Program
> Files\Oracle\jre\1.3.1\bin;C:\Program
> Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemR
> oo t%\System32\Wbem;C:\Program Files\NetManage\RUMBA\System;C:\Program
> Files\NetManage\RUMBA\;C:\Program
> Files\Hummingbird\Connectivity\7.10\Accessories\;C:\Program
> Files\QuickTime\QTSystem\;C:\Program Files\CollabNet 
> Subversion;C:\Program Files\TortoiseSVN\bin;C:\Program 
> Files\Java\jdk1.6.0_11\bin;C:\Program Files\maven\bin
>
> When possible, Please let me know exactly what I am supposed to do.
>
> Thanks so much!!
>
> Regards,
> Satish
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Wednesday, September 23, 2009 5:16 PM
> To: Anupindi, Satish
> Subject: Re: Question on using the JUnit Sampler with JMeter
>
> What version of Java did you use to compile the code?
> And what version of Java did you use to run JMeter?
>
> On 23/09/2009, Anupindi, Satish <Sa...@cable.comcast.com>
> wrote:
>>
>>
>>  My Bad - had classpath issues with junit during compilation. But 
>> here
>>  attached is the jar file which has both the class and source file. I
>>  again put it in the "JMeter_root_dir\lib\junit"  directory - but I
> could
>>  not find the SampleTest under the ClassName option when I brought up
> a
>>  JUnit Sampler. So, back to square 1. I want to have JMeter running
>>  against JUnit for a bigger project, so I am stuck till I get this
> basic
>>  thing to work.
>>
>>
>>  -----Original Message-----
>>  From: sebb [mailto:sebbaz@gmail.com]
>>
>> Sent: Wednesday, September 23, 2009 12:10 PM
>>  To: Anupindi, Satish
>>  Subject: Re: Question on using the JUnit Sampler with JMeter
>>
>>  1) There are no errors in the log file, only one warning
>>
>>  2) The jar file contains the source file, not the compiled class
> file.
>>
>>  On 23/09/2009, Anupindi, Satish
> <Sa...@cable.comcast.com>
>>  wrote:
>>  >
>>  >  Thanks so much for helping me out! I have attached the log file
> and
>>  the
>>  >  Java source and the jar file of the package. I do see errors in
> the
>>  log
>>  >  file, so I have attached it for you to take a look.
>>  >
>>  >  Regards,
>>  >
>>  > Satish
>>  >
>>  >
>>  >  -----Original Message-----
>>  >  From: sebb [mailto:sebbaz@gmail.com]
>>  >
>>  > Sent: Wednesday, September 23, 2009 11:25 AM
>>  >  To: JMeter Users List
>>  >  Subject: Re: Question on using the JUnit Sampler with JMeter
>>  >
>>  >  Are there any errors reported in the jmeter.log file?
>>  >  If so, what are they?
>>  >
>>  >  If not, please send me privately (not to the list):
>>  >
>>  >  The jar.
>>  >  The source for the test case(s) in the jar.
>>  >
>>  >  On 23/09/2009, Anupindi, Satish
>>  <Sa...@cable.comcast.com>
>>  >  wrote:
>>  >  >
>>  >  >  I am using JUnit3.
>>  >  >
>>  >  >
>>  >  >  -----Original Message-----
>>  >  >  From: sebb [mailto:sebbaz@gmail.com]
>>  >  >
>>  >  > Sent: Wednesday, September 23, 2009 10:54 AM
>>  >  >  To: JMeter Users List
>>  >  >  Subject: Re: Question on using the JUnit Sampler with JMeter
>>  >  >
>>  >  >  On 23/09/2009, Anupindi, Satish
>>  >  <Sa...@cable.comcast.com>
>>  >  >  wrote:
>>  >  >  >
>>  >  >  >  Does not seem to work with JMeter 2.3.4 either. Any ideas?
>>  >  >
>>  >  >  Are you using JUnit3 or JUnit4?
>>  >  >
>>  >  >  >
>>  >  >  >  -----Original Message-----
>>  >  >  >  From: sebb [mailto:sebbaz@gmail.com]
>>  >  >  >  Sent: Tuesday, September 22, 2009 6:30 PM
>>  >  >  >  To: JMeter Users List
>>  >  >  >  Subject: Re: Question on using the JUnit Sampler with 
>> JMeter
>>  >  >  >
>>  >  >  >  On 22/09/2009, Anupindi, Satish
>>  >  >  <Sa...@cable.comcast.com>
>>  >  >  >  wrote:
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >  Hi,
>>  >  >  >  >
>>  >  >  >  >             As a proof of concept, I created a sample
> JUNit
>>  Test
>>  >  >  Java
>>  >  >  >  >  file (which is attached), compiled fine, created a jar
> file
>>  out
>>  >  of
>>  >  >  >  the
>>  >  >  >  >  package defined for it. I then, copied the jar file to
> the
>>  >  >  >  >  "JMeter_root_dir\lib\junit"  directory, and restarted
>>  JMeter.
>>  >  But
>>  >  >  I
>>  >  >  >  >  could not find the SampleTest under the ClassName option.
>>  Any
>>  >  >  ideas
>>  >  >  >  why?
>>  >  >  >  >  I Googled the hell out of it - but to no avail. Please
>>  help!!
>>  >  >  >  >
>>  >  >  >
>>  >  >  >  Please don't send attachments to the list (in this case it
> was
>>  >  >  dropped
>>  >  >  >  anyway).
>>  >  >  >
>>  >  >  >  N.B. JMeter 2.3.4 only supports JUnit3 because it targets
> Java
>>  >  1.4+
>>  >  >  >  There will be JUnit4 support in the next release of JMeter
> (no
>>  >  >  release
>>  >  >  >  date yet, but it will require Java 1.5+).
>>  >  >  >
>>  >  >  >  >
>>  >  >  >  >  Thanks,
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >  Satish
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >
>>  >  >  >  >
>>  >  >

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


Re: variablise embedded sql in the jdbc request

Posted by rpaliath <ra...@hotmail.com>.
Aidy, can you please let me know if you were able to get this working? If
yes, can you please add the details on how you got this working. I am having
similar issues with a stored procedure.

Raj



sebb-2-2 wrote:
> 
> On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
>> Hi Sebb
>>
>> On 02/06/2008, sebb <se...@gmail.com> wrote:
>>
>>
>> > Are you sure that the names are identical?
>>  > Make sure that there are no trailing spaces in the variable list.
>>
>>
>> How embarrassing.
>>
>>  I will write up my experiences and put them on the wiki if you would
>> like?
>>
> 
> The Wiki is for everyone to update if they want.
> 
>>  Aidy
>>
>>  ---------------------------------------------------------------------
>>  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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/variablise-embedded-sql-in-the-jdbc-request-tp17600313p25577763.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: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Hi Sebb
>
> On 02/06/2008, sebb <se...@gmail.com> wrote:
>
>
> > Are you sure that the names are identical?
>  > Make sure that there are no trailing spaces in the variable list.
>
>
> How embarrassing.
>
>  I will write up my experiences and put them on the wiki if you would like?
>

The Wiki is for everyone to update if they want.

>  Aidy
>
>  ---------------------------------------------------------------------
>  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: variablise embedded sql in the jdbc request

Posted by aidy lewis <ai...@googlemail.com>.
Hi Sebb
On 02/06/2008, sebb <se...@gmail.com> wrote:

> Are you sure that the names are identical?
> Make sure that there are no trailing spaces in the variable list.

How embarrassing.

I will write up my experiences and put them on the wiki if you would like?

Aidy

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


Re: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Hi Sebb,
>
>  The log tells me the file has been read
>  jmeter.services.FileServer: Stored: C:\aidy\freemind_data\freemind_data.txt
>
>  I have pasted the sql query within the JDBC window
>
>  set @contractId =  ${contractid}
>
> set @partyName = "${partyName}"
>  set @projectId =  ${projectId}
>
>
> The query works when I hard code it.
>
>  The JDBC request shown in the results tree is:
>  set @contractId =  ${contractid}
>
> set @partyName = "${partyName}"
>  set @projectId =  ${projectId}
>
>
> Do I have an alternative?

Just tried, and CSV Dataset works fine with JDBC Sampler for me.

Are you sure that the names are identical?
Make sure that there are no trailing spaces in the variable list.

>  Thanks for the help.
>
>
>  Aidy
>
>  ---------------------------------------------------------------------
>  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: variablise embedded sql in the jdbc request

Posted by aidy lewis <ai...@googlemail.com>.
Hi Sebb,

The log tells me the file has been read
jmeter.services.FileServer: Stored: C:\aidy\freemind_data\freemind_data.txt

I have pasted the sql query within the JDBC window

set @contractId =  ${contractid}
set @partyName = "${partyName}"
set @projectId =  ${projectId}

The query works when I hard code it.

The JDBC request shown in the results tree is:
set @contractId =  ${contractid}
set @partyName = "${partyName}"
set @projectId =  ${projectId}

Do I have an alternative?

Thanks for the help.

Aidy

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


Re: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Hi sebb,
>
>  The request being sent is this
>
>  set @contractId =  ${contractid}

should be ${contractId} ?

>  set @partyName = "${partyName}"
>  set @projectId =  ${projectId}
>
>  So my values are not being passed in. The csv is this:
>
>   15004780,   MRM Productions 6,   1401
>   15004781,   MRM Productions 7,   1402
>   15004782,   MRM Productions 8,   1403
>   15004783,   MRM Productions 9,   1404
>   .....
>
>  And the csv config is:
>
>  filename: C:\data.csv
>  variable names: contractId, partyName, projectId
>

Check the JMeter log file in case there are any errors reported using
the data file.

>  Thanks
>
>  Aidy
>
>  ---------------------------------------------------------------------
>  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: variablise embedded sql in the jdbc request

Posted by aidy lewis <ai...@googlemail.com>.
Hi sebb,

The request being sent is this

set @contractId =  ${contractid}
set @partyName = "${partyName}"
set @projectId =  ${projectId}

So my values are not being passed in. The csv is this:

 15004780,   MRM Productions 6,   1401
 15004781,   MRM Productions 7,   1402
 15004782,   MRM Productions 8,   1403
 15004783,   MRM Productions 9,   1404
  .....

And the csv config is:

filename: C:\data.csv
variable names: contractId, partyName, projectId

Thanks

Aidy

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


Re: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Hi,
>
>  Sorry to bother you again, but I am having problems using the variablised data
>
>  This is my test plan
>
>  test plan
>   thread
>   JDBC config
>   JDBC request
>   View Results in Tree
>   View Results in Table
>   CSV Data Set Config
>
>  In my csv data config, I have
>
>  filename:  C:\data.csv
>  variable name: contractId, projectId, partyName
>
>  tha data.csv is in this format
>   15004780,   Productions 6,   1401
>   15004781,   Productions 7,   1402
>   15004782,   Productions 8,   1403
>   15004783,   Productions 9,   1404
>
>   In my jdbc request the sql update is
>
>   declare @contractId int,
>                  @projectId int,
>                  @partyName nvarchar(100)
>
>  set @contractId = ${contractid}
>  set @partyName = ${projectId}
>  set @projectId = ${partyName}

Looks like the wrong way round.

>  and in the jdbc field
>
>  parameter values: ${contractid},${projectId}, ${partyName}
>  paramater types: int, int, nvarchar
>
>  The error I am getting is:
>
>  Response message: com.microsoft.sqlserver.jdbc.SQLServerException:
>  Line 8: Incorrect syntax near '{'.

You don't need the variable reference in both parameter variables and the SQL

nvarchar types need to be quoted, e.g. '${partyName}' or perhaps using
double-quote - that may depend on your server

>  So for some reason, values are not being entered into the variables.
>

Add a Tree View Listener and check the Request pane to see what was sent.

>  Aidy
>
>  On 02/06/2008, sebb <se...@gmail.com> wrote:
>  > On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
>  > > Sebb,
>  > >
>  > >  Thanks. This is valuable information. Is there anyway we can set up a
>  > >  JMeter Wiki faq, and then we could filter the really useful stuff to
>  > >  the help files?
>  > >
>  >
>  > There is already a Wiki & FAQ - follow the links on the JMeter web-site.
>  >
>  > >  Aidy
>  > >
>  > >
>  > >  On 02/06/2008, sebb <se...@gmail.com> wrote:
>  > >  > On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
>  > >  > > Hi,
>  > >  > >
>  > >  > >  In a JDBC request, is it possible to use variables in the sql query?
>  > >  > >
>  > >  > >  I have a file
>  > >  > >
>  > >  > >  15004781
>  > >  > >  15004782
>  > >  > >  15004783
>  > >  > >  15004784
>  > >  > >  15004785
>  > >  > >  15004786
>  > >  > >  15004787
>  > >  > >  15004788
>  > >  > >  ....
>  > >  > >
>  > >  > >  That I read in the CSV data set config. The var has been assigned to
>  > >  > >  the name 'contractid'
>  > >  > >
>  > >  > >  Now, I know I can use this var in Jmeter like this; ${contractid}
>  > >  > >
>  > >  > >  But, how could I use this in my sql?
>  > >  > >
>  > >  > >  declare @contractId int,
>  > >  > >
>  > >  > >  set @contractId = 15004779
>  > >  > >
>  > >  >
>  > >  > If you are referring to SQL in the JDBC sampler, then just put:
>  > >  >
>  > >  > set @contractId = ${contractid}
>  > >  >
>  > >  > However, I assume you are referring to a stored procedure.
>  > >  >
>  > >  > In which case, you need to pass the variable in as a parameter to the
>  > >  > stored procedure, and use whatever the SQL dialect requires to refer
>  > >  > to the parameter.
>  > >  >
>  > >  > The JDBC Sampler would look something like:
>  > >  >
>  > >  > {CALL PROCEDURE(${contractid})}
>  > >  >
>  > >  > or, if using a prepared statement:
>  > >  > {CALL PROCEDURE(?)}
>  > >  > and then add ${contractid} as a variable at the bottom.
>  > >  >
>  > >  > The enclosing {} may not be necessary.
>  > >  >
>  > >  > See http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request
>  > >  >
>  > >  > >  Thanks
>  > >  > >
>  > >  > >  Aidy
>  > >  > >
>  > >  > >  ---------------------------------------------------------------------
>  > >  > >  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
>  > >  >
>  > >  >
>  > >
>  > >
>  > >
>  > > --
>  > >  Aidy
>  > >  www.agiletester.co.uk
>  > >
>  > >
>  > >  ---------------------------------------------------------------------
>  > >  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
>  >
>  >
>
>
>  --
>  Aidy
>  www.agiletester.co.uk
>
>  ---------------------------------------------------------------------
>  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: variablise embedded sql in the jdbc request

Posted by aidy lewis <ai...@googlemail.com>.
Hi,

Sorry to bother you again, but I am having problems using the variablised data

This is my test plan

test plan
  thread
  JDBC config
  JDBC request
  View Results in Tree
  View Results in Table
  CSV Data Set Config

In my csv data config, I have

filename:  C:\data.csv
variable name: contractId, projectId, partyName

tha data.csv is in this format
 15004780,   Productions 6,   1401
 15004781,   Productions 7,   1402
 15004782,   Productions 8,   1403
 15004783,   Productions 9,   1404

 In my jdbc request the sql update is

 declare @contractId int,
		 @projectId int,
		 @partyName nvarchar(100)

set @contractId = ${contractid}
set @partyName = ${projectId}
set @projectId = ${partyName}

and in the jdbc field

parameter values: ${contractid},${projectId}, ${partyName}
paramater types: int, int, nvarchar

The error I am getting is:

Response message: com.microsoft.sqlserver.jdbc.SQLServerException:
Line 8: Incorrect syntax near '{'.

So for some reason, values are not being entered into the variables.

Aidy

On 02/06/2008, sebb <se...@gmail.com> wrote:
> On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> > Sebb,
> >
> >  Thanks. This is valuable information. Is there anyway we can set up a
> >  JMeter Wiki faq, and then we could filter the really useful stuff to
> >  the help files?
> >
>
> There is already a Wiki & FAQ - follow the links on the JMeter web-site.
>
> >  Aidy
> >
> >
> >  On 02/06/2008, sebb <se...@gmail.com> wrote:
> >  > On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> >  > > Hi,
> >  > >
> >  > >  In a JDBC request, is it possible to use variables in the sql query?
> >  > >
> >  > >  I have a file
> >  > >
> >  > >  15004781
> >  > >  15004782
> >  > >  15004783
> >  > >  15004784
> >  > >  15004785
> >  > >  15004786
> >  > >  15004787
> >  > >  15004788
> >  > >  ....
> >  > >
> >  > >  That I read in the CSV data set config. The var has been assigned to
> >  > >  the name 'contractid'
> >  > >
> >  > >  Now, I know I can use this var in Jmeter like this; ${contractid}
> >  > >
> >  > >  But, how could I use this in my sql?
> >  > >
> >  > >  declare @contractId int,
> >  > >
> >  > >  set @contractId = 15004779
> >  > >
> >  >
> >  > If you are referring to SQL in the JDBC sampler, then just put:
> >  >
> >  > set @contractId = ${contractid}
> >  >
> >  > However, I assume you are referring to a stored procedure.
> >  >
> >  > In which case, you need to pass the variable in as a parameter to the
> >  > stored procedure, and use whatever the SQL dialect requires to refer
> >  > to the parameter.
> >  >
> >  > The JDBC Sampler would look something like:
> >  >
> >  > {CALL PROCEDURE(${contractid})}
> >  >
> >  > or, if using a prepared statement:
> >  > {CALL PROCEDURE(?)}
> >  > and then add ${contractid} as a variable at the bottom.
> >  >
> >  > The enclosing {} may not be necessary.
> >  >
> >  > See http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request
> >  >
> >  > >  Thanks
> >  > >
> >  > >  Aidy
> >  > >
> >  > >  ---------------------------------------------------------------------
> >  > >  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
> >  >
> >  >
> >
> >
> >
> > --
> >  Aidy
> >  www.agiletester.co.uk
> >
> >
> >  ---------------------------------------------------------------------
> >  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
>
>


-- 
Aidy
www.agiletester.co.uk

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


Re: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Sebb,
>
>  Thanks. This is valuable information. Is there anyway we can set up a
>  JMeter Wiki faq, and then we could filter the really useful stuff to
>  the help files?
>

There is already a Wiki & FAQ - follow the links on the JMeter web-site.

>  Aidy
>
>
>  On 02/06/2008, sebb <se...@gmail.com> wrote:
>  > On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
>  > > Hi,
>  > >
>  > >  In a JDBC request, is it possible to use variables in the sql query?
>  > >
>  > >  I have a file
>  > >
>  > >  15004781
>  > >  15004782
>  > >  15004783
>  > >  15004784
>  > >  15004785
>  > >  15004786
>  > >  15004787
>  > >  15004788
>  > >  ....
>  > >
>  > >  That I read in the CSV data set config. The var has been assigned to
>  > >  the name 'contractid'
>  > >
>  > >  Now, I know I can use this var in Jmeter like this; ${contractid}
>  > >
>  > >  But, how could I use this in my sql?
>  > >
>  > >  declare @contractId int,
>  > >
>  > >  set @contractId = 15004779
>  > >
>  >
>  > If you are referring to SQL in the JDBC sampler, then just put:
>  >
>  > set @contractId = ${contractid}
>  >
>  > However, I assume you are referring to a stored procedure.
>  >
>  > In which case, you need to pass the variable in as a parameter to the
>  > stored procedure, and use whatever the SQL dialect requires to refer
>  > to the parameter.
>  >
>  > The JDBC Sampler would look something like:
>  >
>  > {CALL PROCEDURE(${contractid})}
>  >
>  > or, if using a prepared statement:
>  > {CALL PROCEDURE(?)}
>  > and then add ${contractid} as a variable at the bottom.
>  >
>  > The enclosing {} may not be necessary.
>  >
>  > See http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request
>  >
>  > >  Thanks
>  > >
>  > >  Aidy
>  > >
>  > >  ---------------------------------------------------------------------
>  > >  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
>  >
>  >
>
>
>
> --
>  Aidy
>  www.agiletester.co.uk
>
>
>  ---------------------------------------------------------------------
>  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: variablise embedded sql in the jdbc request

Posted by aidy lewis <ai...@googlemail.com>.
Sebb,

Thanks. This is valuable information. Is there anyway we can set up a
JMeter Wiki faq, and then we could filter the really useful stuff to
the help files?

Aidy

On 02/06/2008, sebb <se...@gmail.com> wrote:
> On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> > Hi,
> >
> >  In a JDBC request, is it possible to use variables in the sql query?
> >
> >  I have a file
> >
> >  15004781
> >  15004782
> >  15004783
> >  15004784
> >  15004785
> >  15004786
> >  15004787
> >  15004788
> >  ....
> >
> >  That I read in the CSV data set config. The var has been assigned to
> >  the name 'contractid'
> >
> >  Now, I know I can use this var in Jmeter like this; ${contractid}
> >
> >  But, how could I use this in my sql?
> >
> >  declare @contractId int,
> >
> >  set @contractId = 15004779
> >
>
> If you are referring to SQL in the JDBC sampler, then just put:
>
> set @contractId = ${contractid}
>
> However, I assume you are referring to a stored procedure.
>
> In which case, you need to pass the variable in as a parameter to the
> stored procedure, and use whatever the SQL dialect requires to refer
> to the parameter.
>
> The JDBC Sampler would look something like:
>
> {CALL PROCEDURE(${contractid})}
>
> or, if using a prepared statement:
> {CALL PROCEDURE(?)}
> and then add ${contractid} as a variable at the bottom.
>
> The enclosing {} may not be necessary.
>
> See http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request
>
> >  Thanks
> >
> >  Aidy
> >
> >  ---------------------------------------------------------------------
> >  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
>
>


-- 
Aidy
www.agiletester.co.uk

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


Re: variablise embedded sql in the jdbc request

Posted by sebb <se...@gmail.com>.
On 02/06/2008, aidy lewis <ai...@googlemail.com> wrote:
> Hi,
>
>  In a JDBC request, is it possible to use variables in the sql query?
>
>  I have a file
>
>  15004781
>  15004782
>  15004783
>  15004784
>  15004785
>  15004786
>  15004787
>  15004788
>  ....
>
>  That I read in the CSV data set config. The var has been assigned to
>  the name 'contractid'
>
>  Now, I know I can use this var in Jmeter like this; ${contractid}
>
>  But, how could I use this in my sql?
>
>  declare @contractId int,
>
>  set @contractId = 15004779
>

If you are referring to SQL in the JDBC sampler, then just put:

set @contractId = ${contractid}

However, I assume you are referring to a stored procedure.

In which case, you need to pass the variable in as a parameter to the
stored procedure, and use whatever the SQL dialect requires to refer
to the parameter.

The JDBC Sampler would look something like:

{CALL PROCEDURE(${contractid})}

or, if using a prepared statement:
{CALL PROCEDURE(?)}
and then add ${contractid} as a variable at the bottom.

The enclosing {} may not be necessary.

See http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JDBC_Request

>  Thanks
>
>  Aidy
>
>  ---------------------------------------------------------------------
>  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