Question

am creating a package in pl/sql . with in this i declared the ref cursor . With in procedure am using select statement with multiple column name . but am not able to get the result. here i attached my code. Help me to correct the error. Am new to pl/sql

code

CREATE OR REPLACE PACKAGE types AS 
  TYPE cursor_type IS REF CURSOR;
END Types; 
/

CREATE OR REPLACE
PROCEDURE get_CDR_rs (p_no    IN  zkv.FLD_callingPartyNumber%TYPE,
                  CDR_recordset OUT SYS_REFCURSOR) AS 
BEGIN 
 OPEN CDR_recordset FOR
SELECT  FLD_callingPartyNumber,
       FLD_dateTimeConnect

FROM   CISCOCUIC_TBL
WHERE  FLD_callingPartyNumber= p_no
ORDER BY FLD_callingPartyNumber,;
END get_CDR_rs;
/



SET SERVEROUTPUT ON SIZE 1000000
DECLARE
  l_cursor  SYS_REFCURSOR;
  l_callingPartyNumber   zkv.FLD_callingPartyNumber%TYPE;
  l_dateTimeConnect  zkv.FLD_dateTimeConnect%TYPE;
BEGIN

LOOP 
FETCH l_cursor
INTO  l_callingPartyNumber, l_dateTimeConnect;
EXIT WHEN l_cursor%NOTFOUND;

END LOOP;
CLOSE l_cursor;
END;
/


Error

9/41    PL/SQL: ORA-00936: missing expression
5/5     PL/SQL: SQL Statement ignored
Was it helpful?

Solution

First thing is there is a syntax error in the procedure. It should be

CREATE OR REPLACE
PROCEDURE get_CDR_rs (p_no    IN  zkv.FLD_callingPartyNumber%TYPE,
                  CDR_recordset OUT SYS_REFCURSOR) AS 
BEGIN 
 OPEN CDR_recordset FOR
SELECT  FLD_callingPartyNumber,
       FLD_dateTimeConnect

FROM   CISCOCUIC_TBL
WHERE  FLD_callingPartyNumber= p_no
ORDER BY FLD_callingPartyNumber; -- there was a comma which is not required or you    
--   missed a column
END get_CDR_rs;
/

Secondly where is get_CDR_rs being called to retrieve the results?

Thirdly why do you need the following? because you are using sys_refcursor

CREATE OR REPLACE PACKAGE types AS 
  TYPE cursor_type IS REF CURSOR;
END Types; 
/

If you would like to see the results of your procedure which returns sys_refcursor, do as follows

variable rset refcursor;

DECLARE
  p_no  zkv.FLD_callingPartyNumber%TYPE;
BEGIN
  p_no := '123';
  get_CDR_rs (p_no, :rset);  
END;
/

print rset
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top