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';
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot