从oracle sys_refcursor函数返回完整行

时间:2019-01-24 13:54:12

标签: sql oracle function

我有这个功能:

create function get_next_unlocked_id
  return varchar2
is
  cRefCursor sys_refcursor;
  rRecord    MESSAGES%rowtype;
begin
  -- open cursor. No locks so far
  open cRefCursor for 'Select s.guid,
       s.message_id,
       s.status,
       ...
       s.last_answer_date,
       s.response_message_id
from messages s,
     providers bp,
     groups bg
where status = ''SENT''
  and s.real_bsp_guid = bp.guid
  and bp.bsp_group_id = bg.guid
  and bg.guid = ''123''
order by insert_date for
  update of s.GUID skip locked';

  -- we fetch and lock at the same time one record
  fetch cRefCursor into rRecord;

  -- close cursor
  close cRefCursor;

  -- return ID or any other attribute(s)
  return rRecord.GUID;

end;

它有效。但是我需要返回full row而不是返回GUID。表有许多列。我应该列出所有这些(〜30)还是让我更容易?

0 个答案:

没有答案
相关问题