Skip to content
Advertisement

getting different results from the same query according to the value of a variable

suppose we have the following masterdata:

and we have the order tables:

what is requested is to have one single query that could return 2 different sets of data, according to the value of a given variable v_order_status:

  • v_order_status = 'del' then only transport orders is retrieved:

  • v_order_status =any other value or null then we retrieve the whole table.

the desired SQL statement is to be used within a stored procedure, something like:

any ideas how to set the where clause in the SQL statement?

Advertisement

Answer

Use boolean logic:

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