Binding Data (bind variables)

In a SQL command, you can use a bind variable to represent the value of a column. A bind variable in a SQL command indicates that data will be bound to (associated with) the command each time the command executes. A bind variable in a SQL command must be associated (bound) to a random variable defined in the random variables section or to a global variable of the Silk Performer test script. The bind variable name begins with a colon (:) and is followed by the name of the random variable or global variable associated with it.

Example

var
  v1, v_price : number;

dclrand
  r1 : RndSno(1);
  r2 : RndInd("trousers"  = 0.3; "jackets" = 0.1;
              "pullovers" = 0.1; "shirts" = 0.1;
              "stockings" = 0.1; "skirts" = 0.1;
              "gloves"    = 0.2);
  r3 : RndStr(10..40);
  r4 : RndExpN(10..5000:500.0);
  r5 : RndUniN(1..500);
  r6 : RndUniN(10..50);

dcltrans
  transaction TMain
  begin
    ...
    c1: InsArticle(
    ...
    price := r4;
    g1 := r5;
    c1: UpdArticle();
    ...
  end TMain;

dclsql
  InsArticle:
    INSERT INTO article(articlenumber, articlegroup,
                        articlename, price, stock, quantity)
    VALUES(:r1, :r2, :r3, :r4, 20, 100);

  UpdArticle:
    UPDATE article
    SET price = :v_price * 0.9, quantity = :r6
    WHERE articlenumber = :g1;