Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to execute a data base correlation SQL query from the Responder Output - extension tool

Sindhu
Sindhu Posts: 17

I have a responder which executes a Data source -> data base correlation and I have chained the outputs to the responder and in one of the outputs I am setting the variable value that is used in the data base correlation, now in the next output I have to execute the data base correlation and fetch the database values.
Can anyone please suggest a solution. I am using the extension tool and trying to fetch the results as a list, but the query is not executing.

Answers

  • williammccusker
    williammccusker Posts: 640 ✭✭✭

    Hi,

    The query can be executed automatically as part of "Data Source Correlation" for the responder. The "Data Source Correlation" tab in the responder has a number of options for how values can be extracted from the incoming request and then mapped into the query. Have you tried using "Data Source Correlations"?

  • Sindhu
    Sindhu Posts: 17

    Thank you for responding , I have tried data source correlations. Actually I need the query to be executed twice. One is in the responder mapping with the data source correlations and other is from the extension tool

  • williammccusker
    williammccusker Posts: 640 ✭✭✭

    Hi,

    Ok so for that second execution to pass a value from the first extension tool to the second the context object has methods to put/get variables and I believe one of those can be used to create a value that the other context tool could get.

    Eg.

    context.put("myvariable", "some value")

    Then in the second script

    context.get("myvariable")

  • Sindhu
    Sindhu Posts: 17

    My extension tool should execute the data base correlation sql query

  • williammccusker
    williammccusker Posts: 640 ✭✭✭

    Hi,

    Is all that the tool does is execute the query? If so then perhaps a DB Tool would be a better option since you wouldn't have to write all the SQL query code and would just need to setup the variable from the first extension tool.

  • Sindhu
    Sindhu Posts: 17

    The extension tool should fetch the query results using a variable with is set to have value in the tool just above it and update a new variable based on one of the column values and the new variable should be used in the responder literal

  • williammccusker
    williammccusker Posts: 640 ✭✭✭

    Hi,

    In that case it might be easier to chain a tool to the output of the DB tool so that you don't have to write all the SQL code and then just look at the results and set the new variable based on the results.

  • Sindhu
    Sindhu Posts: 17

    But my databases server is different and it's not embedded server will DB tool still works for databases outside parasoft?

  • williammccusker
    williammccusker Posts: 640 ✭✭✭

    Hi,

    What type of database are you connecting to? The DB tool supports many different database types based on using their JDBC drivers. From the screenshot, it appears that a "Database Correlation" data source is being used. Both the data source and the DB tool connect to SQL databases using JDBC so if the data source can connect to the database I would expect the DB tool can too.

    Here is the documentation on the DB Tool
    https://docs.parasoft.com/display/VIRT20222/DB

  • Sindhu
    Sindhu Posts: 17

    Thank you DB tool it worked