Can oracle  function return more than one value

Hi All
please answer can oracle function return more than one value
need one schenario
regards

Can any function, irrespective of the language, return multiple values?
OF COURSE NOT!!
So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
And whatever programming skills you build on such a foundation, will be seriously lacking.
I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
Message was edited by:
Billy Verreynne

Similar Messages

  • Can a function return more than one value

    plz give me some example.

    http://forums.oracle.com/forums/search.jspa?threadID=&q=%2Bfunction+%2Bparameters&objID=f75&dateRange=all&userID=&numResults=15&rankBy=10001
    Nicolas.

  • Can Function Return more than One Values ??

    Hi Experts,
    I would like to ask you Can Function Return more than one values. I Used Function with Out and In out parameter and its working Fine..
    1. what is harm using Out and In out parameter in function
    2. if we can use Out and In out parameter in Function so what is deffernce between procedure and Function.
    3. Is there any Other Way Though which we can return more the One values in Function.
    Please advice me...
    Thanks
    Umesh Goel

    Yes/No.
    You can return multiple value from function. But, in PL/SQL and not in a SQL.
    The following examples demonstrate that -
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Mar 28 17:41:15 2007
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> create or replace package glob
      2  as
      3    b varchar2(20);
      4    c varchar2(20);
      5  end;
      6  /
    Package created.
    SQL>
    SQL> create or replace function test_mul_out(a in number)
      2  return number
      3  is
      4    cursor c1(eno in number)
      5    is
      6      select ename,job,sal
      7   from emp
      8   where empno = eno;
      9  
    10    rec c1%rowtype;
    11    d  number(10);
    12  begin
    13    open c1(a);
    14    loop
    15      fetch c1 into rec;
    16      exit when c1%notfound;
    17       glob.b:= rec.ename;
    18    glob.c:= rec.job;
    19    d:= rec.sal;
    20    end loop;
    21    close c1;
    22    return d;
    23  end;
    24  /
    Function created.
    SQL> set serveroutput on
    SQL>
    SQL> declare
      2    zz  number(10);
      3  begin
      4    select test_mul_out(7777)
      5    into zz
      6    from dual;
      7    
      8    dbms_output.put_line('Ename: '||glob.b);
      9    dbms_output.put_line('Job: '||glob.c);
    10    dbms_output.put_line('Sal: '||zz);
    11  end;
    12  /
    Ename: Avik
    Job: CLERK
    Sal: 3456
    PL/SQL procedure successfully completed.
    SQL> Regards.
    Satyaki De.

  • Can a function return more than one item or object?

    Hi I am trying to move text movies and textfields around a stage. This is a learning curve for me. I am confused by an example I have found on the internet.
    http://forums.adobe.com/community/flash/flash_actionscript
    What type of object is
    var letter:Object = getLetterObject(_text.charAt(i));  // in the draw function
    as it has properties
    letter.stepDegrees = _totalAngle / numOfLetters;
    getLetterObject()
    seems to return lotts of stuff which would not be done in other languages like C
    return
    movie:movie,
    field:field,
    widthInDegrees:0,
    fieldWidth:field.width,
    fieldHeight:field.height
    I would like to get my head around this as this is a good example of what I need. Well parts of it actualy.
    I understand that the text field is added as a child to the Movieclip. I would have expected just a MovieClip object returned.
    full code including the function  getLetterObject()
    =======
    package 
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    public class CurvedText extends MovieClip
    public static const DIRECTION_UP:String = "up";
    public static const DIRECTION_DOWN:String = "down";
    public var showLetterBorder:Boolean = false;
    public var showCurve:Boolean = false;
    private var _letterHolder:MovieClip;
    private var _text:String;
    private var _radius:Number;
    private var _letters:Array;
    private var _widthOfText:Number = 0;
    private var _startAngle:Number = 0;
    private var _endAngle:Number = 360;
    private var _totalAngle:Number = 0;
    private var _textFormat:TextFormat;
    private var _direction:String;
    public function CurvedText(text:String = "", radius:Number = 200, startAngle:Number = 0, endAngle:Number = 360, direction:String = "up", textFormat:TextFormat = null)
    _text = text;
    _radius = radius;
    _startAngle = startAngle;
    _endAngle = endAngle;
    _direction = direction;
    _textFormat = textFormat;
    _letters = [];
    _totalAngle = Math.abs(_startAngle) + Math.abs(_endAngle);
    public function draw():void
    // checking if there is any text set
    if(_text == "")
    return;
    // clearing the letters' holder
    if(_letterHolder && contains(_letterHolder))
    removeChild(_letterHolder);
    _letterHolder = new MovieClip();
    addChild(_letterHolder);
    // adding letters
    var numOfLetters:int = _text.length;
    for(var i:int=0; i<numOfLetters; i++)
    var letter:Object = getLetterObject(_text.charAt(i));
    letter.stepDegrees = _totalAngle / numOfLetters;
    _letters.push(letter);
    _widthOfText += letter.fieldWidth;
    _letterHolder.addChild(letter.movie);
    // positioning
    position();
    // draw the curve
    if(showCurve) {
    _letterHolder.graphics.lineStyle(1, 0xFF0000, 1);
    _letterHolder.graphics.drawCircle(0, 0, _radius);
    private function getLetterObject(letter:String):Object
    // setting default text format
    if(!_textFormat)
    _textFormat = new TextFormat();
    _textFormat.align = TextFormatAlign.CENTER;
    _textFormat.font = "Verdana";
    _textFormat.size = 12;
    _textFormat.color = 0x000000;
    // creating the field
    var movie:MovieClip = new MovieClip();
    var field:TextField = new TextField();
    field.width = 10;
    field.defaultTextFormat = _textFormat;
    field.embedFonts = true;
    field.multiline = false;
    field.autoSize = TextFieldAutoSize.CENTER;
    field.text = letter;
    field.x = -field.width / 2;
    field.y = -field.height / 2;
    if(showLetterBorder)
    field.border = true;
    movie.addChild(field);
    return  // RETURNS more than one value?
    movie:movie,
    field:field,
    widthInDegrees:0,
    fieldWidth:field.width,
    fieldHeight:field.height
    private function position():void
    // position the letters
    var numOfLetters:int = _letters.length;
    var degrees:Number = _startAngle;
    for(var i:int=0; i<numOfLetters; i++)
    var angle:Number = _letters[i].stepDegrees + degrees;
    if(_direction == DIRECTION_DOWN)
    angle -= 180;
    _letters[i].movie.scaleY = -1;
    } else {
    xValue = _radius * Math.cos((angle-90)/180*Math.PI);
    yValue = _radius * Math.sin((angle-90)/180*Math.PI);
    var xValue:int = _radius * Math.cos((angle-90)/180*Math.PI);
    var yValue:int = _radius * Math.sin((angle-90)/180*Math.PI);
    _letters[i].movie.x = xValue;
    _letters[i].movie.y = yValue;
    _letters[i].movie.rotation = angle;
    degrees += _letters[i].stepDegrees;
    // position the holder
    var bounds:Rectangle = _letterHolder.getBounds(this);
    _letterHolder.x = -bounds.x;
    _letterHolder.y = -bounds.y;
    if(_direction == DIRECTION_DOWN)
    _letterHolder.scaleX = -1;

    Hi
    I still think I need an Object parent child linkage diagram on this to get my head around it.
    It seems that things are reversed so that it is Object:value. Kind of confusing to see movie:movie.
    var letter:Object = getLetterObject(_text.charAt(i));
    letter holds the following objects
    MovieClip:Movie
    TextField:field
    widthInDegrees:0  // What is this. What type is a  widthInDegrees
    fieldWidth:field.width // Same as above
    fieldHeight:field.height  // Same as above
    And to cap it all, back in the calling function draw()
    letter.stepDegrees = _totalAngle / numOfLetters;  //  What is stepDegrees a property of? MovieClip,TextField,widthInDegrees,fieldWidth or fieldHeight
    I can understand the first two but not the last three
    For example widthInDegrees is not mentioned anywhere in the code. and
    letter.stepDegrees // implies that stepDegrees is a property of Object:letter.
    Do you throw a property and value blindly at the letter object and let flash work out which object it is a property of?
    MovieClip & TextField do not have this property. Searched the web for this information. We need an equivelent of MSDN.
    Desmond.

  • Can a method return more than one value?

    I was studying for my biology exam and I got bored and I started thinking and then I wandered if a method can return more than one value...?
    For example, if I want a method to return a row a column, I make a method that returns an int. But what if I want to return two ints? Or what If I want to return an integer and a string? Is it possible or do I have make two methods, each returning one thing?
    What I always did until now is is I want for example to return a few integers, I would store them in a String and then when I return the string, I parse the numbers out using stringtokenizer... but it doesn't look like the best way... and it's pretty annoying...

    I'm weak on terminology, hence I don't even know what
    AFAIK means...As Far As I Know
    This doesn't really make sense for me. It's more
    efficient to make a whole class just for two
    integers, than having two methods? Efficiency is not the point. The flow is.
    If you have two methods, the caller must be aware of both of them. The other way it's up to the callee.
    Just because the
    two integers are related to each other? Doesn't
    making a class require more memory usage than just
    making two one-line methods?The memory usage is not wholly irrelevant, but there are ways to handle that (caching, inlining, etc.).
    It's a bit hard to counter your point for me, but if you had done a lot of GUI painting stuff, you'd see all those Points, Dimensions, Rectangles, you name it, are quite invaluable.

  • Function - Return More than One Value in a Concatenated String

    Hi,
    Is it possible for a function to return a concatenated string(combining more than one number). I am trying to return the PO number by inputting and invoice_id and code number but an invoice_id can have more than one PO with the same code number. I would like to concatenate the PO numbers with commas e.g.
    10124, 10090, 10987
    At the moment the function returns null for these cases that have more than one PO number.
    Thanks

    Also is is possible to create another function that can be called in the same script using the PO number as an IN parameter in SQL. See SQL below:
    select cck.concatenated_segments as "Segment" ,
    cc.code_combination_id,
    NVL ( src . user_je_source_name , '**********' ) AS "Source" ,
    NVL ( cat . user_je_category_name , '**********' ) AS "Category" ,
    jel . period_name as "Period Name" ,
    i.invoice_id as "Invoice ID",
    s.vendor_name as "Vendor Name",
    s.segment1 as "Supplier No",
    jeb . name as "Batch Name" ,
    func_get_po(i.invoice_id, cc.code_combination_id) "PO No",
    jeh . name AS "Header Name" ,
    jel . description AS "Description" ,
    jel.accounted_dr AS "Debit" ,
    jel.accounted_cr AS "Credit" ,
    NVL(jel.accounted_dr, 0) - NVL(jel.accounted_cr, 0) AS "Net Amount"
    FROM apps.gl_code_combinations cc ,
    apps.gl_code_combinations_kfv cck,
    apps.gl_je_lines jel ,
    apps.gl_je_headers jeh ,
    apps.gl_je_batches jeb ,
    apps.gl_je_categories cat ,
    apps.gl_je_sources src,
    apps.gl_import_references r,
    apps.xla_ae_lines al,
    apps.xla_ae_headers ah,
    apps.xla_events e,
    xla.xla_transaction_entities te,
    apps.ap_invoices_all i,
    apps.ap_suppliers s
    WHERE ( cck.concatenated_segments BETWEEN '23.83545.141.000.00.23.000.000' AND '23.83545.141.000.00.23.000.000'
    AND cc.CHART_OF_ACCOUNTS_ID = 50328
    AND jeh.LEDGER_ID IN
    (select acc.ledger_id
    FROM apps.gl_access_set_ledgers acc
    WHERE acc.access_set_id = 1000
    AND jel.code_combination_id = cc.code_combination_id
    AND cck.code_combination_id = cc.code_combination_id
    AND jel.status
    || '' = 'P'
    AND ( jel.accounted_dr != 0
    OR jel.accounted_cr != 0 )
    AND jeh.je_header_id = jel.je_header_id
    AND jeh.actual_flag = 'A'
    AND 1 = 1
    AND jeh.currency_code != 'STAT'
    AND jeb.je_batch_id = jeh.je_batch_id
    AND jeb.average_journal_flag = 'N'
    and src.je_source_name = jeh.je_source
    and cat.je_category_name = jeh.je_category
    and r.je_header_id(+) = jel.je_header_id
    and r.je_line_num(+) = jel.je_line_num)
    AND ( :period_name = jel.period_name
    and al.gl_sl_link_id(+) = r.gl_sl_link_id
    and al.ae_header_id = ah.ae_header_id(+)
    and al.application_id = ah.application_id(+)
    and ah.application_id = e.application_id(+)
    and ah.event_id = e.event_id(+)
    and e.application_id = te.application_id(+)
    and e.entity_id = te.entity_id(+)
    and nvl(te.source_id_int_1,-99) = i.invoice_id(+)
    and i.vendor_id = s.vendor_id(+) )
    AND ( jel.ledger_id = 2041)
    ORDER BY src.user_je_source_name ,
    cat.user_je_category_name ,
    jeb.name ,
    jeh.name ,
    cck.concatenated_segments ,
    jel.je_line_num
    I am using func_get_po(i.invoice_id, cc.code_combination_id), I would like to call another function in this script that uses the PO number as an IN parameter.
    For example func_get_po_requester(i.invoice_id, cc.code_combination_id, func_get_po(i.invoice_id, cc.code_combination_id))
    Would this work?
    Thanks

  • How can a LOV returns more than one value in ADF query?

    Hi,
    I'm using JDev 11g .I'm using a LOV attribute and I have declared a transient attribute to return the meaningful value of the LOV on it. Now it works fine in form , but I want to make it work on the view criteria(<af:query>). It does not return the transient content, and returns empty value.
    Thanks
    Edited by: farzaneh on Nov 13, 2009 10:56 AM

    It seems like Shay Schmeltzer just put out something on his blog on this very issue. You might go have a look to see if you get inspired, since you have given us very little information by which to help you otherwise.

  • Possible to return more than one value?

    If I have a somethign like this:
    public int test()
    return 5;
    }Is it possible to have test() return more than one value? And if it can, can you post an example showing how?

    Could you post an example of how to do this?If you do not know how to define a class, you need to start from the very beginning.
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.
    James Gosling's The Java Programming Language. Gosling is
    the creator of Java. It doesn't get much more authoratative than this.

  • Subquery returned more than one value

    Hi,
    I have this statement which has been working fine - not I get a 'Subquery returned more than one value" error:
    SELECT
    'WAS3' AS 'Rec ID',
    E.EecEEID AS 'Emp ID',
    eepNameFirst AS 'First Name',
    eepNameLast AS 'Last Name',
    EecDateOfOriginalHire AS 'Service Date',
    (SELECT DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) from empcomp EC WHERE EC.EecEEID = E.EECEEID) as 'Yrs of Serv'
    FROM
    EmpPers
    JOIN EmpComp E
    ON E.eecEEID = eepEEID
    JOIN Company
    ON eecCoID = cmpCoID
    WHERE
    EecDateOfTermination IS NOT NULL
    AND EXISTS
    (SELECT 1
    FROM EmpComp e2
    WHERE e2.EecEEID = E.EecEEID
    --AND e2.eecEmplStatus <> 'A')-- changed to <> ...this WAS/is to filter out anyone that was termed then re-hired
    --AND E.EecTermReason NOT IN ('I01','I02','I03','I14','I22','V05','V07','V09','V12','V22','V13', 'TRO')
    AND E.eecDateOfTermination
    IN (SELECT (EC.eecDateOfTermination)
    FROM EMPCOMP EC
    WHERE EC.EecEEID = E.EECEEID
    AND EC.eecDateOfTermination IS NOT NULL
    AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
    AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
    --AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
    -- AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
    -- AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
    -- AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
    -- AND E.eecDateOfTermination IS NOT NULL ))
    --added below per Paul Cottle to exclude employeess less than four years
    AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
    qeqw

    Check this, if it works:
    SELECT
    'WAS3' AS 'Rec ID',
    E.EecEEID AS 'Emp ID',
    eepNameFirst AS 'First Name',
    eepNameLast AS 'Last Name',
    EecDateOfOriginalHire AS 'Service Date',
    DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) as 'Yrs of Serv'
    FROM EmpPers
    JOIN EmpComp E ON E.eecEEID = eepEEID
    JOIN Company ON eecCoID = cmpCoID
    WHERE EecDateOfTermination IS NOT NULL
    AND EXISTS
    (SELECT 1
    FROM EmpComp e2
    WHERE e2.EecEEID = E.EecEEID
    AND E.eecDateOfTermination
    IN (SELECT (EC.eecDateOfTermination)
    FROM EMPCOMP EC
    WHERE EC.EecEEID = E.EECEEID
    AND EC.eecDateOfTermination IS NOT NULL
    AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
    AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
    AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • LOV Return more than one value to differenent items on page

    New to express. I need to returm more than one value from list of LOV. For example: LOV => select a, b, c from testtable
    I would then like to
    a to populate item1 => with submit
    b to populate item2 => hidden
    c to pupulate item3 => hidden
    as items on my page
    when a user chooses a (with submit) in item1 b and c would populate also, b and c are hidden to the user. Any advice?

    Dear Frank
    I did it as like as the following link lead me:
    http://www.oracle.com/technology/obe/obe11jdev/11/adfbc_new_features/adfbc.html
    The problem has been appeared when I attached the "Create" button and when press on it to create new record, then the "LOV" couldn't work correctly.
    Thanks for your reply

  • How to return more than one value from a  function

    hello everybody,
    Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
    2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
    Thanks.

    I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
    <code>
    class justArray {
    int x=0
    int y=0;
    int z= 0;
    ...somewhere
    justArray[] points= new justArray[4];
    points[0].x= ..
    points[0].y= ..
    points[0].z= ..
    points[1].x= ..
    return points[]
    </code>

  • How to Create a Procedure/Function to Return more than one value

    How I can write a function/Procedure to which one value is passed and it will return nine values. How I can use these values

    Syed,
    I would use PL_SQL table versus a VARRAY for this purpose as you will have an advantage of joining PL_SQL table if you want to in your SQL statements in the procedure.
    1. At the SQL prompt, create a type using,
       create or replace type myTable as table of VARCHAR2(100);
    2. Pass the table to your procedure as IN OUT parameter,
    Create or replace procedure
    myProc(pvar1 IN Number, passingArray IN OUT myTable) AS
    Begin
        --Fill the array with your logic
        for i in 1..9
        loop
            passingArray.extend;
            passingArray(passingArray.count) := 'what ever';
        end loop; 
    End;
    3. From your Main prog, you call  Myproc
       --declare a variable for type first
       passingArray myTable := myTable();
       begin
       myProc(10, passingArray());
       --At this point, You would be able to Join the PL_SQL table
       --which gives you the power of using SQL with PL_SQL tables
       end; -- end of main program
    4. All done!I have not shown how to use PL_SQL tables in SELECT statements, as that is not the subject here.
    At the end of the story, I would say, if you know the number of arguments that you are going to pass to a procedure, Simply use "that many" IN OUT parameters to finish your task(9 in your case). Although the proc call looks large with this, it is much simpler. The above approach is VERY helpful if YOU DO NOT KNOW THE NUMBER OF ARGUMENTS that you are sending AND receiving From a procedure.
    Thx,
    SriDHAR

  • Output parameters or how to return more than one value

    My RMI server retrieves a list of Strings from the database. I need to return a status code int and an array of Strings to the RMI client. Does anybody have any ideas on how to do this. The only way I have come up with is to return an array of Strings using the first array position as the status code. But this is very ugly. There doesn't seem to be any way to have output parameters. I can use "output parameters" with code that lies in the same app by using wrapper classes or arrays but this does not really apply to a client and server running on different machines. Any ideas?

    Well, my general reaction is that you don't need a status code. (You can instead throw an exception if the status is anything but "OK".)
    However, on the assumption that you really DO need the status, then some alternatives are
    o Return an object that has a status code and an array as member variables.
    o In the call, pass in an object that the server can fill in with the array of strings. have the function return the status code.

  • How to return more than one value through RECORD TYPE from function

    Hi friends,
    i m ew in oracle forms. i want to return the two values at a time from a function but can't,Please help me. my codding is as following
    Thanks in advance.
    FUNCTION Fun_Choose_Right_cast(v_post_no payroll.post_register.post_no%TYPE) RETURN RECORD IS --here is the error 
    v_return_char CHAR NOT NULL := 'X';
    TYPE row_no_record_type IS RECORD
         (v_row_id NUMBER(3)NOT NULL := 0,
         v_char CHAR NOT NULL := 'X');
    row_no_record row_no_record_type;
    BEGIN
    IF v_post_no = 1 THEN
         IF TRUNC(v_post_no*0.15) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'A';
              --v_return_char := 'A';
         END IF;
         IF TRUNC(v_post_no*0.075) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'B';
              --v_return_char := 'B';
         END IF;
         IF TRUNC(v_post_no*0.275) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'C';
              --v_return_char := 'C';
         END IF;
         IF row_no_record_type.v_row_id = 0 AND v_char = 'X' THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'D';
         --IF v_return_char = 'X' THEN 
              --v_return_char := 'D';
         END IF;
    ELSIF(v_post_no BETWEEN 2 AND 100) THEN
         IF TRUNC(v_post_no*0.15) > TRUNC((v_post_no-1)*0.15) THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'A';
              --v_return_char := 'A';
         END IF;
         IF TRUNC(v_post_no*0.075) > TRUNC((v_post_no-1)*0.075) THEN
              IF TRUNC(v_post_no*0.15) > TRUNC((v_post_no-1)*0.15) THEN
                   row_no_record_type.v_row_id := v_post_no-1;
                   v_char := 'B';
                   --v_return_char := 'A';
              ELSE
                   row_no_record_type.v_row_id := v_post_no;
                   v_return_char := 'B';
              END IF;
         END IF;
         IF TRUNC(v_post_no*0.275) > TRUNC((v_post_no-1)*0.275) THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'C';
              --v_return_char := 'C';
         END IF;
         IF row_no_record_type.v_row_id = 0 AND v_char = 'X' THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'D';
         --IF v_return_char = 'X' THEN 
              --v_return_char := 'D';
         END IF;
         END IF;
    RETURN row_no_record;
    END;

    Posting your Oracle version is immensely helpful when asking questions (different version = different answers / functionality available).
    select * from v$version;Also, using tags will preserve the formatting of your code.
    You should likely read (a lot) about  [http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10807/05_colls.htm]
    Basically, you would need to create a PL/SQL record and reference that, OR you could create a SQL type.
    If you're looking for a 'simple' way to return many single values (no arrays) then your best bet would be a procedure with multiple OUT parameters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Return more than one value in a function

    Hi All,
    I want to return values from table. 4 values will be returned from the table.
    Did something like this....will work for a single row.
    CREATE OR REPLACE FUNCTION test_func
    RETURN varchar2
    IS
    temp1 varchar2(1);
    temp2 varchar2(1);
    temp3 varchar2(1);
    temp4 varchar2(1);
    v_strng_val varchar2(2000);
    BEGIN
    select '1','2','3','4' into temp1,temp2,temp3,temp4 from dual;
    v_strng_val := temp1;
    v_strng_val := v_strng_val||','||temp2;
    v_strng_val := v_strng_val||','||temp3;
    v_strng_val := v_strng_val||','||temp4;
    return v_strng_val;
    exception
    when others then
    return null;
    End test_func;I know this could be done through collections. But not worked on collections
    much.
    Please Suggest. Thanks.
    Edited by: user545846 on Jul 20, 2009 10:26 PM

    use refcursor you can do it.
    SQL> create or replace function get_dept_emps(p_deptno in number) return sys_refcursor is
    2 v_rc sys_refcursor;
    3 begin
    4 open v_rc for 'select empno, ename, mgr, sal from emp where deptno = :deptno' using p_deptno;
    5 return v_rc;
    6 end;
    7 /
    Function created.
    SQL> create or replace type emptype as object(empno number,
    2 ename varchar2(10),
    3 mgr number,
    4 sal number);
    5 /
    Type created.
    SQL> create or replace type t_emptype as table of emptype;
    2 /
    Type created.
    1 create or replace function populate_emps(deptno in number := null)
    2 return t_emptype is
    3 v_emptype t_emptype := t_emptype(); -- Declare a local table structure and initialize it
    4 v_cnt number := 0;
    5 v_rc sys_refcursor;
    6 v_empno number;
    7 v_ename varchar2(10);
    8 v_mgr number;
    9 v_sal number;
    10 begin
    11 v_rc := get_dept_emps(deptno);
    12 loop
    13 fetch v_rc into v_empno, v_ename, v_mgr, v_sal;
    14 exit when v_rc%NOTFOUND;
    15 v_emptype.extend;
    16 v_cnt := v_cnt + 1;
    17 v_emptype(v_cnt) := emptype(v_empno, v_ename, v_mgr, v_sal);
    18 end loop;
    19 close v_rc;
    20 return v_emptype;
    21* end;
    SQL> /
    Function created.
    SQL> select * from table(populate_emps(30));
    EMPNO ENAME MGR SAL
    7499 ALLEN 7698 1600
    7521 WARD 7698 1250
    7654 MARTIN 7698 1250
    7698 BLAKE 7839 2850
    7844 TURNER 7698 1500
    7900 JAMES 7698 950

Maybe you are looking for

  • IPod not showing up on desktop or in iTunes, thinking I have to re-install.

    My iPod isn't showing up when I plug it into my iMac G5 and going through the help menus, I've found that it suggests re-installing iTunes before trying to restore my iPod. I have a color screen 20 GB iPod that I purchased about a year ago. Now, will

  • New SpryWidget .CSS for a New Page

    I have the whole spry arsenal of files on a website in a separate folder. I am already using several widgets and functions from that and among others also a "spry collapsible panel" widget on one of the pages. Now, I would like to use it once again o

  • How do I save  a large font size in my google email?

    Every time I go to my google email the font size is small. So I use View > Zoom in to enlarge it. If I exit and return , I have to repeat the process. How do I save the settings? Dave

  • Problem in opening filename with space

    Hi Folks, I am trying to open a file located on websphere appserver. file name has a space in between. (e.g. abc xyz.xls) I could not open the file in netscape and IE both. Has any one come across such problem?

  • 1500+ Episodes! Is this an iTunes record?

    The Mister Ron's Basement has recently topped 1500 Episodes, all of which are archived and can be downloaded by subscribers. The Episodes are indexed via a link at the web page. Some of the most popular Episodes are from 2005. When all the stories re