Oracle: Get a query to always return exactly one row, even when there's no data to be found

前端 未结 6 1722
余生分开走
余生分开走 2021-01-18 01:17

I have a query like this:

   select data_name
   into v_name
   from data_table
   where data_table.type = v_t_id

Normally, this query shou

6条回答
  •  佛祖请我去吃肉
    2021-01-18 01:54

    https://stackoverflow.com/a/4683045/471149 answer is nice, but there is shorter solution

    select * from my_table ce, (select 150 as id from dual) d
    where d.id = ce.entry_id (+)
    

提交回复
热议问题