0
create or replace package XXX_MWA_LOV_TEST AS
    TYPE t_ref_csr IS REF CURSOR;
    PROCEDURE XXX_USERS_LOV (p_user_name IN VARCHAR2,x_users OUT NOCOPY t_ref_csr);
end XXX_MWA_LOV_TEST;

如何XXX_USERS_LOV在 SQL*Plus 中运行程序?

我尝试了这段代码,但得到了语法错误:

SQL> EXECUTE XXX_MWA_LOV_TEST.XXX_USERS_LOV('%',:my_p_out);

程序主体:

create or replace package body XXX_MWA_LOV_TEST AS
  PROCEDURE XXX_USERS_LOV (x_users OUT NOCOPY t_ref_csr,p_user_name IN VARCHAR2) IS
  BEGIN
    OPEN x_users FOR select user_id,user_name,description 
      from fnd_user
      where user_name like p_user_name;
    DBMS_OUTPUT.PUT_LINE('TESTING DATA');
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR IN USER LOV '|| SQLERRM);
  END XXX_USERS_LOV;

end XXX_MWA_LOV_TEST;
4

1 回答 1

0

首先,参数的顺序在规范和包体中必须一致。

您可以像这样调用 ref 游标:

 declare 
   v_cursor xxx_mwa_lov_test.t_ref_csr;
   var1 the_type_you_need;
   var2 the_type_you_need;
   ...
 begin
   xxx_mwa_lov_test.xxx_users_lov(v_cursor,'username...');

   loop
      fetch v_cursor into var1, var2...;
      exit when v_cursor%notfound;
      ... do what you want with the vars...
   end loop;
end;
/
于 2013-05-23T08:28:07.320 回答