Skip to Main Content
  • Questions
  • Oracale procedure execution is giving an error

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Jay.

Asked: March 07, 2018 - 11:32 pm UTC

Last updated: March 08, 2018 - 6:25 am UTC

Version: 12.1

Viewed 1000+ times

You Asked

I have a stored procedure in oracle. Whenever i try to execute it its throwing me an error mentioned below: Error starting at line 5 in command: exec usp_eventmgmt_get_events(TO_DATE('2018-07-18', 'YYYY-MM-DD'),'District',1) *Error report: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'USP_EVENTMGMT_GET_EVENTS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. Action:

CREATE OR REPLACE PROCEDURE "EGISINSPTEST"."USP_EVENTMGMT_GET_EVENTS"
(
    end_date date,
    heirarchy_type varchar2,
    heirarchy_key int,
  eventCursor OUT SYS_REFCURSOR
)
AS
BEGIN
IF heirarchy_type = 'abc' THEN
  OPEN eventCursor FOR
    SELECT rownum AS "id", es.* FROM
      (SELECT 

        DueDateUnformatted as DueDate, 
        Priority,
        ComplianceDate, 
        AssignmentName,
        count(EventKey) as Total
      FROM  view_viename1
      WHERE DueDateUnformatted < (end_date + 1) and parentEventKey is null and inspectiondate is null and DistrictKey=heirarchy_key
      Group By  DueDateUnformatted, Priority, ComplianceDate, AssignmentName) es;
      --dbms_output.put_line('Output 1');
ELSE IF heirarchy_type = 'def' THEN
  OPEN eventCursor FOR
    SELECT rownum AS "id", es.* FROM
      (SELECT 

      DueDateUnformatted as DueDate, 
      Priority,
      ComplianceDate, 
      AssignmentName,
      count(EventKey) as Total
      FROM  view_viename1
      WHERE DueDateUnformatted < (end_date + 1) and parentEventKey is null and inspectiondate is null and DivisionKey=heirarchy_key
      Group By  DueDateUnformatted, Priority, ComplianceDate, AssignmentName) es;
      --dbms_output.put_line('Output 2');
ELSE IF heirarchy_type = 'hij' THEN
  OPEN eventCursor FOR
    SELECT rownum AS "id", es.* FROM
      (SELECT 

      DueDateUnformatted as DueDate, 
      Priority,
      ComplianceDate, 
      AssignmentName,
      count(EventKey) as Total
      FROM  view_viename1
      WHERE DueDateUnformatted < (end_date + 1) and parentEventKey is null and inspectiondate is null and CompanyKey=heirarchy_key
      Group By  DueDateUnformatted, Priority, ComplianceDate, AssignmentName) es;    
      --dbms_output.put_line('Output 3');
END IF;
END IF;
END IF;
END;

and Connor said...

As the error suggests

"wrong number or types of arguments in call"

The routine is expecting 3 input parameter, plus 1 output parameter.

SQL> CREATE OR REPLACE PROCEDURE USP_EVENTMGMT_GET_EVENTS
  2  (
  3      end_date date,
  4      heirarchy_type varchar2,
  5      heirarchy_key int,
  6    eventCursor OUT SYS_REFCURSOR
  7  ) is
  8  begin
  9    open eventCursor for
 10      select count(*) c
 11      from  all_objects
 12      where object_type = heirarchy_type
 13      and  created > end_date;
 14  end;
 15  /

Procedure created.

SQL>
SQL> exec USP_EVENTMGMT_GET_EVENTS(sysdate,'TABLE',1);
BEGIN USP_EVENTMGMT_GET_EVENTS(sysdate,'TABLE',1); END;

      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'USP_EVENTMGMT_GET_EVENTS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


SQL>
SQL> variable rc refcursor
SQL> exec USP_EVENTMGMT_GET_EVENTS(sysdate,'TABLE', 1, :rc);

PL/SQL procedure successfully completed.

SQL> print rc

         C
----------
         0

1 row selected.


So you need a "receiving" variable to hold that ref cursor output.



Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library