Oracle程序更新一行并返回其密钥?

时间:2016-05-25 19:44:50

标签: oracle plsql

似乎这应该很容易,但语法不适合我。我正在尝试更新现有的行 - 我发现的第一行是'新'。然后我想返回一个带有键和其他两个值的分隔字符串:

create or replace procedure usp_direct_print_task_deque 
(
  taskNa in char
 ,environmentCd in char
) as 
begin
  declare rowkey number;

  select '~' || rowversion || '~' || target_document || '~' || target_printer 
   as delimited_data
   , rowversion 
  from AFD1.bt_direct_print_tasks
  where environment_cd = environmentCd 
   and task_na = taskNa  
   and task_status = 'new'
   and rownum = 1;

  update bt_direct_print_tasks
  set taskStatus = 'processing'
  where rowversion = rowkey;

  return delimited_data;  

end usp_direct_print_task_deque;

1 个答案:

答案 0 :(得分:1)

您需要定义OUT参数变量,例如x_delimited_datax_rowkey,以分别保存delimited_datarowkey的值。然后将SELECT更改为SELECT... INTO x_delimited_data, x_rowkey。 (我假设rowkey是您选择的rowversion)。然后将return delimited_data;更改为return;