0

Here is the top part of my Package Body method:

PROCEDURE GetPortfolioAppsAndProjects
(
   loginId          IN VARCHAR2 := NULL,
   portfolioId      IN NUMBER := NULL,
   portfolioType    IN VARCHAR := NULL,
   ic               IN VARCHAR := NULL,
   AppIds_CUR       IN OUT SYS_REFCURSOR
) 
IS
  INVALID_PORTFOLIO_TYPE EXCEPTION;
BEGIN

This runs fine when I execute from the PL/SQL execute dialogue. I need to be able to run this from an SQL Query window though and join to other tables and what not to develop.

I'm trying to execute this sql from the Sql Window:

DECLARE AppIds_CUR SYS_REFCURSOR;
BEGIN
   IREPORT_PORTFOLIOS.GetPortfolioAppsAndProjects('EVANSF', null, null,    null, :AppIds_CUR);
END;

And I get this error:

PLS-00306: wrong number or types of arguments in call to 'GETPORTFOLIOAPPSANDPROJECTS'

I count 5 incoming (including one IN OUT cursor). In my call I pass 5 including the cursor. How can I get the results of the cursor to the output vars window.

4

1 回答 1

1

AppIds_CUR在您的块中本地声明;您不需要通过在冒号前面添加将其视为绑定变量:

DECLARE
  AppIds_CUR SYS_REFCURSOR;
BEGIN
   IREPORT_PORTFOLIOS.GetPortfolioAppsAndProjects('EVANSF', null, null, null, AppIds_CUR);
END;

如果您在 SQL Developer 中运行您作为语句的内容,它会提示您输入绑定值,这不是您想要发生的,并且会将其视为 varchar 而不是 ref 游标 - 因此会出现错误类型错误。

您需要dbms_output使用这种方法遍历光标并手动显示它的值。但是,如果您将其作为脚本运行,则可以通过声明类型来使用绑定变量 - 这将在块之外,因此您不需要declare

variable AppIds_CUR REFCURSOR;

BEGIN
   IREPORT_PORTFOLIOS.GetPortfolioAppsAndProjects('EVANSF', null, null, null, :AppIds_CUR);
END;
/

print AppIds_CUR

您可以使用 SQL Developerprint命令显示光标内容。

于 2015-09-03T17:02:39.923 回答