How to Return Type from Function

I've defined a type and a function in specification. But package body returns pls-00330 error (invalid use of type name or subtype name). What am I doing wrong? My intent is to write a function which will return a record containing two values. For now, I put "null;" as a placeholder.
--specification
CREATE OR REPLACE PACKAGE res.year_qtr AS
TYPE yq_type IS RECORD
(yr varchar2(2),
qtr varchar2(1));
FUNCTION yq_fun (date_in date)
RETURN yq_type;
END year_qtr;
-body
CREATE OR REPLACE PACKAGE BODY res.year_qtr AS
FUNCTION yq_fun (date_in date)
RETURN yq_type IS
BEGIN
null;
RETURN year_qtr.yq_type; --get error on this line!
END;
END year_qtr;
Edited by: user516543 on Mar 23, 2009 12:17 PM

You need to declare a variable of that type and return the variable.
You can't just return the type as it's not actually a declaration of that type.
--specification
CREATE OR REPLACE PACKAGE res.year_qtr AS
  TYPE yq_type IS RECORD
    (yr varchar2(2),
     qtr varchar2(1));
  FUNCTION yq_fun (date_in date)
    RETURN yq_type;
END year_qtr;
--body
CREATE OR REPLACE PACKAGE BODY res.year_qtr AS
  FUNCTION yq_fun (date_in date) RETURN yq_type IS
    v_ret year_qtr.yq_type;
  BEGIN
    null;
    RETURN v_ret;
  END;
END year_qtr;

Similar Messages

  • In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?

    In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?
    When I select the Apple Symbols font from the list accessed from under Format/"Show fonts"/collection-all fonts/Apple Symbol, and then continue typing, I get normal letters, if in a slightly different font.
    How can I type using the Apple Symbol font?  I want to use that font to include keyboard and cursor selections of actual screen symbols to help write easily understood explicit computer lesson emails to my 92 year-old mom from a few hundred miles away.
    Steve

    In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?
    When I select the Apple Symbols font from the list accessed from under Format/"Show fonts"/collection-all fonts/Apple Symbol, and then continue typing, I get normal letters, if in a slightly different font.
    How can I type using the Apple Symbol font?  I want to use that font to include keyboard and cursor selections of actual screen symbols to help write easily understood explicit computer lesson emails to my 92 year-old mom from a few hundred miles away.
    Steve

  • How comples return types and parameters are mapped

    Hi all!
    I want to know how complex return types and parameters in a java interface gets mapped to wsdl? for example how would the wsdl for the following interface shall look like:
    interface ComplexReturns{
       java.util.Date getLuckyDate(java.util.Date DoB);
       myPack.MyClass getMyClass();
    }

    Hi,
    - In your application module, make a public method that returns an arry, for example an arry of strings[]
        public String[] returnTwoVals(){
            String[] returnvals = {"1","2"};
            return returnvals;
        }- expose this method in the application module
    - in the user interface drag/drop the returnTwoVals method on a page and choose to create a button.
    - double click the button to generate the binding code
        public String commandButton_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding =
                bindings.getOperationBinding("returnTwoVals");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        }- you can access the values in the arry by adding this code after the Object result =...
       String[] vals = (String[])result;
       System.out.println(vals[0] + " - " + vals[1]);

  • How to return rows from tmp table created inside function??

    Hi,
    I'm trying to return rows from a cursor or table (created within
    the function). How do I specify the return type?

    Hi,
    Here is the code that examples to create a function that can
    return data from table.This is achieved using REFCURSOR concept.
    Hope this helps you.I'm giving all stuff in single PL/SQL
    block.You can break it and create a package and declare
    refcursor type and function in that as well.
    DECLARE
    -- Declare generic cursor type
    TYPE gencur_type IS REF CURSOR ;
    -- Declare generic cursor varaible
    gencur gencur_type;
    -- Declare record type
    TYPE rec_type IS RECORD(descr emp.ename%type) ;
    -- Declare record type variable
    rec rec_type;
    --This how you declare a local function that returns gencrtype
    data set
    --This function is called in main block
    FUNCTION call_refcur return gencur_type
    AS
              rr gencur_type;
    BEGIN
         OPEN rr FOR SELECT descr FROM emp;
         RETURN rr;
    END;-- end of local function
    -- Main block begins here
    BEGIN
    -- Call the local function so that gencur will have
    -- the data set returned by select statement
    gencur:= call_refcur;
    -- Open a loop to test the stuff
    LOOP
         FETCH gencur INTO rec;
         EXIT WHEN gencur%NOTFOUND;
         null;
         dbms_output.put_line(rec.ename);
    END LOOP;
    END;
    Regards,
    Sridhar

  • How to get the returned value from Functions with Callable statement?

    I was glad to find that stored procedures can be invoke with Java class code by the object of Callable statement like :
    String stmt = "BEGIN departments_pkg.do_select(?,?,?); END;";
    and getting the output variables by
    populateAttribute(DEPARTMENTNAME,st.getString(2),true,false);
    But i would like to get values returned from FUNCTION other than stored procedure, how can i achieve it? Thanks a lot!

    Here is  my code
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_1202.
      MODULE subscreen_find.
      CALL SUBSCREEN SUBSEARCH INCLUDING sy-cprog dynnr.
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_1202.
      CALL SUBSCREEN SUBSEARCH.
    MODULE subscreen_find.
      case sy-ucomm.
        when 'SELECTED'.             "fcode
          case 'ZSKILL_SEARCH'.     "data element
            when '01'.                       " value range
              dynnr = 0110.
            when '02'.
              dynnr = 0111.
          endcase.
      endcase.
    ENDMODULE.
    kindly tell me what is wrong
    Edited by: Raji Thomas on Feb 8, 2010 10:20 AM

  • How to return error from subscription function of an event

    I am creating a subscription function for an oracle shipped event, oracle.apps.eng.cm.changeObject.submit. The event fires fine, i can do my custom validations in this function. In case the validations fail, I need to return an error message.
    As per the guides and metalink documents, the way to do this is by returning 'ERROR' . But even though I return an ERROR, it does not error out. Whether I return SUCCESS or ERROR , the behaviour is the same.
    While creating the subscription function, for On Error , I selected, "Stop And Rollback ".
    Is it possible to return errors from the subscription functions.
    thanks
    Satya

    You shouldn't be passing ResultSet objects across the EJB layer.
    Instead you should be passing data back and forth.
    All of the data access code should be in one place in one class.
    That class should open the connection, run the query, process/store the results of the query and then close the connection.
    In this case you probably want to return a list of something to your jsp.
    So your EJB call should be more like
    public List<resultBean> check(String id){
      ResultSet rs = Statement.("select * from table1 where id=123");
      List resultList = new ArrayList();
      while (rs.next()){
        Bean myBean = new Bean();
        myBean.setProperty1(rs.getString("field1"));
        myBean.setProperty2(rs.getString("field2"));
        resultList.add(myBean);
      return resultList;
    }

  • How to return sdo_geometry from java procedure

    How can I return a SDO_GEOMETRY object from a java-stored-procedure to PL/SQL.
    I have a java class with methods that creates a specific polygon based on some user values. I want to return this polygon as a SDO_GEOMETRY object to a PL/SQL procedure.
    JDeveloper does not accept SDO_GEOMETRY as a return type.
    Can this be done?

    Justin,
    I have a PL/SQL package that contains several functions. One of them does selection and filtering of spatial features based on a user's location and preferences. For this purpose a web-application runs this function.
    I would like this function to do the following:
    1. the function is called, user parameters are passed in
    2. a call to a java-stored-procedure is made. This java procedure creates a polygon based on the user's location and preferences.
    3. the polygon is returned to the PL/SQL function
    4. the funtion uses the returned polygon to query spatial features that intersect, etc.
    I can do the call to the java-stored-procedure but where I get stuck is how to get the polygon from java to pl/sql. I can return a String or a number from java but how can I return the polygon (e.g., STRUCT, java object)?
    The current solution uses a work-around by storing the polygon in a temporary table. I would like to change this because once the function has run, the polygon is not needed anymore so I would like to do without having to store the polygon.
    Markus

  • Returning arrays from function

    Hi all,
    Can u please guide me in how to return an array from function .
    Is it possible or not ??
    If it is possible please tell me how to declare the function(prototype) that returns string array
    and how to return the string array..
    Thanks in Advance

    Hi all,
    Can u please guide me in how to return an array from
    function .
    Is it possible or not ??
    If it is possible please tell me how to declare the
    function(prototype) that returns string array
    and how to return the string array..
    Thanks in Advance
    public String [] methodReturnsAnArray()
    }

  • Returning Recordsets from Functions

    Pardon my ignorance; there is probably a simple answer to this one, but I'm trying to make the leap to Oracle Stored Procedures and I have a basic question:
    I have created a Function in Oracle 8.1.7 EMP_SEL_ALL, based on the following SQL Statement:
    CREATE OR REPLACE FUNCTION "SCOTT"."EMP_SEL_ALL" (
              enuma          IN NUMBER)
              RETURN SCOTT.emp%ROWTYPE IS
    emp_row SCOTT.emp%ROWTYPE;
    BEGIN
         SELECT * into emp_row FROM SCOTT.emp
         WHERE empno = enuma;
    RETURN emp_row;
    END;
    The function compiles with no problems.
    I have written a Java call to execute the Function, which reads as follows. Because I am attempting to return an entire row, I assume that will equate to a ResultSet:
    sqlCallStmt = con.prepareCall("{ call SCOTT.EMP_SEL_ALL ? ) }");
    sqlCallStmt.setInt(1, 7369);
    result = sqlCallStmt.executeQuery();
    The error returned is as follows:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00221: 'EMP_SEL_ALL' is not a procedure or is undefined
    Looking in DBA Studio, the Function is shown in the SCOTT schema, and I am logged in as that user. I am therefore inclined to think that, rather than a permissions issue, I have a syntax error somewhere, or I have left out a step.
    For anyone who has been down this road before, please advise. Is there a better way to do this via Stored Procedure? I have no problem querying the table and data in a standard SQL statement. Many thanks in advance.

    First, when you call a function I think you have to use the syntax {call ? = function_name} (notice where the ? goes.
    However, I still don't think you will be able to get this to work becuase a Java client cannot interpret a PL/SQL record (or rowtype, in your case).
    If you want to return the results as a recordset, you will have to move the function into package and declare a REF CURSOR for the return type. It appears your code only returns one row, however, so a recordset will create unnecessary overhead.
    It would probably be best to make your function a procedure that returns OUT parameters, one for each column selected.

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • Oracle forms 9i - How to return back from a block?

    Some one please help me
    In a trigger, I have a code says go_block. How to return from the block and back to the trigger to continue executing the codes below the go_block statement? Please see example below, I want to come back from block CHECK_STUFF and continue execute the statements
    :Name.option := '1';
    if :name.option = '1' then
    Example:
    Block: Name
    Item: yes_no - Key-next-item trigger
    declare
    begin
    go_block('check_stuff');
    go_item('answer');
    :Name.option := '1';
    if :name.option = '1' then
    Thanks - Patty

    The code behind the GO_BLOCK is executed immediately after the GO_BLOCK, it doesn't stop at that point. So you have to split your code, like
    declare
    begin
    go_block('check_stuff');Then, create a procedure like
    PROCEDURE PR_RETURN_FROM_BLOCK IS
    BEGIN
    go_item('answer');
    :Name.option := '1';
    if :name.option = '1' then
    END;Then, when returning from the block (in whatever trigger you use), just call that procedure.

  • How to return cursor from procedure to jdbc

    plz help me through example of code as wl as procedure where.... return cursor from procedure to jdbc

    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS OFF
    GO
    CREATE procedure anil3 @count INT OUT,@opcode INT OUT,@total_tiff INT OUT
    as
    declare @query2 varchar(300),@tiff_count int,@query1 varchar(300)
    set @query1='declare move_cursor   cursor forward_only static for
    select count(opcode),opcode from TABLE1 group by opcode
    open move_cursor'
    exec(@query1)
    fetch next  from move_cursor into @count,@opcode
    set @opcode="'"+@opcode+"'"
    set @total_tiff=0
    while (@@fetch_status=0)
    begin
         set @query2='declare move_cursor2  cursor static for '+
         ' select count(tiff) from TABLE2  where opcode='+@opcode+
           ' open move_cursor2 '
         exec(@query2)
         fetch next  from move_cursor2 into @tiff_count
         while (@@fetch_status=0)
         begin
              set @total_tiff=@total_tiff+@tiff_count
              fetch next  from move_cursor2 into @tiff_count
         end
         close move_cursor2
         deallocate move_cursor2
    print  @total_tiff
    print @count
    print @opcode
    fetch next  from move_cursor into @count,@opcode
    end
    close move_cursor
    deallocate move_cursor
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON
    GO******************************************************************************
    above this is sql server 2000 PL/SQL and i hv to get the value
    print @total_tiff
    print @count
    print @opcode
    through JDBC
    plz help me out how to return Cursor to JDBC and HOW toPRINT THESE THREE VALUE @total_tiff, @count, @opcode through JDBC
    get this values through JDBC

  • How to return fault from Async BPEL

    Hi,
    I have ESB that has input,output and fault, This ESB calls Async BPEL that takes only input. Now i want to return fault from BPEL to ESB. How do i do it?
    Please help.

    Hi,
    My use case is i am implementing AIA. So my enterprise layer is ESB and my ABCS provider is BPEL. As provider takes lot of time to complete the instance, to avoid timeout issue i just created Async BPEL with two ports one for input another for fault. I am able to send back my fault back to this call back port. But how i can receive the fault to the same ESB which called the BPEL?
    I am not able to implement it. I can not go for any workaround like creating one more BPEL and then make it as sync, put pick activity and receive the fault then send back to ESB.
    Thats the reason i am very specific. If you find some solution please let me know.

  • How to return fault from Async BPEL to ESB

    Hi,
    I have ESB that has input,output and fault, This ESB calls Async BPEL that takes only input. Now i want to return fault from BPEL to ESB. How do i do it?
    Please help.

    Hi,
    My use case is i am implementing AIA. So my enterprise layer is ESB and my ABCS provider is BPEL. As provider takes lot of time to complete the instance, to avoid timeout issue i just created Async BPEL with two ports one for input another for fault. I am able to send back my fault back to this call back port. But how i can receive the fault to the same ESB which called the BPEL?
    I am not able to implement it. I can not go for any workaround like creating one more BPEL and then make it as sync, put pick activity and receive the fault then send back to ESB.
    Thats the reason i am very specific. If you find some solution please let me know.

  • How to create webservice from function module

    Hello,
    I'm trying to create webservice from function module from. I choose Utilities/More Utilities/Create Webservice/..From function Module. What data should I enter in section "Enter Package/Request" ?
    When I check "Local object" checkbox I get a message "Test objects cannot be created in foreign namespaces"
    Is there any doc about this procedure (web service creation) with description of all sections ?
    thanks for any reply,
    Lukasz Ferenc

    Hi,
    Which SAP product of wich release of which SP are you using ?
    The procedure is documented in help.sap.com and in blogs and SDN forum messages.
    It means that the use of the SEARCH button should give plenty of answers...
    >When I check "Local object" checkbox I get a message "Test objects cannot be created in foreign >namespaces"
    As usual, begin your choosen name with an "Z".
    Regards,
    Olivier

Maybe you are looking for

  • Cover screws for MacBook Pro

    Where may i get the Cover screws for my MacBook Pro? I need the short and long ones.

  • Video transfer from ZR80 camcorder

    I am trying to copy video from a Canon ZR80 camcorder to my HP EliteBook 8580w laptop.  I can directly connect the DV port on the camera to an internal  DV port on the laptop. When I use VideoPadVideo  Editor from NCH,  I cannot see the camcorder in

  • ASSIGN to add new lines to internal tables

    Hello, within our code, I have found several occurrences of the obsolete ASSIGN LOCAL COPY which I would like to replace with up-to-date coding. Particularly, we have the following code segment: DATA: ct_table TYPE INDEX TABLE. FIELD-SYMBOLS: <ls_new

  • I'm having trouble downloading PhotoShop Elements

    I successfully downloaded the Adobe Download Assistant but then only had Photoshop CS6 to choose. Did I do something wrong? Best,   Dina

  • Singleton life-cycle in EJBs

    This is a general question that I have about the use of a singleton class from an EJBs. I want to create a cache in the form of a singleton (suppose for now, no server clustering). The goal of this cache would be to speed access to a database. Differ