Return the two values in PL/SQL function

Hi,
How to create the PL/SQL function to return two values based on arguments?
Can anyone suggest me the idea?
TIA,

Dhiva wrote:
How to create the PL/SQL function to return two values based on arguments?A function can return only a single "+thing+".
That thing can be a scalar value (single value). Such as date, number or string. E.g.
create or replace function F... return number is ..That thing can be a non-scalar value (array). E.g.
create or replace type TNumberArray is table of numbner;
create or replace function F... return TNumberArray is ..That thing can be a complex scalar structure (record/object type) E.g.
create or replace function F... return EMP%RowType is ..That thing can be a complex non-scalar structure (array of object/record types). E.g.
create object TNameValue is object(
  name varchar2(30),
  value varchar2(4000)
create or replace TNameValueArray is table of TNameValue;
create or replace function F... return TNameValue is ..The bottom line is think structured data. A function can return a single variable. But that variable can (and should be) a proper structured data variable - and can be complex and can be non-scalar.

Similar Messages

  • Unable to retreive the return value of pl/sql function using DB Adapter

    Dear Experts,
    I am using DB Adapter in my BPEL Process. Using DB Adapter I am invoking a PL / SQL function. I am able to send two input parameters for the pl/sql function. But I dont know how to retrieve the return value from the function. Please suggest me.
    Thanks,
    Rajesh

    Yes I am returning a value from PL/SQL function.
    Please see the code segments below,
    FUNCTION "TD_INSERT" (a TDINIT_TYPE, stops TDDETAIL_TABLE )
    RETURN VARCHAR2
    AS
    td_no Number;
    td_id Number;
    stop TDDETAILFULL_TYPE;
    length number;
    BEGIN
    insert into TD_INIT values( ----passing all the values here --------- );
    select max(tdno) into td_no from TD_INIT ;
    length := stops.count;
    for i in 1.. length loop
    stop := stops(i);
    insert into TD_DETAIL_FULL values(
    td_no, ------- );
    end loop;
    commit;
    RETURN td_no;
    END;
    Thanks,
    Rajesh

  • I Need to Return Two values or more from Function, Is this possible?

    Below is the offending query, I am trying to pass v_bu and v_po to this function, and after validations then return v_count and v_action is this possible in a function? I am having problem returning two values.
    see below code
    function po_edi_func(v_bu purchase_order.business_unit_id%type,
         v_po purchase_order.purchase_order_number%type)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    return v_count;
    end;

    Paul,
    This is becoming a nightmare to me, can you look at the below and tell me where I am having a problem
    This is the Function below
    CREATE OR REPLACE function po_edi_func(v_bu sewn.purchase_order.business_unit_id%type,
         v_po sewn.purchase_order.purchase_order_number%type,v_action_out OUT VARCHAR2)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    v_action_out := (lpad(v_count,8,'0')||lpad(v_action,1,' '));
    return v_action_out;
    end;
    and this is how I am calling it from my trigger which has to pass the v_bu and v_po values to be used in extracting data and returning the records
    see below
    if po_edi_func(v_bu,v_po) <> '' then;
    v_count:= (substr(v_action,1,8));
    v_action := substr(v_actione,9,1);
    else
    v_count:=0;
    v_action := 'I';
    end if;
    I need the extracted values of v_count and v_action for my app to reset some values

  • Function to return the Entry Value based on Assignment, Element and Date

    Hi Guys,
    Is there a function that returns the Entry Value for the Assignment Element, based on the Assignment Number, Element Name, Entry Segment and the End of Period date?
    Example:
    ==============
    Input Parameters:
    Employee: Iana
    Assignment Num: 123
    Element: D480
    Element Entry: Fund Name
    Output Parameter:
    Element Entry Value: MLC Super Fund
    Thanks,
    Iana

    For element entry values you can use:
    select petf.element_name, nvl(peevf.screen_entry_value,0) screen_entry_value
    from
    pay_element_entries_f peef, pay_element_types_f petf,
    pay_element_entry_values_f peevf, pay_input_values_f pivf,
    per_all_assignments_f paaf
    where petf.element_type_id = peef.element_type_id
    and :p_date_earned between pivf.effective_start_date and pivf.effective_end_date
    and :p_date_earned between petf.effective_start_date and petf.effective_end_date
    and peevf.input_value_id = pivf.input_value_id
    and paaf.assignment_id = peef.assignment_id
    and petf.business_group_id = :p_business_group_id
    and peevf.element_entry_id = peef.element_entry_id
    and :p_date_earned between peef.effective_start_date and peef.effective_end_date
    and :p_date_earned between peevf.effective_start_date and peevf.effective_end_date
    and :p_date_earned between paaf.effective_start_date and paaf.effective_end_date
    and pivf.name = :p_input_value_name
    and petf.element_name = :p_element_name
    and peef.entry_type = 'E'
    and peevf.effective_start_date = peef.effective_start_date
    and peevf.effective_end_date = peef.effective_end_date
    --and peef.assignment_id = :p_assignment_id
    and paaf.assignment_number = :p_assignment_number;
    For payroll results you can use:
    select sum(prrv.result_value)
    from pay_run_results prr, pay_run_result_values prrv,
    pay_assignment_actions paa, pay_payroll_actions ppa,
    pay_element_types_f petf, pay_input_values_f pivf,
    per_all_assignments_f paaf, per_all_people_f papf
    where
    petf.element_type_id = pivf.element_type_id
    and :p_pay_date between petf.effective_start_date and petf.effective_end_date
    and :p_pay_date between pivf.effective_start_date and pivf.effective_end_date
    and paa.assignment_action_id = prr.assignment_action_id
    and petf.element_type_id = prr.element_type_id
    and ppa.payroll_action_id = paa.payroll_action_id
    and prrv.input_value_id = pivf.input_value_id
    and prr.run_result_id = prrv.run_result_id
    and petf.element_name = :p_element_name
    and pivf.name = :p_input_value_name
    and ppa.date_earned = :p_pay_date
    and papf.person_id = paaf.person_id
    and nvl(prr.start_date,ppa.effective_date) between paaf.effective_start_date and paaf.effective_end_date
    and nvl(prr.start_date,ppa.effective_date) between papf.effective_start_date and papf.effective_end_date
    and paaf.assignment_id = paa.assignment_id
    and papf.employee_number = :p_employee_number;

  • The Popup dialog Page needs two times to return the selected value[10.1.3]

    Hi All,
    I have problem in an JSF Application that uses the EMP and DEPT tables .
    the Application contains two pages
    page 1 : a calling page uses EmpView as ADF Table .
    page 2 : a popup List of Values (LOV) dialog page uses DeptView
    These cause the popup dialog page to return to the calling page and to set the selected value into the Deptno attribute .
    the calling page includes :deptno and dname columns as
    <af:column headerText="#{bindings.EmpView1.labels.Deptno}">
    <af:selectInputText value="#{row.Deptno}"
    required="#{bindings.EmpView1.attrDefs.Deptno.mandatory}"
    columns="#{bindings.EmpView1.attrHints.Deptno.displayWidth}"
    action="dialog:ChooseDept1" id="deptnoField"
    autoSubmit="true">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.EmpView1.formats.Deptno}"/>
    </af:selectInputText>
    </af:column>
    <af:column headerText="#{bindings.EmpView1.labels.Dname}">
    <af:inputText value="#{row.Dname}" simple="true"
    required="#{bindings.EmpView1.attrDefs.Dname.mandatory}"
    columns="#{bindings.EmpView1.attrHints.Dname.displayWidth}"
    partialTriggers="deptnoField" autoSubmit="true"/>
    </af:column>
    and popup dialog page includes : Submit Button to return selected value to calling page :-
    <af:tableSelectOne text="Select and">
    <af:commandButton text="Submit">
    <af:returnActionListener value="#{row.Deptno}"/>
    <af:setActionListener from="#{row.Deptno}"
    to="#{bindings.Deptno.inputValue}"/>
    </af:commandButton>
    </af:tableSelectOne>
    the problem is
    I have to press ( two times ) the select button in the calling page to
    return the selected value into the Dname attribute .
    best regards,

    Hi,
    However, I am using the Jdeveloper 10.1.3.3, but still getting this error. I could not find any threads related to this problem and hence I wrote up here. Anyway I have also logged an SR #7179012.993 for the same with the testcase. I hope the issue will be resolved soon.
    Thanks,
    Neeraj

  • Return Into.  Can I return the old value in an update statement?

    Hello - I have an update statement and I need the value of a field, prior to the update. Is it possible to use the Return Into to do this? Or do I have to have a separate select statement prior to the update statement in order to store that value in a variable?
    Thanks!

    RETURNING INTO is valid for an UPDATE, but it returns the new value, not the old value.
    SCOTT @ nx102 Local> select * from a;
          COL1
             4
    Elapsed: 00:00:00.00
    SCOTT @ nx102 Local> ed
    Wrote file afiedt.buf
      1  declare
      2    l_old_col1 number;
      3  begin
      4    update a
      5       set col1=col1+1
      6     returning col1 into l_old_col1;
      7    dbms_output.put_line( l_old_col1 );
      8* end;
    SCOTT @ nx102 Local> /
    5
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00If you are trying to track historical changes, have you looked at Workspace Manager? That can be far easier than writing your own change tracking code...
    Justin

  • How do I return the displaysleep value from the console?

    I know that I can do pmset -g to list all the settings, including displaysleep, but I  was hoping there was a command similar to that for the screensaver which only returns the numerical value:
    defaults -currentHost read com.apple.screensaver idleTime
    Any possibility there is a console function that will return the value only?
    Thanks.

    Hi RavensFan,
    Thank you for your help.
    I have seen this Max/Min function, and I tried it, but I get an error becuase my signal is apprently "dynamic data" and the max/min function accepts double precision data, so thats the problem I am encountering at this moment. I have modified the block diagram to convert the "dynamic data" into a double and then do the same thing you suggested, but I will test it tomorrow in the lab. 
    I am currently working around this by using a numeric input, which the user would simply watch the sensor output over the calibration period and manually input that value into the formula.
    Thanks again!
    PackersFan btw...
    Cheers

  • GUID generation issue, SYSUUID always returns the same value.

    Hi,
    I'm using "SELECT SYSUUID FROM DUMMY" to get a guid value but it always return the same value.
    What should I do to get a unique value each time I execute the query above.
    Thanks.

    I thought I had the same problem and I found that if you generate multiple UUID's in the same SQL, it they will be the same.  If you make multiple calls, you should get multiple UUID's. 
    Try this:
    SELECT SYSUUID as UUID1 FROM DUMMY;
    SELECT SYSUUID as UUID2 FROM DUMMY;
    I get the following results:
    UUID1 = 538632FD7EA20426E10000000A3F10A9
    UUID2 = 538632FE7EA20426E10000000A3F10A9
    Notice that the strings look almost identical, but the 8th character on UUID1 is a D and the 8th on UUID2 is a E.
    Jim

  • Recursion:returning the largest value in a linked list

    import java.io.*;
    import java.util.*;
    class Node{
         int num;
         Node next;
         Node(int n){
              num = n;
              next = null;
    class RecursivePrint{
         public static void main(String[] args){
              Node np, last;
              Node top = null;
              last = null;
              for(int i = 1; i <11; i++){
                   np = new Node(i);
                   if(top==null)top = np;
                        else
                   last.next = np;
                   last = np;
              int x =Largest(top);
             System.out.println("large is "+ x);
         }//end main
         public static int Largest(Node top){
              int large = 0;
              if(top==null){
                   return 0;
                   while(top!=null){
               if(top.num > large){
                   large = top.num;
                   //top = top.next;
              Largest(top.next);     
         }//while
         return large;
    }//end class
    I am trying to return the largest value in a linked list (10) in this case.  when I do it withour recurrsion it works ok, but when I try it with recurrsion it dies.  The logic seems ok to me, cannot figure why it dies.

    chetah wrote:
    public static int Largest(Node top){
              int large = 0;
              if(top==null){
                   return 0;
              if(top.num > large){
                   large = top.num;
                   //top = top.next;
                   Largest(top.next);
         return large;
    Initially I had the above, it return only 1 that was the reason for puting the loop.You don't seem to understand recursion or variable scope.
    int large = 0;large is a different variable inside each instance of the method.
    So when you get back up to the value 1 from the recursive calls its just comparing 1 to 0
    Here's a solution...
         public static int Largest(Node top){
              if(top.next != null){
                   if(Largest(top.next) > top.num)
                        return Largest(top.next);}
              return top.num;
         }

  • How to assign the two values for constant (same key)

    How to assign the two values for constant (same key)
    CONSTANTS: c_pstkey TYPE  bschl VALUE '09',
               c_splgl  TYPE  umskz VALUE 'I',
               c_buzei  TYPE  buzei VALUE '001'.
    using BSCH1 again i have two asign vaue
    can you just let me know
    Edited by: sravya_se38 on Nov 23, 2010 12:14 AM

    You can create a structure for that constant .
    You can define in this way
    CONSTANTS : BEGIN OF c_pstkey,
                             01 TYPE bschl VALUE '01',
                             02 TYPE bschl VALUE '02',
                          END OF c_pstkey.
    and can access using...
    c_pstkey-01, c_pstkey-02 ........

  • Picking the right values from tables - SQL (select statement)

    Hi everyone,
    I'm facing the litlle(?) problem in Oracle environment.
    Let me explain:
    I have two tables.
    TABLE 1
    Id1 | Val1 | Id2 | Val2
    A | 44 | B | 36
    B | 36 | A | 44
    TABLE 2
    Id | Name
    A | New York
    B | Seattle
    I need to get from those tables, using SQL statement, result like this:
    Id1 | Val1 | Name1 | Id2 | Val2 | Name2
    A | 44 | New York | B | 36 | Seattle
    NOTE !! Very important!! If in table 1 we have crossed the same values in fields IdX and ValX in two rows (like in example)- just one of them should be presented as a result.
    I'm afraid it's a bit too complex. You, guys are my last hope.
    Looking forward for any solutions.
    Thanks in advance!

    jeneesh wrote:
    This can give you a startJaneesh, the OP specified that the duplication was across the ID and the VAL columns, but your solution only checks the ID's..
    SQL> ed
    Wrote file afiedt.buf
      1  with t1 as (select 'A' as id1, 44 as val1, 'A' as id2, 36 as val2 from dual union all
      2              select 'A', 36, 'A', 36 from dual)
      3      ,t2 as (select 'A' as id, 'New York' as name from dual union all
      4              select 'B', 'Seattle' from dual)
      5  -- END OF TEST DATA
      6  select distinct greatest(id1,id2) id1,
      7         case when id1 > id2 then val1 else val2 end val1,a.name name1,
      8         least(id1,id2) id2,
      9         case when id1 < id2 then val1 else val2 end val2,b.name name2
    10  from t1 t,t2 a,t2 b
    11  where greatest(id1,id2) = a.id
    12* and least(id1,id2) = b.id
    SQL> /
    I       VAL1 NAME1    I       VAL2 NAME2
    A         36 New York A         36 New York
    SQL>With this data I would have expected both rows to be returned as there is a difference in the val columns..
    SQL> ed
    Wrote file afiedt.buf
      1  with t1 as (select 'A' as id1, 44 as val1, 'A' as id2, 36 as val2 from dual union all
      2              select 'A', 36, 'A', 36 from dual)
      3      ,t2 as (select 'A' as id, 'New York' as name from dual union all
      4              select 'B', 'Seattle' from dual)
      5  -- END OF TEST DATA
      6      ,t3 as (select distinct id1, val1, id2, val2
      7              from
      8                (
      9                 select decode(switch,1,id2,id1) as id1
    10                       ,decode(switch,1,val2,val1) as val1
    11                       ,decode(switch,1,id1,id2) as id2
    12                       ,decode(switch,1,val1,val2) as val2
    13                 from (select id1, val1, id2, val2
    14                             ,case when id1||val1 > id2||val2 then 1 else 0 end as switch
    15                       from t1)
    16                )
    17             )
    18  --
    19  select t3.id1, t3.val1, t2_1.name
    20        ,t3.id2, t3.val2, t2_2.name
    21  from   t3 join t2 t2_1 on (t2_1.id = t3.id1)
    22*           join t2 t2_2 on (t2_2.id = t3.id2)
    SQL> /
    I       VAL1 NAME     I       VAL2 NAME
    A         36 New York A         36 New York
    A         36 New York A         44 New York

  • V$session prev_hash_value not returning the correct value?

    Hello,
    I am executing a plsql package (which has the following query) in two modes: through Toad and through a deployed web application. I get two results.
    SELECT sa.sql_text,
    sa.sql_id,
    ss.sid
    FROM v$session ss,
    v$sqlarea sa
    WHERE ss.status = 'ACTIVE'
    AND sa.hash_value = ss.prev_hash_value
    AND ss.username = USER;
    Toad gives me the correct result. The query above pulls the correct SQL statement. But when running through the web application it gives me
    some random SQL statement executed during that session. I thought it might have something to do with pooled JDBC connections so I made sure for that
    execution I created a new dedicated JDBC connection. Still did not work. I used the function SYS_CONTEXT('USERENV', 'SID') to report the session id
    from my java program and from the query above. Both return the same SID. I've tried different variations of that query above (removing status = ACTIVE, removing username = USER, etc...)
    and I still get the same result.
    So any thoughts on what's going on?
    Thanks,
    Piyush

    I believe I figured it out. My testing was flawed. The testing in Toad was directly calling my package (e.g., pkg_b). The web app doesn't do that. It calls pkg_a which does a bunch of setup and then calls the target package (pkg_b) using EXECUTE IMMEDIATE. Apparently the v$session stops collecting info at that point. The current statement always shows as 'BEGIN :b1 := pkg_b; END;'. But it's still confusing why it would do that. Is there another way to access SQL statements from within that dynamic block?

  • Returning the Prompt Value for a Variable

    Hi Experts,
    What I am currently trying to do is to return the values from a prompt so that I can use them in a variable. I have two Queries that are built off of two different Universes out of BEx. I do not have the same dimensions in both queries. I am merging the Universes based on the 'Employee ID' field, but I need to display Amount measures from both queries. Currently, this is functioning if I do not run any filters.
    However, as soon as I put a query filter on a dimension that does not exist within both Universes, I have a problem where Query1 is returning a dataset of maybe 10 records, while Query2 still returns a dataset of 100 records. Obviously this presents a problem when aggregating the Amount measures.
    I have tried a number of different ways to create a relationship between the measures and Employee, but I can't get things specific enough if I don't have the filtered dimension in the report. Suppose that I have Company Code filtered to 1200, I would like to show on the report only the employees from Company Code 1200. This is fine if I drag in the Employee dimension from Query1. However, once I drag in the Amount measure from Query2, the numbers are totalled for the entire 100 Employees, rather than the 10.
    I figure that I should be able to specify my results by leveraging some sort of formula. I'm currently experimenting with:
    =sum([Query2].[Amount] ForEach ([Company Code];[Query1].[Employee]) Where ([Company Code] = [Prompt1]))
    Prompt1:
    =UserResponse([Query1];"Prompt1")
    The problem with this is that the UserResponse does not return an array of values that were selected (otherwise it would say #MULTIVALUE). Instead, it seems to concatenate the selections by the user into one field. Unfortunately I can't use that for anything. Is there a way to capture the actual value from the prompt in an array?
    Alternatively, is there a better way to accomplish what I'm doing?
    Thanks,
    Brian Comeau

    Hi Brian
    I'm not familiar with Bex queries but have you tried adding using the query with the filter to be the driver for the values of the second query, so in effect you have 3 queriues:
    Query 1 with filter
    Query 2 with sub-query based on filtered query 1
    Regards
    Charles

  • Return type for a PL?SQL function

    Hi,
    I am trying to register a PL/SQL function with discoverer which returns more than one numerical values. What return type should i use for this function....cant see an array or something like it from the Diccover end, when I try to register it.
    Please help.
    -S

    S.
    If you create a function, then you can pass in parameters but only return one value for the function.
    That return datatype cannot be an array, but just one value (ie: varchar, number, etc.).
    Russ

  • Report query not returning the field value from external table

    hi
    I have an issue regarding reports. I have a query having 4 fields from external table and remaining from db tables. the report query returns all the fields from the db tables and only 2 fields from external table. but the same query if I tried in plsql developer it returns all the fields values.
    Can anyone please help me in this issue.
    Thanks and Regards
    kk

    Duplicate post?
    value not displaying in report whereas it returns in plsql developer
    value not displaying in report whereas it returns in plsql developer
    Please log a SR if you do not get any reply to your thread instead of creating new one.
    Thanks,
    Hussein

Maybe you are looking for

  • Installed mountain lion, now I cannot print wirelessly from imac or macbook

    I installed mountain lion. I updated as much as there is to update via software. Now when I try to print wirelessly from my imac and macbook pro it says "unalbe to find printer" and printer is not connected from both computers. I reconfigured the Bro

  • Videos take all the screen in Full Screen mode!!!!!

    I mean, if you have a flash, and a video on it, which is smaller than the size of the flash, AND if the project is set to be in Full Screen, then, when you publish it and test the .exe, the video will TAKE all the screen area! I have included some pi

  • Need help on how forms developer is used

    to everyone: im actually new at forms developer 2000,at really wondering how to use it though i have a background in SQL.If you have any data that you can share to me explaining the whole environment of Developer 200 please send it to me. Any help is

  • Do the ibook g4 12 inch and 14 inch use the same battry

    I need to replace the battery in my ibook g4 14 inch; i can find only batteries for the 12 inch.  do they use the same battery? thanks

  • Query taking too long

    I am running a fairly complex query with several table joins and it is taking too long. What can I do to improve performance? Thanks. Frank