Dynamic changes of where query conditions

Encounter a requirement (oracle database): a parameter is sent from the front desk. If the parameter is not empty, the query condition includes the query condition: field = parameter value, if the parameter is empty, there is no query condition.

At first I thought of using decode, where docode(:p, null, 1=1, field=:p), which is not supported by oracle. Similarly case is not supported.
Later, Daniel in the Q group gave a writing method: where (:p is null or field=:p) . Understand that does meet the requirements. Writing is true 6. . .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326120191&siteId=291194637