Parameterizing Static Values in SQLs

When recording an installable cloud app to create the script, you would use static values for SQL statements (Retrieve, Select, etc.). It is not realistic to use the same value for all replays. Therefore, it is necessary to parameterize the static values.

How to parameterize static values in Retrieve

  1. Find the static value in the Retrieve request body. You shall get it in the “arguments” node.

  2. Select the value, right click and select “Replace with Parameter” -> “Create new parameter”.

  3. Enter the parameter name.

    In the example script below, the “customer_id” static value has been parameterized with the parameter <customerID>:

    web_custom_request("RetrieveWithParm",
          "URL=http://192.168.178.125:5001/api/ServerApi/RetrieveWithParm",
          "Method=POST",
          "Resource=0",
          "RecContentType=application/json",
          "Referer=",
          "Snapshot=t144.inf",
          "Mode=HTTP",
          "EncType=application/json;charset=UTF-8",
          "Body={\"version\":\"1.0\",\"requestid\":\"50CA839C-E8DF-4303-A146-33EBB30BEB45\",\"appname\":\
                "psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"""<gs_SessionID>\",\
                "type\":1,\"transaction\":{\"transactionid\":\"""<gs_TransactionID>\"},\"content\":{\"retrieves\":
                [{\"retrieveid\":\"50CA839C-E8DF-4303-A146-33EBB30BEB45\",\"parent\":\"\",\"dataobject\":
                \"d_customer_pro\",\"""parentcolumn\":\"\",\"isreport\":false,\"isdynamic\":false,\"dwsyntax\":\"\",
                \"sql\":\"\",\"processing\":1,\"arguments\":[{\"category\":1,\"name\":\"customer_id\",\"""type\":
                \"number\",\"value\":<customerID>}]}]}}",
          LAST);

How to parameterize static values in Select

  1. Find the static value in the Select request body. You shall get it in the “parameters” node.

  2. Select a value in the list of parameters, right click and select “Replace with Parameter” -> “Create new parameter”.

  3. Enter the parameter name.

  4. Repeat step 2 to 3 until all values are parameterized

    In the example script below, the Select request has been parameterized with the parameters <customerID> and <NotName>:

    web_custom_request("SelectWithParm",
          "URL=http://192.168.178.125:5001/api/ServerApi/SelectWithParm",
          "Method=POST",
          "Resource=0",
          "RecContentType=application/json",
          "Referer=",
          "Snapshot=t358.inf",
          "Mode=HTTP",
          "EncType=application/json;charset=UTF-8",
          "Body={\"version\":\"1.0\",\"requestid\":\"7C362898-230B-4858-AB15-2241DC3FD982\",\"appname\":
                \"psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"""<gs_SessionID>\",
                \"type\":11,\"transaction\":{\"transactionid\":\"""<gs_TransactionID>\",\"transactionname\":
                \"sqlca\"},\"content\":{\"esqlselect\":{\"modulename\":\"\",\"sqlid\":\"sqlHandle_01_2763E2FE\",
                \"parameters\""":[{\"category\":1,\"name\":\"name\",\"type\":\"int\",\"value\":<customerID>},
                {\"category\":1,\"name\":\"name\",\"type\":\"string\",\"value\":\"<NotName>\"}]}}}",
          LAST);