1
I have a condition, like this one below, in a query.
If you receive the empty parameter or with 0, I would like this condition to cease to exist, or be nullified, so that the query search for all doctors.
where CD_MEDICO_CIRURGIAO = :medico
How to do?
Would you have an example of this check, to see if the :doctor parameter receives values? The other way you quoted below I could not, because it always brings all the values, and is not what I wish.
– Rodrigo Segatto
Isn’t that what you wanted? if :doctor is empty bring all doctors? This code will bring all doctors. Post your code that gives to improve the example.
– Adir Kuhn
select NR_CIRURGIA from surgery Where CD_MEDICO_CIRURGIAO = :doctor
– Rodrigo Segatto
What language are you using? Post the code that will generate this output because it doesn’t look like pure PL/SQL. Another thing which database you are using?
– Adir Kuhn
This is pl sql yes. E :medico is a parameter passed when you run the code. If I pass as a parameter a doctor’s code will correctly return the values corresponding to the code. What I need, is in case this parameter comes empty, this condition ceases to exist, to fetch all values.
– Rodrigo Segatto
Which database? Oracle?
– Adir Kuhn
oracle database
– Rodrigo Segatto
Just to be sure, hehehe. I modified the answer.
– Adir Kuhn
Works well, thank you very much :D
– Rodrigo Segatto