home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle.server      Oracle Sysadmins question their careers      44,300 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 42,640 of 44,300   
   "Michel Cadot"    
   Re: Returning a REF cursor   
   02 Aug 16 21:36:18   
   
    a écrit dans le message de news: bbbe29   
   a-a04a-4650-846f-2ce9aa05fa51@googlegroups.com...   
   | Something like this:   
   |   
   | CREATE OR REPLACE PACKAGE test_package AS   
   |   
   | TYPE ref_crs IS REF CURSOR;   
   |   
   | PROCEDURE test_procedure (   
   |  p_score     NUMBER,   
   |  p_email     VARCHAR2,   
   |  p_address   VARCHAR2   
   |  p_data  OUT REF_CRS);   
   |   
   | END test_package;   
   | /   
   |   
   | Package created.   
   |   
   | CREATE OR REPLACE PACKAGE BODY test_package AS   
   |   
   | PROCEDURE test_procedure (   
   |  p_score     NUMBER,   
   |  p_email     VARCHAR2,   
   |  p_address   VARCHAR2   
   |  p_data  OUT REF_CRS) AS   
   |   
   | BEGIN   
   |  OPEN p_data FOR   
   |    SELECT email FROM emails WHERE score = p_score;   
   | END test_procedure;   
   |   
   | END test_package;   
   | /   
   |   
   |   
   | Then to call it:   
   |   
   | var data refcursor;   
   |   
   | exec test_package.test_procedure (   
   |  p_score => 5,   
   |  p_data  => :data);   
   |   
   | BEGIN test_package.test_procedure (; END;   
   |                                   *   
   | ERROR at line 1:   
   | ORA-06550: line 1, column 36:   
   | PLS-00103: Encountered the symbol ";" when expecting one of the following:   
   | ( ) - + case mod new not null    
   |   
   |   
   | Any thoughts on this one?   
   |   
   | Thanks!!   
      
   EXEC is a one line SQL*Plus short cut for BEGIN/END.   
   Either use BEGIN/END or - line continuation character.   
      
   SQL> var data refcursor;   
   SQL>   
   SQL> BEGIN   
     2  test_package.test_procedure (   
     3    p_score => 5,   
     4    p_data  => :data);   
     5   
     6  END;   
     7  /   
      
   PL/SQL procedure successfully completed.   
      
   SQL> exec test_package.test_procedure ( -   
   >   p_score => 5,  -   
   > p_data  => :data);   
      
   PL/SQL procedure successfully completed.   
      
   Regards   
   Michel   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca