Is there any way I can concatenate to a select a query according to a condition? for example in I have a procedure in which I will receive N input parameters, the query I have it ready but since they are filters not all parameters will come with a value (a code is received, date from and date until), the problem is that in the select that I have so that I can bring the data I must put the values to all the parameters, my question is I can concatenate it by means of an IF if for example the code is full, I append to that select that value and execute ?, so that Have an idea, in java using stringQueryBuilder and the IF condition, can I add to the query using .append the condition of 'and date_from =?', is there any form in PL or do they have any suggestions?
here the query
SELECT ORDER_SCHEDULE_NO, S.SUPPLIER, S.SUP_NAME, TO_CHAR (ORDER_DATE, 'DD / MM / YYYY HH24: MI: SS'), TO_CHAR (ORDER_CREATE_DATE, 'DD / MM / YYYY HH24: MI: SS') FROM ORDER_SCHEDULE OS, SUPS S WHERE S.SUPPLIER =: SUPPLIER AND TRUNC (order_date) > = TO_DATE (: DATES, 'DD / MM / YYYY hh24: mi: ss') AND TRUNC (order_date) < = TO_DATE (: DATEHASTA, 'DD / MM / YYYY hh24: mi: ss') AND S.SUPPLIER = OS.SUPPLIER ORDER BY ORDER_DATE