Updated on 2022-09-01 GMT+08:00

Using Optional Parameters

In a data API, the square brackets ([]) are used to mark optional parameters. An example SQL statement is as follows:

select * from table01 where id=${id} [or sex='${sex}']

The statement enclosed in square brackets ([]) indicates that the parameter takes effect only when the backend request carries the ${sex} parameter. If ${sex} is not carried, the statement enclosed in [] is ignored during execution.

  • If the backend request carries the id=88 parameter but does not carry the optional parameter sex, run the following SQL statement:
    select * from table01 where id=88;
  • If the backend request carries both id=88 and sex=female, run the following SQL statement:
    select * from table01 where id=88 or sex='female';