Skip to content
Advertisement

How to generate the dynamic where condition in pl/sql cursor

Generate the dynamic where condition in pl/sql cursor based on input values

For Example :

Input Values : a b c values

Query Format :

Advertisement

Answer

This is how I understood the problem; no dynamic stuff is necessary.

For simpler testing (on my side, as I don’t have your tables), on Scott’s DEPT table, this might do the job (par_x is name of procedure’s parameter).

If those are different columns, no problem either:

If certain parameter isn’t passed and you don’t want to see that column’s value, then use

If you want to exclude the column from result set, well, that isn’t that simple. If you used (for example) Oracle Apex, you could choose not to render that column. Otherwise, in pure SQL, I wouldn’t know how to do that.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement