Modifying Scripts

Parameterize scripts of SessionID:

  1. Use the keyword "servlet" to search in the scripts, and add the following scripts to the line previous to the line where the second "servlet" appears, so as to capture the current SessionID.

    web_reg_save_param("SessionID","LB=ID =","RB=\r\n",LAST);
  2. Search all the remaining "servlet" statements, and modify the parameters starting with "Body=" in the following way:

    Find the location of "session_id =", and replace the recorded value of SessionID with the character string "{SessionID}", for example,

    Replace

    "session_id = -318005152\r\n" 

    with

    "session_id = {SessionID}\r\n"

    The following block ({SessionID} in "session_id = {SessionID}\r\n") is an example after changed.

    web_custom_request("appeon.weblibrary.AXDispatcher_6",
    "URL=http://172.17.1.108:8080/servlet/appeon.weblibrary.AXDispatcher",
    "Method=POST",
    "Resource=1",
    "Referer=",
    "EncType=",
    "Body="
    "\\x1F\\x8B\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\x0B"
    "ST"
    "\\x16"
    "b0a0"
    "\\x06"
    "b"
    "\\x0B\\x06"
    "K"
    "\\x06"
    "C"
    "\\x06"
    "3"
    "\\x06"
    "#"
    "\\x06"
    "S"
    "\\x06"
    "1"
    "\\x86\\x00"
    "†T"
    "\\x86"
    "\""
    "\\x86"
    "4†| ™ËÈÇ"
    "\\x90\\x0C\\x14\\x01\\x01"
    "1 fb"
    "\\x00\\x00\\x12\\x02"
    "½8"
    "\\x00\\x00\\x00"
    "--------------------appeon data\r\n"
    "Name = Kill Session\r\n"
    "session_id = {SessionID}\r\n"
    "--------------------appeon data\r\n"
    "D"
    "\\x00\\x00\\x00"
    ,
    LAST);

Additional steps for the Update operation

For the Update operation, the script parameterization should meet the following three requirements:

  1. Parameterization of SessionID (which has already been described in Modifying Scripts);

  2. Parameterization of SQL statements (which will be described in Parameterization of DataWindow SQL statements and in Parameterization of Embedded SQL statements);

  3. Add the Commit request to the end of each Update request, that is, move the Commit request in the recorded scripts from end.c to action.c.

Parameterization of DataWindow SQL statements

  1. The recorded DataWindow SQL statements are as follows:

    "UpDateSQL_1 = update \"PERF_TEST1\" set \"depid\" = 
    1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" = 0;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.843',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 1;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 2;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" = 3;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" 
    = 'modify1',\"born\" = '2006-09-04 14:35:12.843',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 4;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 5;update \"PERF_TEST1\" set \"depi" 
    "d\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.859',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 6;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 7;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 8;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.859',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 9\r\n"
    1. To make the field value change every time the same user executes it, you need to parameterize the constant after the field: "modify1" in the above example.

    2. To ensure that different virtual users modify different records, you need to parameterize the id value after the "Where" keyword.

    For these purposes, at least two parameters should be set: "Modified" and "ID".

    To parameterize fields of the number type and the data type, it is also necessary to set the new parameters.

    In this example, the type of parameter "Modified" is iteration number, and the type of parameter "id" is UserID.

  2. In the scripts, for most field values, you must perform the following two replacements in the DataWindow SQL statements.

    1. Replace "modify1" with "{modified}"

    2. Replace "where \"id\" = " (Note: In this example, the last character included in the quotation mark must be a space) with "where \"id\" = {id}"

    If the text to be replaced is split and displayed in two lines, for example, "modify1" is displayed as "modif" and "y1" in two separated lines, you need to manually modify or programmatically replace it, otherwise transaction failures will occur when there are many concurrent user access.

    Make sure that every SQL statement is correctly replaced.

    ………………………………,\"col8\" = '{modified}',\"col9\" = 'modif"
    "y1',\"col10\" = 'modify1' where \"id\" = {id}06;………………………
  3. The parameterized SQL statements are as follows:

    "UpDateSQL_1 = update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}0;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}1;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}2;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}3;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}4;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}5;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}6;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}7;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.890',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}8;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.890',\"age\" = 1,\"salary\" = 1 where \"id\" = {id}9\r\n"
  4. When playing back the scripts after replacement, the DataWindow SQL statements executed are as follows:

    UpDateSQL_1 = update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    10;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    11;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    12;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    13;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    14;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    15;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    16;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    17;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 
    18;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 19
  5. In the iterative operations, the DataWindow SQL statements executed at the third time are as follows:

    UpDateSQL_1 = update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    10;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    11;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    12;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    13;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    14;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    15;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    16;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    17;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 
    18;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 19

    In this way, the value changes every time the same user executes an Update operation.

Parameterization of Embedded SQL statements

To parameterize the value in the embedded SQL statement, you will have to define the value as a variable.

For example, the following script cannot be parameterized.

select a from table where c = ‘1’;

You will have to modify the script as below, in order to parameterize the value:

int ic
ic = 1
select a from table where c= :ic