Call two selects in a function?

Hi, I am fairly new to oracle.
I have written a function that returns a sql statement that I would like to execute and return the results.
I have another function that I can execute the statement with, I so far have no idea of how to put this together.
This is the one that returns a sql statement:
CREATE OR REPLACE function fnMyFunc1(var_in IN varchar2) return varchar2
as
x varchar(32767);
BEGIN
SELECT fnMyFunc2(var_in) into x from dual;
return x;
end;and this is the one that executes it:
create or replace function fnExecX(sql_in IN varchar2) return XmlType
as
x XmlType;
Begin
EXECUTE IMMEDIATE (fnExecV(sql_in)) into x;
return x;
end;I would like to just execute it in the first one and return the XmlType from the first function or have a function that calls the first one, gets the result, passes it to the second and returns the xmltype.
Any help would be much appreciated.

I am not sure if this is what you are looking for, anyway here is something I tried :
-- function that creates the dynamic sql
CREATE FUNCTION f2 (var_in VARCHAR2) RETURN VARCHAR2 IS
sql_str VARCHAR2(250);
BEGIN
sql_str := 'SELECT SYSDATE FROM '|| var_in;
RETURN sql_str;
END;
-- function that calls the dynamic sql creating function
CREATE FUNCTION f1 (var_in VARCHAR2) RETURN VARCHAR2 IS
sql_str VARCHAR2(250);
BEGIN
SELECT f2(var_in) INTO sql_str FROM dual;
RETURN sql_str;
END;
-- function that executes the dynamic query :
CREATE FUNCTION f3 (var_in VARCHAR2) RETURN DATE IS
exec_sql VARCHAR2(250);
dd DATE;
BEGIN
SELECT f1(var_in) INTO exec_sql FROM dual;
EXECUTE IMMEDIATE exec_sql INTO dd;
RETURN dd;
END;
-- output from sqlplus
SQL> select f3('dual') from dual;
F3('DUAL'
21-DEC-05
SQL>
HTH

Similar Messages

  • Calling a Selection Screen from a Function Module/Method

    Hi,
      I would like to call a selection screen from a function module or method. I understand it is not possible by the definition. Are there any alternative options as I am looking for the Variants Save option on the screen. Any thoughts?
    Thanks
    Raghav

    Since i don't know your exact requirements (standard SAP selection screen? your own selection screen?) the onl;y thing i can come up with is:
    1. in your function pool create your own screen with a subscreen area
    2. create your own selection screen as a subscreen.
    3. include the selection subscreen in the first screen
    4. call the first screen in your function.

  • How to define select option in function module

    Hi expert,
                           Actually in my program i am using two select options plant and project definition. i have to pass those two select options to my function module. What i did is i declared that two select options in tables tab using RSDSSELOPT structure. My function module is working correctly when i am testing in se37 but if i am calling my function module from my program its showing dump error 'TYPE CONFLICT WHEN CALLING A FUNCTION MODULE(field length)'. please tell me how to solve this problem.
    Regards,
    Rathish

    Problem solved

  • More than one selects in a function

    Hi All,
    Is it that there can not be more than one selects in a function?What is the work around for this thing?
    Regards,
    Amit.

    Hi Krystian Zieja ,
    Thanks for responding. I do not know what was going wrong but now it is working fine.
    The problem is that I was not able to compile a function with two select statements in it. If I could comment one of the select statements it was getting compiled. But now it is getting compiled with both the selects.
    Now since we are at it can you solve another of my problem. I want to see the output of my function. If I write DBMS_OUTPUT.PUT_LINE statements in it I am not able to see the output. Is there anyway that I can call my function and it can show the output on the screen.
    I am using Benthic Golden 32 editor. Is there any way in it that I can call my function from it ?
    Regards,
    Amit.

  • Calling two transaction in one Zprogram

    How to call two transaction (MIGO and MIRO)with each transaction should display two different window simultaneously from one Zprogram..
    Pls let me know ...

    Hello Arun
    If you like to use an ABAP-OO version here is my approach:
    *& Report  ZUS_SDN_CALL_TRANSACTION
    REPORT  zus_sdn_call_transaction.
    TYPE-POOLS: abap.
    PARAMETERS:
      p_tcode      TYPE tcode.
    START-OF-SELECTION.
      CALL FUNCTION 'AUTH_CHECK_TCODE'
        EXPORTING
          tcode                          = p_tcode
        EXCEPTIONS
          parameter_error                = 1
          transaction_not_found          = 2
          transaction_locked             = 3
          transaction_is_menu            = 4
          menu_via_parameter_transaction = 5
          not_authorized                 = 6
          OTHERS                         = 7.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL METHOD cl_reca_gui_services=>call_transaction
        EXPORTING
          id_tcode             = p_tcode
    *      IF_LEAVE_CURRENT     = ABAP_FALSE
    *      IF_SKIP_FIRST_SCREEN = ABAP_FALSE
           if_new_external_mode = abap_true  " new mode
        EXCEPTIONS
          error                = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    END-OF-SELECTION.
    Regards
      Uwe

  • How to call two RFC in a single JAVA method.

    Dear all,
    I just want to know that how to call two RFC in a single java method which is defined in CRM implementation file. I'm using NWDS as the customization IDE & working on ISA 7.0.

    Hi Sunil,
    In the Backend Implementation class, in any method you can call multiple RFCs.
    It will be the same way as you do for the single RFC call.
    Following syntax is for your reference.
    Get the JCO connection
    JCoConnection  connection = getDefaultJCoConnection();
    JCO.Function func = connection.getJCoFunction("ZXXXXXXX");
    set the import parameters
    Execute it.
    connection.execute(func);
    get the data from export / table parameters
    Now call the second RFC
    func = connection.getJCoFunction("ZYYYYYYYYYY");
    set the import parameters
    Execute it.
    get the data from export / table parameters
    close the connection
    Hope this will help you.
    -Chandra.
    Edited by: Chandra Sekhar Seeli on Jan 13, 2011 2:04 PM

  • How to call two data blocks at a time.

    hi all
    i want to call two data blocks at a time on function when button pressed.
    how can I it?
    many thanks

    Many thanks that you people reply,
    I am working in oracle form developer 6i and database 10g.
    I have a form that have three data blocks,
    first block have text boxes and search button,and next two blocks display records on the basis of search criteria that is inserted in the first block and when is clicked on save button.
    the data that is to b displayed is from two different tables.
    i used Go_block('my_block')
    and call other block with the same method.
    kindly guide me how can i do it.
    Thanks in advance

  • Two selection screen problem in one report

    i have a two selection screens 1000 & 2000 in single report , which needs to be executed one after the other ,
    the problem is when i execute second selection screen(2000) , the cursor is going back to at-selection-screen once again.
    but i need to trigger start-of-selection directly after executing second selection screen,
    the first selection screen 1000 will be executed with the help of select options..
    the sample code is below .
    at-selection-screen.
        perform validations.
       call selection screen 2000.
        at selection screen on value request p_adm
    start-of-selection.
       main logic

    Moderator message - Cross post locked
    Rob

  • Can i  use Two DSO 's in Function module

    hi experts,
    Can i  use Two DSO 's in Function module  .That FM is used for Layout
    I actually  want to  fill one DSO Refering the Data in Another DSO.
    Regard
    Naresh.

    In the first way the DSO's are usually called shared libraries or DSO libraries and named libfoo.so or libfoo.so.1.2. They reside in a system directory (usually /usr/lib) and the link to the executable program is established at build-time by specifying -lfoo to the linker command. In the second way the DSO's are usually called shared objects or DSO files and can be named with an arbitrary extension

  • Total funcnality of select options in function module

    Dear ABAPers
    i am using structure and  ranges  to meet the functionality of select-options in function module3
    but unlike reports if i leave it blank rather than selecting all the data it comes blank.
    how can i do that
    coz my select query uses 8 selection criteria and user may enter one two or three as per his need.
    in that case the output comes out to be blank.
    how this can be resolved
    Thanks and Regards
    Luthra, Deep.

    You have to maintain conditions for all your possibilities.
    Something like this.
      IF ( post_dt_from IS INITIAL AND post_dt_to IS INITIAL AND
       doc_dt_from IS INITIAL AND doc_dt_to IS INITIAL ) OR
         ( post_dt_from IS INITIAL AND post_dt_to IS NOT INITIAL AND
       doc_dt_from IS NOT INITIAL AND doc_dt_to IS NOT INITIAL ) OR
         ( post_dt_from IS NOT INITIAL AND post_dt_to IS INITIAL AND
       doc_dt_from IS NOT INITIAL AND doc_dt_to IS NOT INITIAL ) OR
         ( post_dt_from IS NOT INITIAL AND post_dt_to IS NOT INITIAL AND
       doc_dt_from IS INITIAL AND doc_dt_to IS NOT INITIAL ) OR
         ( post_dt_from IS NOT INITIAL AND post_dt_to IS NOT INITIAL AND
       doc_dt_from IS NOT INITIAL AND doc_dt_to IS INITIAL ) OR
       ( post_dt_from IS NOT INITIAL AND post_dt_to IS INITIAL AND
       doc_dt_from IS INITIAL AND doc_dt_to IS INITIAL ) OR
         ( post_dt_from IS INITIAL AND post_dt_to IS NOT INITIAL AND
       doc_dt_from IS INITIAL AND doc_dt_to IS INITIAL ) OR
         ( post_dt_from IS INITIAL AND post_dt_to IS INITIAL AND
       doc_dt_from IS NOT INITIAL AND doc_dt_to IS INITIAL ) OR
         ( post_dt_from IS INITIAL AND post_dt_to IS INITIAL AND
       doc_dt_from IS INITIAL AND doc_dt_to IS NOT INITIAL ) OR
        ( ( post_dt_from IS NOT INITIAL AND post_dt_to IS NOT INITIAL ) AND
         ( doc_dt_from IS NOT INITIAL AND doc_dt_to IS NOT INITIAL ) ).

  • Requirement wherein I want to call two queries in parallel using ABAP Prg

    We are using RSCRM_BAPI to run a query in background and write the results to a table. We later read this table and create a file. I have a requirement u2013 wherein I want to call two queries in parallel using an ABAP program.
    For our discussion assume:
    1) Program : ZCALL_RCRMBAPI  is a program that calls RSCRM_BAPI in background and takes the query name as input
    2) Program: ZMAIN_PROGRAM  this is the main program
    The requirement is to call the ZCALL_RCRMBAPI in a loop. Also within the loop call it in parallel. Basically we have an ODS that stores ; FISCPER. So I call the two queries for a list of FISCPER.
    ZMAIN_PROGRAM - A program that reads a table (ODS ) in our case and call the two programs in a loop and both should run in parallel .
    Now if it was sequential u2013 it was easy u2013 I would just say
    Loop at L_T_FISCPER .
    Update Z_FISCPER with L_T_FISCPER-FISCPER u201C Assume Z_FISCPER is a Z table . The VARIABLE in the query Q1 and Q2 use a customer exit to read this table.
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .
    Endloop .
    Question: How do I make these calls in parallel u2013 yet retain control in the main program?
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .

    Instead of RSCRM BAPI you can use the RRW3_QUERY_VIEW_DATA function module for greater control over program execution...
    /people/arun.varadarajan/blog/2009/07/29/make-the-most-out-of-query-execution--part-1
    will give you pointers as to how this can be done...

  • Using selection options in functions..

    Hi,
    I have written abap program in which there are 3 selection options.. I want to pass these selection options to a function.  so I want to know how to define or refer selection options in functions which is called by some other abap program ?
    Regards,
    Santosh

    The select options are basically just tables with a specific structure. One option would be to specify them as TABLES parameters, e.g. check out function module BAPI_MATERIAL_GETLIST and you can see for example a call via function IAC_SHMA_MATERIALS_SELECT (or check dictionary table type SHP_MATNR_RANGE_T in SE11).
    Cheers, harald

  • How to use select a vi function inside a loop?

    I am modifying the notifier basics part 2.vi to send a notifier to each of 64 sub-vi's. How can you use the 'select a vi' function inside a loop for 64 iterations to access the individual filenames??
    Attachments:
    Notifier_BASICS_Part_2.vi ‏87 KB

    If all you are trying to do is send notifiers to each of these 64 subVIs, I would suggest not doing it in a loop, but rather just placing the 64 subVIs in your diagram.
    The alternative is of course to use the call by reference node and have an array of VI names. This is a little cleaner on the diagram, but 1) doesn't occur in parallel and 2) is a bit tricky. Additionally, you have to be sure that your array of filenames is correct, and that you NEVER move or rename those VIs. Of course, you could always put them in a directory and create an array by reading the directory contents.
    Either way, good luck, it doesn't sound like fun.

  • Calling a stored workspace procedure/function in page template

    I have an unusual puzzle. I am trying to find a way to call a stored procedure or function in a page template; ie, through HTML/javascript.
    I maintain a website with several dozen applications and I currently have the page templates in all of these applications subscribed to one master template, so that changes can be made in one place and implemented across all the applications. So far, the only content I can display on every page in every application through page template subscription is static content; dynamic content (ie content generated based on data in the database) is implemented page-by-page (or application-by-application).
    I'm wondering if there is a way to call stored procedures/functions from the page template to create dynamic content (based on the :APP_USER identity, for example). htmldb_Get() doesn't seem to be helpful, because as far as I can tell it only calls on-demand application processes, not workspace procedures/functions.
    Is there any way at all that a workspace procedure/function can be called directly from the page template (eg with a javascript function of some kind)? Again, I am trying to avoid having to use any application/page-level apex entities (items, processes, etc) so that I can just put the javascript or whatever in the page template and refresh all the applications in my workspace.
    Thanks in advance!
    Jonathan Cole
    PS - I am currently using v3.1

    Just to add the owner in output :
    SCOTT@demo102> ed
    Wrote file afiedt.buf
      1  select owner, table_name, ltrim(max(sys_connect_by_path(column_name,','))
      2                     keep (dense_rank last order by position),',') as PKcolumns
      3  from
      4  (select a.owner, a.table_name, b.column_name, b.position
      5   from all_tables a, all_cons_columns b, all_constraints c
      6   where a.owner=b.owner
      7   and   a.table_name=b.table_name
      8   and   b.owner=c.owner
      9   and   b.constraint_name=c.constraint_name
    10   and   c.constraint_type='P'
    11   and   a.table_name in ('SDO_COORD_AXES','EMP'))
    12  group by owner, table_name
    13  connect by prior owner = owner and prior table_name = table_name and prior position = position - 1
    14* start with position = 1
    SCOTT@demo102> /
    OWNER                          TABLE_NAME                      PKCOLUMNS
    MDSYS                          SDO_COORD_AXES                  COORD_SYS_ID,ORDER
    SCOTT                          EMP                             EMPNO
    SCOTT@demo102> Nicolas.

  • Dynamic actions in two select list

    Hi all,
    I have created two select lists.one is parent another is child.
    i can get the child list values correctly using cascading lov parent item
    Eg: parent item values company name :x,y,z etc
    x having 3 clients say a,b,c
    there is no client for y
    z having 2 clients say d,e
    now i want to hide the child item once the parent having no child.
    The moment when i select 'y' for the above example i want to hide the child item.
    How can i do that?

    Hi,
    You can do the following:
    1. Create a hidden page item, say PX_HIDE_SHOW_FLG
    2. Create a Dynamic Action of the type "Set Value" on the parent item to update PX_HIDE_SHOW_FLG. You can choose the "Set Type" as "PL/SQL Function Body". The function code should return 'Y' or 'N' based on the logic (count the number of children under the selected parent). You can trigger this DA on "change" of the parent item.
    3. Now, create another DA on PX_HIDE_SHOW_FLG to hide/show the child LOV item based on its value. For, example, if value (of the hidden page item) = 'Y', then hide, else show.
    Thanks,
    Rohit

Maybe you are looking for

  • How can I block spam e-mail when the "from address" keeps changing?

    How can I block a spam mail sender when that spamer uses a different e-mail address everytime!  I have set up a rule with the spamers name (which does not change) and setting the rule to "is equal to" but it is not working. 

  • Plan, Actual & Commitment Report in Multiple Currency

    Dear SAP gurs, Is there any report where I can see Plan, Actual & Commitments in Multiple currency (see below format). In standard SLAR reports, values are displayed in one currency at a time either I can see in INR or USD. Here each WBS is planed in

  • Crystal Reports Basic for Visual Studio 2008 - Export to PDF in arabic font space issue

    When exporting the crystal report having Arabic contents to PDF , space characters are replaced with " . Please find the attachment . Is there any way to sort out this issue??

  • Sent email gets marked as 'unread'

    Hi all, I'm getting two rather frustrating issues on Apple Mail. Firstly, sent emails are starting to, on occasion (probably 50% of the time), get marked as 'unread' in my sent mailbox. This was not an issue in the past. Secondly, my to do items are

  • Movie disappears after screen saver kicks in

    If my screen saver (it doesn't matter which one) kicks in while watching a movie, after I press a key to stop the screen saver, Quicktime still plays the movie but there's nothing on the screen, all I see is my background. I can hear the sound, but n