return a default row in sql
For complex queries where the overhead on finding out if there is a row in the result set is onerous or the query is just very large and unwieldy, then a subquery factoring clause might be beneficial:
With my_query as ( select a, b, c from foobar where foo='FOO' )Select a,b,cFrom my_queryUnion AllSelect ...From dualWhere Not Exists (Select 1 from my_query)/
I suspect that it would be cleaner to have the process that the writes the ASCII file write the default data if no rows are returned rather than getting Oracle to do it. If the query that you're using is expensive, you'd significantly increase that cost if you fudge it to return a default row as ammoQ and David Oniell have done.