How can i call a Oracle Function which return value is user defined record? SOS !!!!!

Last post 05-30-2008 11:07 AM by greg.darling. 3 replies.

Sort Posts:

  • How can i call a Oracle Function which return value is user defined record? SOS !!!!!

    05-30-2008, 2:21 AM
    • Member
      point Member
    • suhua
    • Member since 05-30-2008, 6:10 AM
    • China
    • Posts 2

    Package and Function:

    SPEC

    CREATE OR REPLACE PACKAGE PACKAGE_SUHUATEST AS
    type resp is record

    (resp_key varchar(30),

    app_name varchar2(15));

    type resp_tab is table of resp INDEX BY BINARY_INTEGER;


    FUNCTION MyFunction(invar in varchar) return resp_tab ;
     

    END PACKAGE_SUHUATEST;
    /

     

    BODY

    CREATE OR REPLACE PACKAGE BODY MVL_SOX.PACKAGE_SUHUATEST AS


      FUNCTION MyFunction(invar in varchar) return resp_tab  IS
      record1 resp;
      record2  resp;
      allresult resp_tab;
      BEGIN
        record1.resp_key :='key1';
        record1.app_name :='name1';
       
        record2.resp_key :='key2';
        record2.app_name :='name2';
       
        allresult(1) := record1;
        allresult(2) := record2;
       
        RETURN allresult;
       
        EXCEPTION
         WHEN NO_DATA_FOUND THEN
           NULL;
         WHEN OTHERS THEN
           -- Consider logging the error and then re-raise
           RAISE;
      END MyFunction;

     

     

    DO my best.
  • Re: How can i call a Oracle Function which return value is user defined record? SOS !!!!!

    05-30-2008, 3:25 AM

    Hi ,

    i think return is not supported in Oracle as in Sql Server,

    instead use the output parameter.

     

     

    Regards

    Suresh Kumar Goudampally

  • Re: How can i call a Oracle Function which return value is user defined record? SOS !!!!!

    05-30-2008, 4:35 AM
    • Member
      point Member
    • suhua
    • Member since 05-30-2008, 6:10 AM
    • China
    • Posts 2

    Thank you very much,

     can you give me a example.

     

    i want to call it using c#.

    Best regards.

     

    Suhua

    DO my best.
  • Re: How can i call a Oracle Function which return value is user defined record? SOS !!!!!

    05-30-2008, 11:07 AM
    • Participant
      1,440 point Participant
    • greg.darling
    • Member since 02-07-2003, 6:50 AM
    • Posts 306

    Hi,

      The Oracle Call Interface doesnt support PLSQL Record type, so you cant return one to client side programs, only plsql.  You could use an Object type instead, and return a Varray of Objects (as either Return or Out param) but you'd have to use Oracle's 11g ODP for that as I dont believe System.Data.OracleClieint supports User Defined Types and Oracle's only recently does (as of 11g) .  There are numerous examples that install with the product.

    Hope it helps,

    Greg

Page 1 of 1 (4 items)