DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Help with Pakage Body!

  1. #1
    Join Date
    Jun 2004
    Posts
    125

    Thumbs up Help with Pakage Body!

    Hi,

    I am trying to write a package that returns a refcursor. I am getting error in my pakage body.

    This is my pakage specs and body:

    Code:
    CREATE OR REPLACE PACKAGE SPKG_COMM_BOL IS
    Type Comm_bol_qry IS RECORD (
    account_num	bol_issued.account_num%TYPE
    ,bol_num        bol_issued.bol_num%Type
    ,date_issued  	bol_issued.date_issued%Type
    ,reg_num	bol_issued.reg_num%Type
    ,receivedyn	bol_issued.receivedyn%Type
    ,bol_type	bol_issued.bol_type%Type
    ,remarks	bol_issued.remarks%Type
    );
    
    TYPE rec_commbol_qry is REF CURSOR RETURN Comm_bol_qry;
    
    PROCEDURE sp_comm_bol_query(ioref_queryset IN OUT rec_commbol_qry);
    
    END SPKG_COMM_BOL;
    
    CREATE OR REPLACE PACKAGE BODY SPKG_COMM_BOL IS
    
    PROCEDURE sp_comm_bol_query(ioref_queryset IN OUT rec_commbol_qry) IS
    
    
    V_BOL	  SHIPMENT.GBL_TO%TYPE;
    V_ACCT    BOL_ISSUED.ACCOUNT_NUM%TYPE;
    PART_GBL  VARCHAR2(10);
    
    POS_1       	PLS_INTEGER;
    POS_2       	PLS_INTEGER;
    
    CUROR GET_BOL IS
    SELECT ACCOUNT_NUM
    FROM BOL_ISSUED;
    
    CURSOR GET_GBL IS
    SELECT GBL_TO
    FROM SHIPMENT
    WHERE SHIPMENT_CODE = 'CO';
    
    BEGIN
    
      FOR CUR_BOL IN GET_BOL
      LOOP
    	POS_1 := 0;
    	POS_2 := 0;
        BOL_TYPE_FLAG := NULL;
      
        FOR CUR_GBL IN GET_GBL
        LOOP
    	SELECT INSTR(CUR_GBL.GBL_TO, 'M') INTO POS_1 FROM DUAL;
    	 IF POS_1 > 0 THEN
    	  SELECT SUBSTR(CUR_GBL.GBL_TO,INSTR(CUR_GBL.GBL_TO,'M')+1, LENGTH(CUR_GBL.GBL_TO)) INTO PART_GBL FROM DUAL;
    	 ELSE
               SELECT SUBSTR(CUR_GBL.GBL_TO,INSTR(CUR_GBL.GBL_TO,'-')+1, LENGTH(CUR_GBL.GBL_TO)) INTO PART_GBL FROM DUAL;
    	 END IF;
    	
      	OPEN ioref_queryset FOR
        	SELECT B.ACCOUNT_NUM, B.BOL_NUM, B.DATE_ISSUED, S.REG_NUM, B.RECEIVEDYN, B.BOL_TYPE, B.REMARKS
        	FROM BOL_ISSUED B, SHIPMENT S
        	WHERE TO_CHAR(BOL_NUM) = PART_GBL
        	AND ACCOUNT_NUM = CUR_BOL.ACCOUNT_NUM
        	AND TO_CHAR(BOL_NUM) = SUBSTR(S.GBL_TO, -POS_1) 
        	AND S.SHIPMENT_CODE = 'CO'
        	UNION ALL
        	SELECT ACCOUNT_NUM, BOL_NUM, DATE_ISSUED, REG_NUM, RECEIVEDYN, BOL_TYPE, REMARKS
        	FROM BOL_ISSUED
        	WHERE TO_CHAR(BOL_NUM) <> PART_GBL
        	AND ACCOUNT_NUM = CUR_BOL.ACCOUNT_NUM;
        END LOOP;
      END LOOP;
    END sp_comm_bol_query;
    
    ERROR:
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    13/15    PLS-00103: Encountered the symbol "SELECT" when expecting one of
             the following:
             := . ( @ % ; not null range default character
    
    54/0     PLS-00103: Encountered the symbol "end-of-file" when expecting
             one of the following:
             begin function package pragma procedure form
    I would really appreciate any help. I have also looked for the error but I am not sure if I am allowed to write cursors like this. Please help! Thanks.

  2. #2
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    159
    There is a typo in "CUROR GET_BOL" - it's missing an "s".

    btw I find "c_" makes a more meaningful prefix for cursor names than "get_" - it's shorter, and they don't really "get" anything anyway

  3. #3
    Join Date
    Jun 2004
    Posts
    125
    thanks. I spotted the typo and I'll use the prefix. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width