How to return two values of a function?

Hi all
I have a function which returns a varchar2 value. This value is used in the SQL of a ref cursor

Now I want this function returns two values. I tried to use varray, but could not accomplish the task.

Can you tell me how can I find the two values from a function? and how this function can be called in a SQL query?

Thank you very much

The query should look like:

SELECT v.col.name AS name
     , v.col.flag AS flag
FROM   ( SELECT kk_test_kk(t.somecolumn,t.someothercolumn,42) AS col
         FROM   sometable t ) v;

Note that you need to prefix with the name of view inline ('v' in the example) and the expression of the function ('col' in the example).

Tags: Database

Similar Questions

  • How to return multiple variables from a function

    Hello

    As seen below, I tried more then return a variable to a function, but I think I have a syntax problem...

    function hesapla3 (parameter1, parameter 2): (number & & Boolean) / / PROBLEM IS HERE, I have NEED of TWO VARIABLES to RETURN
    {
    var yenideger2:Number = new Number();
    var bol2:Boolean = new Boolean();
    yenideger2 = parameter1 + parameter 2;
    if(yenideger2>80) {bol2 = false ;}
    Return yenideger2;
    return bol2;
    trace (yenideger2);
    trace (bol2);
    }

    You can do it this way.

    You can combine the 2 to 1 as a var

    var tekdeger:String=yenideger2.toString()+"-"+bol2.toString();

    Return tekdeger;

    and then you can split and mount the value returned into variables that you want...

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • How to merge two values of resource bundle?

    Hi all

    JDev worm: 11.1.1.7

    I want to merge two values of resource bundle... How to do?

    like this #{expr? str1: str1 + str2}

    I tried like below and used some features of jstl... but no use did not work... got a parse exception, exception of compilation, etc...

    < af:outputText value = "#{row.accountName eq 'AccountName9'?" {resource ['LBL_WELC']: resources ["LBL_WELC"] + resource ['LBL_HOME']} "/ >"

    I would like to know how to do this?

    Kind regards

    Gopi

    The outputtext above is an example, I can use diff bundle keys like below,

    The principle is the same

    Dario

  • return two values of columns via Javascript

    For the same purpose as:

    OnClick = "$s ('P1_DEPTNO', #DEPTNO #); return false; »

    to return a value from column via javascript, is it possible to return 2 values? Example:

    OnClick = "$s ('P1_DEPTNO', #DEPTNO #); $s ('P1_EMP, #EMPLOYEE #); return false; »

    Thank you all :)

    Max

    Maxime Carrier wrote:
    Sorry for the wrong question form, I'm not an English speaker, so I try my best to make sentences clear.

    My goal is like this in this issue: Insert the value of a column in the report in a page with JavaScript element - 2?

    My Apex version is: 4.0.2.00.06
    My DB is: Oracle 11G
    My browser: IE 7

    I'm trying to save two values when I click on a link in a report. I will use these values in which the declaration of another report. The content of the second report will depend on the link I clicked in the 1st. It will change dynamically without reloading the entire page.

    Standard or interactive report?

    Where is the defined link? Column link IR? The column link? HTML embedded in the report query?

    One of the two values is not a number.

    Use quotes around chains of substitution of the column as shown above.

  • How to swap two values without using the third variable using the procedure

    How to exchange the two values without using the third variable using the procedure?

    In a procedure using two mode we pass two values A = x and B = y, and let us pass parameters to receive the output has A = y and B = x without using the third variable

    Published by: Millar on August 19, 2012 11:23

    Your question doesn't seem wise. As written, there is no reason to a third variable, just

    CREATE OR REPLACE PROCEDURE(
      x IN number,
      y IN number,
      a OUT number,
      b OUT number
    )
    AS
    BEGIN
      a := y;
      b := x;
    END;
    

    If it's an interview question, I suspect that the intention was that you had two settings IN OUT and you wanted to swap the values without the help of a third variable.

    Justin

  • How to return the value 0 for no data using the County?

    Hi all
    I used this query to count the number of records for each month of the year:

    SELECT DISTINCT COUNT (I.information_sid) COUNT, TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM') MONTH

    INFORMATION I

    TO_DATE GROUP (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    ORDER BY TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    But this code returns no value for months without data
    I want to return the value '0' for any month of data. How, please?

    Note: I use reports 6i.

    Maybe this?

    SELECT SUM(CNT_REC) CNT_REC, MONTH
    FROM
    (
    SELECT COUNT(I.information_sid) CNT_REC, TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM') MONTH
    FROM INFORMATIONS I
    GROUP BY TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM')
    UNION ALL
    SELECT 0, LPAD(ROWNUM,2,0)
    FROM ALL_OBJECTS
    WHERE ROWNUM <= 12
    )
    GROUP BY MONTH
    ORDER BY MONTH
    

    No need to SEPARATE during the use of GROUP BY.

    -Clément

  • How to add two values

    How to add varchar values in oracle. Consider that both are times values.but [both] data type is varchar and stroed table

    For example:

    Column1 Column2
    2.40: 10 05:22

    I need the result to the following format
    8.02 [8 hours and 2 minutes]

    user12059276 wrote:
    How to convert this format

    Assuming that the result is less than 24 hours:

    select to_char(trunc(sysdate) + interval '2:40:10' hour to second + interval '5:22:00' hour to second,'HH24:MI') dt
      from dual
    /
    
    DT
    -----
    08:02
    
    SQL> 
    

    SY.

  • How to return a message of a function

    Hi gurus,
    I wrote the function on my database related to the return of the specific table voucherdate
    I want to return one message if other that this condition means that if vouchers No. is not there or if there is no null vouchertype is provided.

    my function is
    -------------------
    create or replace fn_get_voucherdate (v_vouchertype in varchar2, v_compcode in numbers)
    date of return
    as
    date of v_voucherdate;
    Start
    If v_vouchertype = "B - P" then
    Select max (voucherdate) from v_voucherdate
    from sometables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = "C - P" then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = "C - R" then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;

    elsif v_vouchertype = s-P' then
    Select max (voucherdate) from v_voucherdate
    from someothertables where vouchertype = v_vouchertype and companycode = v_compcode;

    Return v_voucherdate;
    on the other
    return a message here;
    end if;

    but the message by not returning function showing no matter what return value error

    Please guide me how display a message to the user.

    Please answer...

    but the message by not returning function showing no matter what return value error

    as it is coded your function returns a DATE data type
    It cannot return any "message".

  • How to return the value of the SQL in the text element

    Hi friends

    I need you to guide me how I can print the return value of the SQL in a text element

    Suppose it's your function
    create or replace function get_value
    return number
    is
    begin
    return 3*2;
    end;
    /
    any help that I enjoyed

    Thank you

    >

    http://i46.Tinypic.com/11l0s5h.jpg

    This is ORA-06502: PL/SQL: digital error or value.

    Check the data type and size for items of text or any other variables or fields in the service.

  • How to return the value of messageLovChoice

    Hello
    I used messageLovChoice to implement of poplist and return value to other elements as lov. I'm not Toolbox example to create extenal Lov, I just use internal lov located in messageLovChoice.
    But if I do not run the VO that messageLovChoice used, the poplist show more... But I can search results lov table items, and other parameters can be set by lov selected/fast selected value.
    Poplist do have values, I for the poplist VO executequery. then when the page show first of all, there are values in poplist, but even choose poplist value, no value is derived and set other items.

    Could someone can help to lookinto it? From my understanding, messageLovChoice should be messageChoice and messageLovinput function, so the values should be returned to other elements through lov card when click poplist value, is it good?

    Best regards
    Eileen

    Hello

    According to my understanding, it uses LOV just to show the values (if the values are more than 30), what features are it of just a poplist not a LOV

    Kind regards
    Out Sharma

  • How to control two channels of simultaneous functions AFG 3200 B generator?

    The AFD 3200 B function generator has two channels. I want to use both channels generations some vague simultaneous sin. I downloaded the labview driver: Tektronix AFG 3000 Series.

    I did three things:

    (1) try to connect to two channels in VI.

    However, all the screws of example do not support the connection of the name of two channels simultaneously.

    (2) run only two signals generating VI with another name for channel at the same time.

    However, a single channel runs after the other.

    Do you have any suggestions?

    Thank you!

    Wu Yue

    Hey Wu,.

    You need two sine waves to be completely synchronized (aka having the same exact phase)?

    If they must be synchronized, then the AFG should on the two output channels at the same time, but you will probably need to configure serial in your program.

    If they do not need to be synchronized, then is there a reason why you would not be able to simply divided between the output signal two BNC? If this isn't an option, then you will probably need to make some kind of trigger to get both channels to start at the same time.

    Lars L

  • How to return an array from a function package

    It is a package, that give the type of table.

    But it does not work.

    create or replace package account_group is

    TYPE string_array IS the TABLE OF varchar2.

    function get_acc_by_vat_number (in_string varchar2) return string_array;

    end account_group;

    create or replace package body is account_group

    function get_acc_by_vat_number (in_string varchar2) return string_array is

    acc_array string_array;

    i the number;

    cursor c1 is

    (Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

    where commercial_flag = 'Y '.

    and l.franchise_code! = 'F29'

    and d.account_number = l.account_number

    and id_3 = in_string - vat_number

    - and ssn ='08-09-002272' - company_reg_num

    UNION

    Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

    where commercial_flag = 'Y '.

    and l.franchise_code = 'F29'

    and d.account_number = l.account_number

    and id_3 = in_string - vat_number

    - and ssn ='08-09-002272' - company_reg_num

    and there are

    (select 1 from WIZ_CUSTOMER_HP_OCCURRENCE p

    WHERE product_category_code in ('MID', "MVO")

    and p.account_number = l.account_number

    and p.service_address_id = l.service_address_id));

    Start

    I: = 0;

    for the news loop c1

    i: = i + 1;

    acc_array (i): = cur.account_number;

    end loop;

    Return acc_array;

    end;

    end account_group;

    Use the functions in pipeline, which give to the appellant, while the dataset is the treatment.

    create or replace package account_group is

    TYPE string_array IS the TABLE OF varchar2.

    function get_acc_by_vat_number (in_string varchar2) return string_array in pipeline;

    end account_group;

    create or replace package body is account_group

    function get_acc_by_vat_number(in_string varchar2) return pipeline string_array is

    acc_array string_array;

    i the number;

    cursor c1 is

    (Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

    where commercial_flag = 'Y '.

    and l.franchise_code! = 'F29'

    and d.account_number = l.account_number

    and id_3 = in_string - vat_number

    - and ssn ='08-09-002272' - company_reg_num

    UNION

    Select to_char (d.account_number) wiz_customer_descrip account_number d, wiz_customer_hp_life l

    where commercial_flag = 'Y '.

    and l.franchise_code = 'F29'

    and d.account_number = l.account_number

    and id_3 = in_string - vat_number

    - and ssn ='08-09-002272' - company_reg_num

    and there are

    (select 1 from WIZ_CUSTOMER_HP_OCCURRENCE p

    WHERE product_category_code in ('MID', "MVO")

    and p.account_number = l.account_number

    and p.service_address_id = l.service_address_id));

    Start

    I: = 0;

    for the news loop c1

    pipe row (c.account_number);

    end loop;

    return;

    end;

    end account_group;

  • How to return a value empty for a column

    Hi all

    We want to create an abridged version of the BI dashboards report that has the same number and order of the columns, but fewer lines. This will improve the size and performance of the load, Services dashboard.

    For some columns, we need empty values, which means that the content must be empty, but the column must appear in the report.

    I tried a few options in the tab "format of the column" under properties of the column of check and played with 'column header' and 'value', however, I couldn't get the desired effect.

    Can achieve us?

    Please suggest me on the same.

    Regds
    Mano

    If you want to add a column to the State and the column indicates no data except null, you can do this by adding a column to the area in question and change its format to two single quotes without space between them (which basically means the null value).

  • How to return a value from stored procedure.

    Hello

    I have an insert in which insert a username through generated sequence number.

    I need this generated sequence number stored procedure return.

    Kindly help me to achieve this goal.

    It might be useful if there is a code sample for the same thing.

    Thank you
    Ahmed Shareefuddin

    Something like this:

    create or replace procedure xproc (num out number) is
    begin
     insert into mytab values (myseq.nextval);
     select myseq.currval into num from dual;
    end;
    /
    

    Max
    http://oracleitalia.WordPress.com

Maybe you are looking for