SQL Section

The SQL commands that are called by the transactions are defined in the SQL section. They present the reusable component of the Silk Performer program. The SQL commands should already exhibit the form in which they will be used in the transaction of the application program.

Silk Performer supports stored procedures in test scripts. The syntax of defining a stored procedure in the SQL section is very similar to defining a SQL command.

The SQL section is defined using the keyword sql.

Syntax

SqlSection = SqlStatement ";" { SqlStatement ";" }.

SQLStatement = ( ident ":" SqlCommand )
             | ( ident "(" "proc" ")" ":" SqlProcedure ).

An SQL section can contain several definitions of SQL commands or stored procedures (SqlStatement). ident is the name of the SQL command (stored procedure) you are using when calling the SQL command in a transaction. SQLCommand is the current SQL statement in SQL syntax of your DBMS. Each SQL statement must be a valid SQL statement of your DBMS.

SqlProcedure describes the calling conventions for Stored Database Procedures that you want to use in your Silk Performer script. The syntax for calling a stored procedure in a transaction is the same as the syntax for calling a SQL command. You do not write the stored procedure directly in your Silk Performer program; instead you define a call to the stored procedure using ODBC syntax in your SQL section.

The following example shows a portion of a Silk Performer program for simulating a workload. Two random variables (randvar1 and randvar2) with two different random functions (RndUniN and RndStr) are defined in the random variables section. Two users (usr1 and usr2) are defined in the workload section. During a simulation time slice of 3600 seconds, usr1 calls the transaction Selling 100 times and the transaction Order 10 times. usr2 calls the transaction StockQuery 20 times during a simulation time slice of 2000 seconds.

Example

dclrand
  randvar1: RndUniN(1..1000);
  randvar2: RndStr("abcde1234"; 10..20);

dcluser
  user
    usr1
  transactions
    Selling : 100;
    Order   : 10;
  
  user 
    User2 
  transactions 
    TStockQuery : 20;

The transactions Selling, Order and StockQuery are defined in the transactions section of the Silk Performer program. The transaction Selling calls the SQL command SelArticle and InsSale to access the test database of the application system to be simulated. A transaction can bind a global variable or a random variable to a SQL command (:v_artno). R values of the SQL command can be passed on to other SQL commands (into :v_name,:v_price,:v_agr).

Example

var
  I, v_artno, v_price : number;
  v_name, v_agr       : string;

dcltrans
  transaction TSelling
  begin
    ...
    for I := 1 to 5 do
      artno := randvar1;
      c1: SelArticle();
      c2: InsSale(...);
    end;
  end TSelling;

  transaction TOrder
  begin
    ...
  end TOrder;

  transaction TStockQuery
  begin
    ...
  end TStockQuery

The SQL commands used by the transactions SelArticle and InsSale are defined in the SQL section. Global variables (v_artno, v_name, v_agr and v_price) and random variables can be used in SQL text as bind variables (with a preceding ":").

Example

dclsql
  SelArticle:
    SELECT article_name, price, article_group
    INTO :v_name, :v_price , :v_agr
    FROM article WHERE artno = :v_artno;
    InsSale(...):
    ...