Performace Which is better ?  : Bapi inside a loop OR Select from Tables

Hi Gurus,
I have a report which displays purchase info records.
If I am selecting from tables i need to use EINA, EINE, EORD and some other tables.
There is a BAPI which gets all purchase info records specific to a vendor , material , purchasing organisation.
QUESTION: Performace wise which is the better Approach, either selecting from tables or BAPI for Purchase info records
Regards
Avi.

Whether it using BAPI or select. you need to check the performance. If you have full key for these tables EINA, EINE, EORD  then mak a select outside of the loop and within loop use READ TABLE statement with binary search. of if you want multiple records within loop then use loop insdie loop.
Your final objective is to minimise the database hits . If you use bapi inside loop then your database hits will be more
select from EINA
select from EINE
select from EORD
loop at itab,
  read table EINA
  read table EINE
  read table EORD
endloop

Similar Messages

  • How to create a dynamic RTF report which creates dynamic columns based on dynamic column selection from a table?

    Hi All,
    Suppose I have table, whose structure changes frequently on daily basis.
    For eg. desc my_table gives you following column name on Day 1
    SQL > desc my_table;
    Output
    Name
    Age
    Phone
    On Day 2, two more columns are added, viz, Address and Salary.
    SQL > desc my_table;
    Output
    Name
    Age
    Phone
    Address
    Salary
    Now I want to create an Dynnamic RTF report which would fetch data from ALL columns from my_table on daily basis. For that I have defined a concurrent program with XML as output type and have attached a data template/data definition to it which takes in XML as input and gives final output of conc program in EXCEL layout. I am able to do this for constant number of columns, but dont know how to do it when the number of columns to be displayed changes dynamically.
    For Day 1 my XML file should be like this.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
    </group>
    </dataStructure>
    </dataTemplate>
    And my Day 1, EXCEL output from RTF template should be like this.
    Name     Age     Phone
    Swapnill     23     12345
    For Day 2 my XML file should be like this. With 2 new columns selected in SELECT clause.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    SELECT Name
    ,Age
    ,Phone
    ,Address
    ,Salary
    FROM my_table
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_my_table" source="Q2">
      <element name="Name" value="Name" />
      <element name="Age" value="Age" />
      <element name="Phone" value="Phone" />
      <element name="Address" value="Address" />
      <element name="Salary" value="Salary" />
    </group>
    </dataStructure>
    </dataTemplate>
    And my Day 2, EXCEL output from RTF template should be like this.
    Name     Age     Phone     Address     Salary
    Swapnill     23     12345         Madrid     100000
    Now, I dont know below things.
    Make the XML dynamic as in on Day 1 there must be 3 columns in the SELECT statement and on Day 2, 5 columns. I want to create one dynamic XML which should not be required to be changed if new columns are added in my_table. I dont know how to create this query and also create their corresponding elements below.
    Make the RTF template dyanamic as in Day1 there must 3 columns in EXCEL output and on Day 2, 5 columns. I want to create a Dynamic RTF template which would show all the columns selected in Dynamic XML.I dont know how the RTF will create new XML tags and how it will know where to place it in the report. Means, I can create RTF template on Day 1, by loading XML data for 3 columns and placing 3 XML tags in template. But how will it create and place tags for new columns on Day 2?
    Hope, you got my requirement, its a challenging one. Please let me know how I can implement the required solution using RTF dynamically without any manual intervention.
    Regards,
    Swapnil K.
    Message was edited by: SwapnilK

    Hi All,
    I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
    Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
    Please let me know if there is any oracle functionality to do this.
    If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
    For eg, /$APPL_TOP/ar/1.0/sql or something.
    Regards,
    Swapnil K.

  • ORA-14551 when using rules manager inside a SELECT * FROM TABLE(myFunction)

    Hello
    I want to return rows from a pipelined function, and map this to a view, or a BC4J an query this in my application.
    I want to populate the rows based on many evaluations, to achieve this, I want to include the rules manager functionality.
    I have defined my event, rule class and result view successfully, but... when I run my query, I have the following error:
    ORA-14551: cannot perform a DML operation inside a query
    We believe this is caused when the engine tries to populate the results view with the matching rules.
    Is there a workaround for this?
    Please help
    Thnks in advance.
    Alex.

    Alex,
    I cannot think of any workaround that would allow you to evaluate the rules and return the results with a single query. A Rules Manager application with composite events modifies the state of the database (for maintaining incremental state as well as the results view) when some events are processed. So, you will not be able to pipeline the results to a SQL query. If you can at least separate the ADD_EVENTS call from the rest of the logic this may be possible.
    Hope this helps,
    -Aravind.

  • Is there BAPI to insert/del/update/select customer table

    I need to maintain customer table using RFC, but after try, I found that there are some problem.
          Something can execute at ECC system but it will fail at RFC interface, So I would like to know if there is a way to maintain it.

    Hi,
    Check these BAPI's
    BAPI_CUSTOMER_CREATE Create Customer Master Online
    BAPI_CUSTOMER_CREATEFROMDATA1
    Regards,
    Jyothi CH.

  • Which is fast ? Select * from tableName or Select Column1,Column2 .... From tableName ? and Why ?

    Which is fast ? Select * from tableName or Select Column1,Column2 .... From tableName ? and Why ?
    select * from Sales.[SalesOrderHeader]
    select SalesOrderNumber,RevisionNumber,rowguid from Sales.[SalesOrderHeader]
    As you can see both the query execution plan and subtree cost is same. So how selecting the particular columns optimize the query ?

    Which is fast ? Select * from tableName or Select Column1,Column2 .... From tableName ? and Why ?
    select * from Sales.[SalesOrderHeader]
    select SalesOrderNumber,RevisionNumber,rowguid from Sales.[SalesOrderHeader]
    As you can see both the query execution plan and subtree cost is same. So how selecting the particular columns optimize the query ?
    Yes, selecting specific columns is always better than select *.
    If you always need few columns in result, then just use SELECT col1, col2 FROM YourTable. If you SELECT * FROM YourTable; that is extra useless overhead.
    If in future if someone adds Image/BLOB/Text type columns in your table, using SELECT * will worsen the performace for sure.
    Let's say if you have SP and you use INSERT INTO DestTable SELECT * FROM TABLE which runs fine BUT again if someone adds few more columns then your SP will fail saying provided columns don't match.
    -Vaibhav Chaudhari

  • Help with Trigger - looping through SELECT results

    How do I loop through a SELECT query within a Custom Trigger? I can
    execute the query fine, but the PHP mysql_xxx_xxx() functions don't
    appear to work inside a custom trigger. For example:
    This ends up empty:
    $totalRows_rsRecordset = mysql_num_rows($rsRecordset);
    While this returns the correct # of records:
    $totalRows_rsRecordset = $rsRecordset->recordCount();
    I need to loop through the records like I would with
    mysql_fetch_assoc(), but those mysql_xxx_xxx() don't seem to work.
    This works great outside a custom trigger, but fails inside a custom
    trigger:
    do {
    array_push($myArray,$row_Recordset['id_usr']);
    while ($row_Recordset= mysql_fetch_assoc($Recordset));
    What am I missing?
    Alec
    Adobe Community Expert

    Although the create trigger documentation does use the word "must", you are quite free to let the trigger fire during a refresh of the materialized view. Generally, you don't want the trigger to fire during a materialized view refresh-- in a multi-master replication environment, for example, you can easily end up with a situation where a change made in A gets replicated to B, the change fired by the trigger in B gets replicated back to A, the change made by the trigger in A gets replicated back to B, in an infinite loop that quickly brings both systems to their knees. But there is nothing that prevents you from letting it run assuming you are confident that you're not going to create any problems for yourself.
    You do need to be aware, however, that there is no guarantee that your trigger will fire only for new rows. For example, it is very likely that at some point in the future, you'll need to do a full refresh of the materialized view in which case all the rows will be deleted and re-inserted (thus causing your trigger to fire for every row). And if your materialized view does anything other than a simple "SELECT * FROM table@db_link", it is possible that an incremental refresh will update a row that actually didn't change because Oracle couldn't guarantee that the row would be unchanged.
    Justin

  • "cannot perform a DML operation inside a query" error when using table func

    hello please help me
    i created follow table function when i use it by "select * from table(customerRequest_list);"
    command i receive this error "cannot perform a DML operation inside a query"
    can you solve this problem?
    CREATE OR REPLACE FUNCTION customerRequest_list(
    p_sendingDate varchar2:=NULL,
    p_requestNumber varchar2:=NULL,
    p_branchCode varchar2:=NULL,
    p_bankCode varchar2:=NULL,
    p_numberOfchekbook varchar2:=NULL,
    p_customerAccountNumber varchar2:=NULL,
    p_customerName varchar2:=NULL,
    p_checkbookCode varchar2:=NULL,
    p_sendingBranchCode varchar2:=NULL,
    p_branchRequestNumber varchar2:=NULL
    RETURN customerRequest_nt
    PIPELINED
    IS
    ob customerRequest_object:=customerRequest_object(
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
    condition varchar2(2000 char):=' WHERE 1=1 ';
    TYPE rectype IS RECORD(
    requestNumber VARCHAR2(32 char),
    branchRequestNumber VARCHAR2(32 char),
    branchCode VARCHAR2(50 char),
    bankCode VARCHAR2(50 char),
    sendingDate VARCHAR2(32 char),
    customerAccountNumber VARCHAR2(50 char),
    customerName VARCHAR2(200 char),
    checkbookCode VARCHAR2(50 char),
    numberOfchekbook NUMBER(2),
    sendingBranchCode VARCHAR2(50 char),
    numberOfIssued NUMBER(2)
    rec rectype;
    dDate date;
    sDate varchar2(25 char);
    TYPE curtype IS REF CURSOR; --RETURN customerRequest%rowtype;
    cur curtype;
    my_branchRequestNumber VARCHAR2(32 char);
    my_branchCode VARCHAR2(50 char);
    my_bankCode VARCHAR2(50 char);
    my_sendingDate date;
    my_customerAccountNumber VARCHAR2(50 char);
    my_checkbookCode VARCHAR2(50 char);
    my_sendingBranchCode VARCHAR2(50 char);
    BEGIN
    IF NOT (regexp_like(p_sendingDate,'^[[:digit:]]{4}/[[:digit:]]{2}/[[:digit:]]{2}$')
    OR regexp_like(p_sendingDate,'^[[:digit:]]{4}/[[:digit:]]{2}/[[:digit:]]{2}[[:space:]]{1}[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}$')) THEN
    RAISE_APPLICATION_ERROR(-20000,cbdpkg.get_e_m(-1,5));
    ELSIF (p_sendingDate IS NOT NULL) THEN
    dDate:=TO_DATE(p_sendingDate,'YYYY/MM/DD hh24:mi:ss','nls_calendar=persian');
    dDate:=trunc(dDate);
    sDate:=TO_CHAR(dDate,'YYYY/MM/DD hh24:mi:ss');
    condition:=condition|| ' AND ' || 'sendingDate='||'TO_DATE('''||sDate||''',''YYYY/MM/DD hh24:mi:ss'''||')';
    END IF;
    IF (p_requestNumber IS NOT NULL) AND (cbdpkg.isspace(p_requestNumber)=0) THEN
    condition:=condition|| ' AND ' || ' requestNumber='||p_requestNumber;
    END IF;
    IF (p_bankCode IS NOT NULL) AND (cbdpkg.isspace(p_bankCode)=0) THEN
    condition:=condition|| ' AND ' || ' bankCode='''||p_bankCode||'''';
    END IF;
    IF (p_branchCode IS NOT NULL) AND (cbdpkg.isspace(p_branchCode)=0) THEN
    condition:=condition|| ' AND ' || ' branchCode='''||p_branchCode||'''';
    END IF;
    IF (p_numberOfchekbook IS NOT NULL) AND (cbdpkg.isspace(p_numberOfchekbook)=0) THEN
    condition:=condition|| ' AND ' || ' numberOfchekbook='''||p_numberOfchekbook||'''';
    END IF;
    IF (p_customerAccountNumber IS NOT NULL) AND (cbdpkg.isspace(p_customerAccountNumber)=0) THEN
    condition:=condition|| ' AND ' || ' customerAccountNumber='''||p_customerAccountNumber||'''';
    END IF;
    IF (p_customerName IS NOT NULL) AND (cbdpkg.isspace(p_customerName)=0) THEN
    condition:=condition|| ' AND ' || ' customerName like '''||'%'||p_customerName||'%'||'''';
    END IF;
    IF (p_checkbookCode IS NOT NULL) AND (cbdpkg.isspace(p_checkbookCode)=0) THEN
    condition:=condition|| ' AND ' || ' checkbookCode='''||p_checkbookCode||'''';
    END IF;
    IF (p_sendingBranchCode IS NOT NULL) AND (cbdpkg.isspace(p_sendingBranchCode)=0) THEN
    condition:=condition|| ' AND ' || ' sendingBranchCode='''||p_sendingBranchCode||'''';
    END IF;
    IF (p_branchRequestNumber IS NOT NULL) AND (cbdpkg.isspace(p_branchRequestNumber)=0) THEN
    condition:=condition|| ' AND ' || ' branchRequestNumber='''||p_branchRequestNumber||'''';
    END IF;
    dbms_output.put_line(condition);
    OPEN cur FOR 'SELECT branchRequestNumber,
    branchCode,
    bankCode,
    sendingDate,
    customerAccountNumber ,
    checkbookCode ,
    sendingBranchCode
    FROM customerRequest '|| condition ;
    LOOP
    FETCH cur INTO my_branchRequestNumber,
    my_branchCode,
    my_bankCode,
    my_sendingDate,
    my_customerAccountNumber ,
    my_checkbookCode ,
    my_sendingBranchCode;
    EXIT WHEN (cur%NOTFOUND) OR (cur%NOTFOUND IS NULL);
    BEGIN
    SELECT requestNumber,
    branchRequestNumber,
    branchCode,
    bankCode,
    TO_CHAR(sendingDate,'yyyy/mm/dd','nls_calendar=persian'),
    customerAccountNumber ,
    customerName,
    checkbookCode ,
    numberOfchekbook ,
    sendingBranchCode ,
    numberOfIssued INTO rec FROM customerRequest FOR UPDATE NOWAIT;
    --problem point is this
    EXCEPTION
    when no_data_found then
    null;
    END ;
    ob.requestNumber:=rec.requestNumber ;
    ob.branchRequestNumber:=rec.branchRequestNumber ;
    ob.branchCode:=rec.branchCode ;
    ob.bankCode:=rec.bankCode ;
    ob.sendingDate :=rec.sendingDate;
    ob.customerAccountNumber:=rec.customerAccountNumber ;
    ob.customerName :=rec.customerName;
    ob.checkbookCode :=rec.checkbookCode;
    ob.numberOfchekbook:=rec.numberOfchekbook ;
    ob.sendingBranchCode:=rec.sendingBranchCode ;
    ob.numberOfIssued:=rec.numberOfIssued ;
    PIPE ROW(ob);
    IF (cur%ROWCOUNT>500) THEN
    CLOSE cur;
    RAISE_APPLICATION_ERROR(-20000,cbdpkg.get_e_m(-1,4));
    EXIT;
    END IF;
    END LOOP;
    CLOSE cur;
    RETURN;
    END;

    Now what exactly would be the point of putting a SELECT FOR UPDATE in an autonomous transaction?
    I think OP should start by considering why he has a function with an undesirable side effect in the first place.

  • Which is better??? for loop or bulk collect

    declare
    cursor test is
    select * from employees;
    begin
    open test;
    loop
    exit when test%notfound;
    fetch test into myvar_a(i); CASE A
    i:=i+1;
    end loop;
    close test;
    open test;
    fetch test bulk collect into myvar_b; CASE B
    close test;
    end;
    Which case is better?? A or B?
    Edited by: Kakashi on May 31, 2009 12:54 AM

    Depends on the meaning of better.
    Generally case B should be faster although a bit more elaborate code is required.
    But there may be exceptions. I think I read somewhere (I'm home now and I cannot find it at the moment) that in 10g (or 11g - not sure) 100 rows at a time are pre-fetched behind scenes even when you use case A. So using case B with a low limit could well be slower.
    If I can express an additional opinion case F(irst) is nearly always the best i.e. plain SQL (no loops at all). I'm aware that sometimes it cannot be used, but should be the first approach to be tried.
    Regards
    Etbin
    FOUND: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:213366500346264333
    CONTAINS
    Hey Tom, love the site. I noticed in your first fetch, which was in the first for loop that did an unconditional exit:
    2 for x in ( select rownum r, t1.* from big_table.big_table t1 )
    3 loop
    4 exit;
    5 end loop;
    In looking at the TKPROF output for that query, it shows the number of rows being fetched as 100. Does that prove / demonstrate the bulk collecting optimization that Oracle added in 10g, where it implicitly and automatically does a bulk collect of limit 100 behind the scenes?
    This came up at a discussion at my site very recently, and I think I can just point them to your example here as a demo rather than creating my own. I assume that if you ran the same thing in 9iR2, then that first fetch of rows in TKPROF would only show 1?
    Followup April 18, 2007 - 1pm US/Eastern:
    yes, that demonstrates the implicit array fetch of 100 rows...
    in 9i, it would show 1 row fetched.
    Edited by: Etbin on 31.5.2009 10:38

  • Which is better ? for loop or iterator ??

    Hi,
    I have one array list having more than 100 objects in it.
    I have two way to ietrator.
    1.
    for(int i=0; i<list.size(); i++)
    Object o = list.get(i);
    2.
    Iterator i = list.getIterator()
    while(i.hasNext())
    Object o ...
    which is better in performance ??

    Well okay. It's an easy optimization but I guess Sun
    doesn't want to "bail out" people who don't know
    their data structures.It won't always be optimal, though. If you use
    iterators and don't iterate the whole way through
    every time, it would degrade performance. It's hard
    for them to make assumptions about how you will
    access the data. So you punish people who do use it
    properly if you do that.I don't know. The optimization I suggested is isolated to random accesses in the linked list only. Say you access index 5. The node pointer corresponding to 5 is stored and if the next access is index 6 the node pointer you're looking for is pointer.next. There's no need to walk the list from the beginning.

  • Diff bet BAPI & BADI

    Dear friends
    Coul any1 of clearly tel me
    wt s BADI?
    wt s BAPI?
    Hw th both r differed frm each othr?
    regards
    sakthi

    Hi
    hope it will help you.
    Reward if help.
    Business Add-Ins
    Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.
    As with customer exits (SMOD/CMOD [Page 40]), two different views are available:
    • In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object.
    • In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.
    In contrast to customer exits, Business Add-Ins no longer assume a two-system infrastructure (SAP and customers), but instead allow for multiple levels of software development (by SAP, partners, and customers, and as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.
    SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.
    The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time.
    In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example). All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard.
    A single Business Add-In contains all of the interfaces necessary to implement a specific task. In Release 4.6A, program and menu enhancements can be made with Business Add-Ins. The actual program code is enhanced using ABAP Objects. In order to better understand the programming techniques behind the Business Add-In enhancement concept, SAP recommends reading the section on ABAP Objects
    DEFINING THE BADI
    1) execute Tcode SE18.
    2) Specify a definition Name : ZBADI_SPFLI
    3) Press create
    4) Choose the attribute tab. Specify short desc for badi.. and specify the type :
    multiple use.
    5) Choose the interface tab
    6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
    7) Dbl clk on interface name to start class builder . specify a method name (name,
    level, desc).
    Method level desc
    Linese;ection instance methos some desc
    8) place the cursor on the method name desc its parameters to define the interface.
    Parameter type refe field desc
    I_carrid import spfli-carrid some
    I_connid import spefi-connid some
    9) save , check and activate…adapter class proposed by system is
    ZCL_IM_IM_LINESEL is genereated.
    IMPLEMENTATION OF BADI DEFINITION
    1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.
    2) Specify aname for implementation ZIM_LINESEL
    3) Specify short desc.
    4) Choose interface tab. System proposes a name fo the implementation class.
    ZCL_IM_IMLINESEL which is already generarted.
    5) Specify short desc for method
    6) Dbl clk on method to insert code..(check the code in “AAA”).
    7) Save , check and activate the code.
    Some useful URL
    http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://www.esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    www.sapgenie.com/publications/saptips/022006%20-%20Zaidi%20BADI.pdf
    http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/d54d3c596f0b26e10000000a11402f/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/eab541c5b63031e10000000a155106/frameset.htm
    Now write a sample program to use this badi method..
    Look for “BBB” sample program.
    “AAA”
    data : wa_flights type sflight,
    it_flights type table of sflight.
    format color col_heading.
    write:/ 'Flight info of:', i_carrid, i_connid.
    format color col_normal.
    select * from sflight
    into corresponding fields of table it_flights
    where carrid = i_carrid
    and connid = i_connid.
    loop at it_flights into wa_flights.
    write:/ wa_flights-fldate,
    wa_flights-planetype,
    wa_flights-price currency wa_flights-currency,
    wa_flights-seatsmax,
    wa_flights-seatsocc.
    endloop.
    “BBB”
    *& Report ZBADI_TEST *
    REPORT ZBADI_TEST .
    tables: spfli.
    data: wa_spfli type spfli,
    it_spfli type table of spfli with key carrid connid.
    *Initialise the object of the interface.
    data: exit_ref type ref to ZCL_IM_IM_LINESEL,
    exit_ref1 type ref to ZIF_EX_BADISPFLI1.
    selection-screen begin of block b1.
    select-options: s_carr for spfli-carrid.
    selection-screen end of block b1.
    start-of-selection.
    select * from spfli into corresponding fields of table it_spfli
    where carrid in s_carr.
    end-of-selection.
    loop at it_spfli into wa_spfli.
    write:/ wa_spfli-carrid,
    wa_spfli-connid,
    wa_spfli-cityfrom,
    wa_spfli-deptime,
    wa_spfli-arrtime.
    hide: wa_spfli-carrid, wa_spfli-connid.
    endloop.
    at line-selection.
    check not wa_spfli-carrid is initial.
    create object exit_ref.
    exit_ref1 = exit_ref.
    call method exit_ref1->lineselection
    EXPORTING
    i_carrid = wa_spfli-carrid
    i_connid = wa_spfli-connid.
    clear wa_spfli.
    what is BAPI?
    BAPI stands for Business API(Application Program Interface).
    A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
    You can make your function module remotely enabled in attributes of Function module but
    A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).
    BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
    The following standardized BAPIs are provided:
    Reading instances of SAP business objects
    GetList ( ) With the BAPI GetList you can select a range of object key values, for example, company codes and material numbers.
    The BAPI GetList() is a class method.
    GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an instance method. BAPIs that can create, change or delete instances of a business object type
    The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.
    Create( ) and CreateFromData! ( )
    The BAPIs Create() and CreateFromData() create an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.
    Change( )
    The BAPI Change() changes an existing instance of an SAP business object type, for example, a purchase order. The BAPI Change () is an instance method.
    Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.
    The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
    Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business object type. The instance to be cancelled remains in the database and an additional instance is created and this is the one that is actually canceled. The Cancel() BAPI is an instance method.
    Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.
    BAPI-step by step
    http://www.sapgenie.com/abap/bapi/example.htm
    just refer to the link below
    http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g
    list of all bapis
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    for BAPI's
    http://www.sappoint.com/abap/bapiintro.pdf
    http://www.sappoint.com/abap/bapiprg.pdf
    http://www.sappoint.com/abap/bapiactx.pdf
    http://www.sappoint.com/abap/bapilst.pdf
    http://www.sappoint.com/abap/bapiexer.pdf
    http://service.sap.com/ale
    http://service.sap.com/bapi
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf
    http://www.planetsap.com/Bapi_main_page.htm
    http://www.topxml.com/sap/sap_idoc_xml.asp
    http://www.sapdevelopment.co.uk/
    http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf
    Also refer to the following links..
    www.sap-img.com/bapi.htm
    www.sap-img.com/abap/bapi-conventions.htm
    www.planetsap.com/Bapi_main_page.htm
    www.sapgenie.com/abap/bapi/index.htm
    Checkout !!
    http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
    http://techrepublic.com.com/5100-6329-1051160.html#
    Example Code
    U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.
    U can find these parameters for a particular condition type in table KONV.
    *& Form saveTransactionJOCR
    text
    --> p1 text
    <-- p2 text
    FORM saveTransactionJOCR .
    data: salesdocument like BAPIVBELN-VBELN,
    order_header_inx like bapisdh1x,
    order_header_in like bapisdh1,
    return type standard table of bapiret2 with header line,
    conditions_in type standard table of bapicond with header line,
    conditions_inx type standard table of bapicondx with header line,
    logic_switch like BAPISDLS,
    step_nr like conditions_in-cond_st_no,
    item_nr like conditions_in-itm_number,
    cond_count like conditions_in-cond_count,
    cond_type like conditions_in-cond_type.
    salesdocument = wa_order_information-VBELN.
    LOGIC_SWITCH-COND_HANDL = 'X'.
    order_header_inx-updateflag = 'U'.
    conditions
    clear conditions_in[].
    clear conditions_inx[].
    clear: step_nr,
    item_nr,
    cond_count,
    cond_type.
    step_nr = '710'.
    item_nr = '000000'.
    cond_count = '01'.
    cond_type = 'ZCP2'.
    CONDITIONS_IN-ITM_NUMBER = item_nr.
    conditions_in-cond_st_no = step_nr.
    CONDITIONS_IN-COND_COUNT = cond_count.
    CONDITIONS_IN-COND_TYPE = cond_type.
    CONDITIONS_IN-COND_VALUE = 666.
    CONDITIONS_IN-CURRENCY = 'EUR'.
    append conditions_in.
    CONDITIONS_INX-ITM_NUMBER = item_nr.
    conditions_inx-cond_st_no = step_nr.
    CONDITIONS_INX-COND_COUNT = cond_count.
    CONDITIONS_INX-COND_TYPE = cond_type.
    CONDITIONS_INX-UPDATEFLAG = 'U'.
    CONDITIONS_INX-COND_VALUE = 'X'.
    CONDITIONS_INX-CURRENCY = 'X'.
    append conditions_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = salesdocument
    ORDER_HEADER_IN = order_header_in
    ORDER_HEADER_INX = order_header_inx
    LOGIC_SWITCH = logic_switch
    TABLES
    RETURN = return
    CONDITIONS_IN = conditions_in
    CONDITIONS_INX = conditions_inx
    if return-type ne 'E'.
    commit work and wait.
    endif.
    ENDFORM. " saveTransactionJOCR
    Bdc to Bapi
    The steps to be followed are :
    1. Find out the relevant BAPI (BAPI_SALESORDER_CHANGE for VA02).
    [for VA01 use BAPI_SALESORDER_CREATEFROMDAT2]
    2. Create a Z program and call the BAPi (same as a Funtion module call).
    2. Now, if you see this BAPi, it has
    -> Importing structures.
    eg: SALESDOCUMENT: this will take the Sales order header data as input.
    -> Tables parameters:
    eg: ORDER_ITEM_IN: this will take the line item data as input.
    Note :
    Only specify fields that should be changed
    Select these fields by entering an X in the checkboxes
    Enter a U in the UPDATEFLAG field
    Always specify key fields when changing the data, including in the checkboxes
    The configuration is an exception here. If this needs to be changed, you need to complete it again fully.
    Maintain quantities and dates in the schedule line data
    Possible UPDATEFLAGS:
    U = change
    D = delete
    I = add
    Example
    1. Delete the whole order
    2. Delete order items
    3. Change the order
    4. Change the configuration
    Notes
    1. Minimum entry:
    You must enter the order number in the SALESDOCUMENT structure.
    You must always enter key fields for changes.
    You must always specify the update indicator in the ORDER_HEADER_INX.
    2. Commit control:
    The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.
    For further details... refer to the Function Module documentation for the BAPi.
    Bapi to VB(Visual Basic)
    Long back I had used the following flow structure to acheive the same.
    Report -> SM59 RFC destination -> COM4ABAP -> VB.exe
    my report uses the rfc destination to create a COM session with com4abap. com4abap calls the vb.exe and manages the flow of data between sap and vb exe.
    You need to have com4abap.exe
    If com4abap is installed you will find it in sapgui installatin directory , C:\Program Files\SAPpc\sapgui\RFCSDK\com4abap.
    else refer OSS note 419822 for installation of com4abap
    after making the settings in com4abap to point to the vb program and setting up rfc destination in sm59 to point to com4abap session , you can use the following function modules to call the vb code.
    for setting up com4abap and rfc destination please refer to the documentation for com4abap.
    Invoke NEW DCOM session
    call function 'BEGIN_COM_SESSION'
    exporting
    service_dest = service_dest "(this will be a RFC destination created in SM59)
    importing
    worker_dest = worker_dest
    exceptions
    connect_to_dcom_service_failed = 1
    connect_to_dcom_worker_failed = 2
    others = 3.
    call function 'create_com_instance' destination worker_dest
    exporting
    clsid = g_c_clsid
    typelib = g_c_typelib
    importing
    instid = g_f_oid
    exceptions
    communication_failure = 1 message g_f_msg
    system_failure = 2 message g_f_msg
    invalid_instance_id = 3
    others = 4.
    call function 'com_invoke' destination worker_dest
    exporting
    %instid = g_f_oid
    %method = 'UpdatePDF'
    sntemp = g_v_const_filent
    snsysid = sy-sysid
    snflag = 'N'
    tables
    rssaptable = g_t_pdfdetail1
    %return = g_t_pdfdetail1 "t_test
    exceptions
    communication_failure = 1 message g_f_msg
    system_failure = 2 message g_f_msg
    invalid_instance_id = 3
    others = 4.
    then close the com session , using
    FM delete_com_instance
    FM END_COM_SESSION

  • How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

    Hi.
    I think this is a pretty basic LV question, but I have not been able to find a good solution.
    I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.
    The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.
    Can any one suggest a good solution?
    Thanks,
    AlejandroZ
    Attachments:
    CallingVI.vi ‏7 KB
    subVI.vi ‏8 KB

    Hi.
    I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:
    I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.
    Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.
    As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.
    One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...
    There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.
    Thanks for all your responses.
    AlejandroZ

  • Sometimes a plugin-container.exe instance starts hogging a ton of memory -- I would like to know which plugin is running inside that plugin-container without having to one-by-one disable the plugins. Which process called plugin-container.exe?

    As described above, I have several instances of plugin-container.exe running, which is OK. It would make me feel safer to know which plugins are running inside each of these, since I would be better able to know whether there is malware running inside one of them, or which website might have made the process start hogging memory.
    I am a power user, I usually have 80-100 tabs open, and of course it is hard to track the website or plugin down without having to waste a lot of time.
    Could you provide in future releases this information?
    Is it already available under one of the about: pages (e.g. config, plugins, memory, etc?)

    Thanks Efreak! <br><br>
    Maybe I was not clear. I usually have 4-5 plugin-container.exe processes running. I know now that the large one that hogs is the Adobe Flash player, but, for example I don't know which plug-in initiated the other plugin-container.exe instances.<br><br>
    One of them actually says "googletalkplugin.exe" if you dig deep, which is OK. At least I know why the plugin-container.exe was started. But there are other instances that are just there and there is no way to figure out which plug-in initiated it.<br><br>
    This would of course also help figure out if it is really the Adobe Flash plug in that is hogging all the memory, OR even if within Firefox in the about: pages one could figure out which TABS are using which plug-ins.
    Like that you could freely choose to terminate the process directly, or close the TAB.<br><br>
    1) What I am looking for is a way to determine which plug-in is running under which instance of plugin-container.exe<br>
    2) Additionally it would be great to have a summary of which TABS are using which plugins (e.g. in the about:plugins page or yet another about: page)
    <br><br>
    Thank you

  • How to avoid data selection inside the loop?

    Hello Experts,
    I am working on one performance item and I have already applied some changes to the original version.
    Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my research (Below run is updating around 20M records which is real time volume for this application).
    As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.
    1. Select data from ZABC
    2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)
    3. Loop Variant Table
    4. Select data from X, Y, Z table for Var<n>.
    5. Populate final internal table from ZABC, X, Y and Z table
    6. Modify ZTABLE with Final Internal table data
    7. End Loop on Variant Table
    As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:
    select rrcty ryear rbukrs racct rcntr sum( amt1) as amt1  "Like I have 32 amount fields in original query
               from zabc
                into table i_zabc
                where ryear in r_year    " Two records in ranges with I and EQ
                and rvers = '001'
                and rrcty in r_rrcty        "Three records in ranges with I and EQ
                and rldnr = 'DT'
                group by rrcty ryear rbukrs racct rcntr
                order by rrcty ryear rbukrs racct rcntr.
    ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should move ZABC selection inside the variant loop which can cause fetching ZABC data 12 times (Let me know If I am missing anything here).
    Now, third statement in my trace results, with 10% of overall time is this:
    loop at i_abc assigning <fs_abc>. 
    loop at i_table assigning <fs_table> where low <= <fs_abc>-racct and high >= <fs_abc>-racct. 
    endloop. 
    endloop. 
    6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)
    1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.
    2) Removed WHERE condition on HIGH only and applied filter inside the loop.
    Any suggestions on how to proceed with ZABC selection and I_TABLE loop.
    Let me know if you have any questions on above compose.

    Since I looked at this case before, let me try some quick suggestions:
    Is table ZABC related to table X, Y and/or Z and can the selection be limited by applying those 12 selection variants?
    If yes, try a join select involving these tables that could make your step 1 obsolete and replace steps 4 and 5.
    This might also get rid of the "loop inside loop" problem. Generally, make sure that the inner table is declared as a sorted table with a key that consists of the fields as used in the WHERE-condition of the inner loop. Use secondary keys for internal tables if your ABAP release permits and the task at hand warrants it.
    Finally, look at PACKAGE SIZE option for the (join) select to reduce memory consumption.
    Thomas

  • Help with XML - which is better - Help needed

    Current version of Oracle:
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    I'm new to XML & this is my first post.
    Background: I have a "few" relational tables which are designed to assist the form scraping and to store the values as Key-Value-Attribute from the UI capture. (the change to the design is not possible at this time). I've also built the "normalized" schema which will hold the normalized data from this form-scrapping schema.
    In order to achive this: I plan on having (1) XML view which the UI will call and then it will be inserted/updated in the normalized schema (2) to be able to use the same XML by the BI publisher for reporting (3) end user query this form-scraping db to view as normalized data.
    Following are my thoughts about the approach & please correct & guide if my understanding/approach is wrong.
    After some good reading on this forum and other materials, I've come up with the below mentioned XML generation method. How can I convert this XML "record" such that it can satisfy the above stated.
    output:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <FORM_TYPE_ID>900</FORM_TYPE_ID>
      <SYSTEM_NAME>HAZMAT_ENROLLMENT</SYSTEM_NAME>
      <FORM_TYPE>ENR-HAZMAT</FORM_TYPE>
      <FORM_ID>2371370</FORM_ID>
      <SUBMISSION_TYPE_ID>60</SUBMISSION_TYPE_ID>
      <FILING_DATE>29-APR-11</FILING_DATE>
      <SECTION>
       <SECTION_ROW>
        <SECTION_ID>6750</SECTION_ID>
        <SECTION_NAME>Personal Information</SECTION_NAME>
        <ATTRIBUTE>
         <ATTRIBUTE_ROW>
          <SRC>FRM_RSP</SRC>
          <ATTR_ID>30001</ATTR_ID>
          <ATTR_NAME>ENROLLEE_FIRST_NAME</ATTR_NAME>
          <ATTR_DESC>Enrollee&apos;s First Name</ATTR_DESC>
          <ATTR_VAL>Test First Name</ATTR_VAL>
         </ATTRIBUTE_ROW>
         <ATTRIBUTE_ROW>
          <SRC>FRM_RSP</SRC>
          <ATTR_ID>30002</ATTR_ID>
          <ATTR_NAME>ENROLLEE_MIDDLE_INIT</ATTR_NAME>
          <ATTR_DESC>Enrollee&apos;s Middle Initial</ATTR_DESC>
          <ATTR_VAL>Test Middle Initial</ATTR_VAL>
         </ATTRIBUTE_ROW>
       </SECTION_ROW>
      </SECTION>
    </ROW>
    </ROWSET>
    Code:
    *(All REF_% tables are lookup and FRM_RESPONSE is a KVA capture table and TBL_RESPONSE is also a KVA capture only used if the input is table wise (rows X columns))*
    FORM is made up of SECTIONs (1-to-many), SECTIONs contain ATTR_IDs (question ids, 1-to-many), %RESPONSE is always linked to an ATTR_ID
    CREATE OR REPLACE function DEVDBA.gen_xmlstr (p_form_id form.form_id%type) return clob as
    str clob := '
    SELECT rft.form_type_id, rft.system_name,rft.form_type, f.form_id, f.submission_type_id, f.sp_id,
           f.filing_date, f.tracking_num, f.spplmntl_num, f.parent_form_id, f.created_date, f.created_by,
           f.updated_date, f.updated_by,
           CURSOR(SELECT rs.section_id,
                         rs.section_name,
                         CURSOR(SELECT ''FRM_RSP'' src, fr.frm_response_id, ra.attr_id, ra.attr_name, ra.attr_desc, fr.attr_val
                                  FROM frm_response fr, ref_attr ra, ref_section_attr rsa
                                 WHERE fr.form_id = f.form_id
                                 AND fr.attr_id = rsa.attr_id
                                 AND fr.form_section_id = rsa.form_section_id
                                 AND fr.attr_id = ra.attr_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP1'' src, tr.tbl_response_id, tr.col_attr_id1, ra.attr_name, ra.attr_desc, col_attr_val1
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id1 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP2'' src, tr.tbl_response_id, tr.col_attr_id2, ra.attr_name, ra.attr_desc, col_attr_val2
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id2 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP3'' src, tr.tbl_response_id, TO_NUMBER(tr.col_attr_id3), ra.attr_name, ra.attr_desc, col_attr_val3
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND TO_NUMBER(tr.col_attr_id3) = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP4'' src, tr.tbl_response_id, tr.col_attr_id4, ra.attr_name, ra.attr_desc, col_attr_val4
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id4 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP5'' src, tr.tbl_response_id, tr.col_attr_id5, ra.attr_name, ra.attr_desc, col_attr_val5
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id5 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP6'' src, tr.tbl_response_id, tr.col_attr_id6, ra.attr_name, ra.attr_desc, col_attr_val6
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id6 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP7'' src, tr.tbl_response_id, tr.col_attr_id7, ra.attr_name, ra.attr_desc, col_attr_val7
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id7 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP8'' src, tr.tbl_response_id, tr.col_attr_id8, ra.attr_name, ra.attr_desc, col_attr_val8
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id8 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP9'' src, tr.tbl_response_id, tr.col_attr_id9, ra.attr_name, ra.attr_desc, col_attr_val9
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id9 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                                UNION
                                SELECT ''TBL_RSP10'' src, tr.tbl_response_id, tr.col_attr_id10, ra.attr_name, ra.attr_desc, col_attr_val10
                                  FROM tbl_response tr, ref_attr ra, ref_section_attr rsa
                                 WHERE tr.form_id = f.form_id
                                 AND tr.col_attr_id10 = ra.attr_id
                                 AND tr.form_section_id = rsa.form_section_id
                                 AND rsa.form_section_id = rfs.form_section_id
                           attribute
                    FROM ref_section rs, ref_form_section rfs
                   WHERE rs.section_id = rfs.section_id
                   AND   rfs.form_type_id = f.form_type_id
                  ORDER BY rs.section_id, rfs.form_section_id)
             section
      FROM ref_form_type rft, form f
    WHERE rft.form_type_id = f.form_type_id
    AND f.form_id = ' || p_form_id; --2371370'';
    begin
      return dbms_xmlgen.getxml(str);
    end gen_xmlstr;
    Invocation:
    select gen_xmlstr(2371370)
    from dual;
    Below is the execution plan. Can this be better?
    Execution Plan
    Plan hash value: 2652539008
    | Id  | Operation                        | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                 |                      |     1 |    75 |     3   (0)| 00:00:01 |
    |   1 |  SORT UNIQUE                     |                      |    11 |  1024 |    40  (88)| 00:00:01 |
    |   2 |   UNION-ALL                      |                      |       |       |            |          |
    |   3 |    NESTED LOOPS                  |                      |       |       |            |          |
    |   4 |     NESTED LOOPS                 |                      |     1 |    91 |     5   (0)| 00:00:01 |
    |   5 |      NESTED LOOPS                |                      |     1 |    82 |     3   (0)| 00:00:01 |
    |*  6 |       TABLE ACCESS BY INDEX ROWID| FRM_RESPONSE         |     1 |    25 |     2   (0)| 00:00:01 |
    |*  7 |        INDEX RANGE SCAN          | FK3_FRM_RESPONSE     |    20 |       |     1   (0)| 00:00:01 |
    |   8 |       TABLE ACCESS BY INDEX ROWID| REF_ATTR             |     1 |    57 |     1   (0)| 00:00:01 |
    |*  9 |        INDEX UNIQUE SCAN         | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |* 10 |      INDEX RANGE SCAN            | FK2_REF_SECTION_ATTR |     2 |       |     1   (0)| 00:00:01 |
    |* 11 |     TABLE ACCESS BY INDEX ROWID  | REF_SECTION_ATTR     |     1 |     9 |     2   (0)| 00:00:01
    |  12 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  13 |     NESTED LOOPS                 |                      |     1 |   105 |     2   (0)| 00:00:01 |
    |  14 |      NESTED LOOPS                |                      |     1 |    48 |     2   (0)| 00:00:01 |
    |* 15 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 16 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    44 |     1   (0)| 00:00:01 |
    |* 17 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 18 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  19 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  20 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  21 |     NESTED LOOPS                 |                      |     1 |   100 |     2   (0)| 00:00:01 |
    |  22 |      NESTED LOOPS                |                      |     1 |    43 |     2   (0)| 00:00:01 |
    |* 23 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 24 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    39 |     1   (0)| 00:00:01 |
    |* 25 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 26 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  27 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  28 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  29 |     NESTED LOOPS                 |                      |     1 |    86 |     3   (0)| 00:00:01 |
    |  30 |      NESTED LOOPS                |                      |     1 |    29 |     2   (0)| 00:00:01 |
    |* 31 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 32 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    25 |     1   (0)| 00:00:01 |
    |* 33 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 34 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  35 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     1   (0)| 00:00:01 |
    |  36 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  37 |     NESTED LOOPS                 |                      |     1 |    93 |     2   (0)| 00:00:01 |
    |  38 |      NESTED LOOPS                |                      |     1 |    36 |     2   (0)| 00:00:01 |
    |* 39 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 40 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    32 |     1   (0)| 00:00:01 |
    |* 41 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 42 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  43 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  44 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  45 |     NESTED LOOPS                 |                      |     1 |    93 |     2   (0)| 00:00:01 |
    |  46 |      NESTED LOOPS                |                      |     1 |    36 |     2   (0)| 00:00:01 |
    |* 47 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 48 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    32 |     1   (0)| 00:00:01 |
    |* 49 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 50 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  51 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  52 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  53 |     NESTED LOOPS                 |                      |     1 |    90 |     2   (0)| 00:00:01 |
    |  54 |      NESTED LOOPS                |                      |     1 |    33 |     2   (0)| 00:00:01 |
    |* 55 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 56 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    29 |     1   (0)| 00:00:01 |
    |* 57 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 58 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  59 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  60 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  61 |     NESTED LOOPS                 |                      |     1 |    95 |     2   (0)| 00:00:01 |
    |  62 |      NESTED LOOPS                |                      |     1 |    38 |     2   (0)| 00:00:01 |
    |* 63 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 64 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    34 |     1   (0)| 00:00:01 |
    |* 65 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 66 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  67 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  68 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  69 |     NESTED LOOPS                 |                      |     1 |    90 |     2   (0)| 00:00:01 |
    |  70 |      NESTED LOOPS                |                      |     1 |    33 |     2   (0)| 00:00:01 |
    |* 71 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 72 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    29 |     1   (0)| 00:00:01 |
    |* 73 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 74 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  75 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  76 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  77 |     NESTED LOOPS                 |                      |     1 |    90 |     2   (0)| 00:00:01 |
    |  78 |      NESTED LOOPS                |                      |     1 |    33 |     2   (0)| 00:00:01 |
    |* 79 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 80 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    29 |     1   (0)| 00:00:01 |
    |* 81 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 82 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  83 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  84 |    NESTED LOOPS                  |                      |       |       |            |          |
    |  85 |     NESTED LOOPS                 |                      |     1 |    91 |     2   (0)| 00:00:01 |
    |  86 |      NESTED LOOPS                |                      |     1 |    34 |     2   (0)| 00:00:01 |
    |* 87 |       INDEX RANGE SCAN           | FK1_REF_SECTION_ATTR |     9 |    36 |     1   (0)| 00:00:01 |
    |* 88 |       TABLE ACCESS BY INDEX ROWID| TBL_RESPONSE         |     1 |    30 |     1   (0)| 00:00:01 |
    |* 89 |        INDEX RANGE SCAN          | FK1_TBL_RESPONSE     |     1 |       |     0   (0)| 00:00:01 |
    |* 90 |      INDEX UNIQUE SCAN           | PK_REF_ATTR          |     1 |       |     0   (0)| 00:00:01 |
    |  91 |     TABLE ACCESS BY INDEX ROWID  | REF_ATTR             |     1 |    57 |     0   (0)| 00:00:01 |
    |  92 |  SORT ORDER BY                   |                      |    20 |  1040 |     7  (29)| 00:00:01 |
    |* 93 |   HASH JOIN                      |                      |    20 |  1040 |     6  (17)| 00:00:01 |
    |  94 |    TABLE ACCESS BY INDEX ROWID   | REF_FORM_SECTION     |    20 |   200 |     2   (0)| 00:00:01 |
    |* 95 |     INDEX RANGE SCAN             | FK1_FORM_SECTION     |    20 |       |     1   (0)| 00:00:01 |
    |  96 |    TABLE ACCESS FULL             | REF_SECTION          |   100 |  4200 |     3   (0)| 00:00:01 |
    |  97 |  NESTED LOOPS                    |                      |     1 |    75 |     3   (0)| 00:00:01 |
    |  98 |   TABLE ACCESS BY INDEX ROWID    | FORM                 |     1 |    59 |     2   (0)| 00:00:01 |
    |* 99 |    INDEX UNIQUE SCAN             | PK_FORM              |     1 |       |     1   (0)| 00:00:01 |
    | 100 |   TABLE ACCESS BY INDEX ROWID    | REF_FORM_TYPE        |     5 |    80 |     1   (0)| 00:00:01 |
    |*101 |    INDEX UNIQUE SCAN             | PK_REF_FORM_TYPE     |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       6 - filter("FR"."FORM_SECTION_ID"=:B1)
       7 - access("FR"."FORM_ID"=:B1)
       9 - access("FR"."ATTR_ID"="RA"."ATTR_ID")
      10 - access("FR"."ATTR_ID"="RSA"."ATTR_ID")
      11 - filter("RSA"."FORM_SECTION_ID"=:B1 AND "FR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      15 - access("RSA"."FORM_SECTION_ID"=:B1)
      16 - filter("TR"."COL_ATTR_ID1" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      17 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      18 - access("TR"."COL_ATTR_ID1"="RA"."ATTR_ID")
      23 - access("RSA"."FORM_SECTION_ID"=:B1)
      24 - filter("TR"."COL_ATTR_ID2" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      25 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      26 - access("TR"."COL_ATTR_ID2"="RA"."ATTR_ID")
      31 - access("RSA"."FORM_SECTION_ID"=:B1)
      32 - filter("TR"."FORM_ID"=:B1)
      33 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      34 - access("RA"."ATTR_ID"=TO_NUMBER("TR"."COL_ATTR_ID3"))
      39 - access("RSA"."FORM_SECTION_ID"=:B1)
      40 - filter("TR"."COL_ATTR_ID4" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      41 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      42 - access("TR"."COL_ATTR_ID4"="RA"."ATTR_ID")
      47 - access("RSA"."FORM_SECTION_ID"=:B1)
      48 - filter("TR"."COL_ATTR_ID5" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      49 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      50 - access("TR"."COL_ATTR_ID5"="RA"."ATTR_ID")
      55 - access("RSA"."FORM_SECTION_ID"=:B1)
      56 - filter("TR"."COL_ATTR_ID6" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      57 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      58 - access("TR"."COL_ATTR_ID6"="RA"."ATTR_ID")
      63 - access("RSA"."FORM_SECTION_ID"=:B1)
      64 - filter("TR"."COL_ATTR_ID7" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      65 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      66 - access("TR"."COL_ATTR_ID7"="RA"."ATTR_ID")
      71 - access("RSA"."FORM_SECTION_ID"=:B1)
      72 - filter("TR"."COL_ATTR_ID8" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      73 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      74 - access("TR"."COL_ATTR_ID8"="RA"."ATTR_ID")
      79 - access("RSA"."FORM_SECTION_ID"=:B1)
      80 - filter("TR"."COL_ATTR_ID9" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      81 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      82 - access("TR"."COL_ATTR_ID9"="RA"."ATTR_ID")
      87 - access("RSA"."FORM_SECTION_ID"=:B1)
      88 - filter("TR"."COL_ATTR_ID10" IS NOT NULL AND "TR"."FORM_ID"=:B1)
      89 - access("TR"."FORM_SECTION_ID"=:B1)
           filter("TR"."FORM_SECTION_ID"="RSA"."FORM_SECTION_ID")
      90 - access("TR"."COL_ATTR_ID10"="RA"."ATTR_ID")
      93 - access("RS"."SECTION_ID"="RFS"."SECTION_ID")
      95 - access("RFS"."FORM_TYPE_ID"=:B1)
      99 - access("F"."FORM_ID"=2371370)
    101 - access("RFT"."FORM_TYPE_ID"="F"."FORM_TYPE_ID")
    What tools/techniques are available to generate the XSLT? (use XMLSpy etc?), how to create a such that it can be as simple as "select from v_xml_view;" and be able to replace * with column names?*
    ==============================
    I've also tried the *SQL-XML extensions* but am stuck with the UNION PART (help is requested on how to union columns within the XMLAgg).
    {code}
    select
    xmlelement ("System",
    xmlforest(rft.form_type_id as "FormTypeID", rft.system_name as "SystemName", rft.form_type as "FormType", f.form_id as "FormID"),
    xmlelement("Sections",
    (select xmlagg(xmlelement("Section",
    xmlforest(rs.section_id as "SectionID", rs.section_name as "SectionName"),
    xmlelement("Attributes",
    (select xmlagg(xmlelement("Attr",
    xmlforest (rsa.attr_id as "AttrID", ra.attr_name as "AttrName", ra.attr_desc as "Attr_desc", fr.attr_val as "AttrValue")
    ) -- "attr"
    ) --xmlagg attr
    from ref_section_attr rsa, ref_attr ra, frm_response fr
    where rsa.attr_id = ra.attr_id
    and rsa.form_section_id = rfs.form_section_id
    and fr.form_id = f.form_id
    and fr.form_section_id = rsa.form_section_id
    and fr.attr_id = rsa.attr_id
    ) --attributes select
    ) -- attributes
    ) -- section elements
    ) -- xmlagg
    from ref_section rs, ref_form_section rfs
    where rs.section_id = rfs.section_id
    and rfs.form_type_id = f.form_type_id
    ) -- select query
    ) -- sections
    ) -- system
    as str
    from ref_form_type rft, FORM f
    where rft.form_type_id = f.form_type_id
    and f.form_id = 2371420;
    {code}
    *and the output is like:
    (I don't know how to format this for easy viewing!)*
    {code}
    <System><FormTypeID>900</FormTypeID><SystemName>HAZMAT_ENROLLMENT</SystemName><FormType>ENR-HAZMAT</FormType><FormID>2371420</FormID><Sections><Section><SectionID>6750</SectionID><SectionName>Personal Information</SectionName><Attributes><Attr><AttrID>30001</AttrID><AttrName>ENROLLEE_FIRST_NAME</AttrName><Attr_desc>Enrollee&apos;s First Name</Attr_desc><AttrValue>Enroll</AttrValue></Attr><Attr><AttrID>30002</AttrID><AttrName>ENROLLEE_MIDDLE_INIT</AttrName><Attr_desc>Enrollee&apos;s Middle Initial</Attr_desc><AttrValue> </AttrValue></Attr><Attr><AttrID>30003</AttrID><AttrName>ENROLLEE_LAST_NAME</AttrName><Attr_desc>Enrollee&apos;s Last Name</Attr_desc><AttrValue>User11</AttrValue></Attr><Attr><AttrID>30004</AttrID><AttrName>ENROLLEE_WORK_PHONE</AttrName><Attr_desc>Enrollee&apos;s Work Phone Number</Attr_desc><AttrValue>(703) 222-4444</AttrValue></Attr><Attr><AttrID>30005</AttrID><AttrName>ENROLLEE_FAX</AttrName><Attr_desc>Enrollee Fax Number</Attr_desc><AttrValue> </AttrValue></Attr><Attr><AttrID>30006</AttrID><AttrName>ENROLLEE_EXT</AttrName><Attr_desc>Enrollee&apos;s Work Extension</Attr_desc><AttrValue> </AttrValue></Attr><Attr><AttrID>30007</AttrID><AttrName>ENROLLEE_EMAIL</AttrName><Attr_desc>Enrollee&apos;s Email</Attr_desc><AttrValue>[email protected]</AttrValue></Attr><Attr><AttrID>30023</AttrID><AttrName>POC_TYPE</AttrName><Attr_desc>Point of Contact Type</Attr_desc><AttrValue>Consultant</AttrValue></Attr><Attr><AttrID>30008</AttrID><AttrName>ENROLLEE_MAIL_ADDR_1</AttrName><Attr_desc>Enrollee&apos;s Mailing Address #1</Attr_desc><AttrValue>123 Main St</AttrValue></Attr><Attr><AttrID>30009</AttrID><AttrName>ENROLLEE_MAIL_ADDR_2</AttrName><Attr_desc>Enrollee&apos;s Mailing Address #2</Attr_desc><AttrValue> </AttrValue></Attr><Attr><AttrID>30010</AttrID><AttrName>ENROLLEE_CITY</AttrName><Attr_desc>Enrollee&apos;s City</Attr_desc><AttrValue>Herndon</AttrValue></Attr><Attr><AttrID>30011</AttrID><AttrName>ENROLLEE_STATE</AttrName><Attr_desc>Enrollee&apos;s State</Attr_desc><AttrValue>VA</AttrValue></Attr><Attr><AttrID>30012</AttrID><AttrName>ENROLLEE_ZIP</AttrName><Attr_desc>Enrollee&apos;s Zip</Attr_desc><AttrValue>28408</AttrValue></Attr><Attr><AttrID>30013</AttrID><AttrName>ENROLLEE_USER_NAME</AttrName><Attr_desc>Enrollee&apos;s User Name</Attr_desc><AttrValue>enrolluser11</AttrValue></Attr></Attributes></Section><Section><SectionID>6800</SectionID><SectionName>Company Information</SectionName><Attributes><Attr><AttrID>30014</AttrID><AttrName>DUN_BRADSTREET_NUM</AttrName><Attr_desc>Company&apos;s Dun and Bradstreet #</Attr_desc><AttrValue>198455201</AttrValue></Attr></Attributes></Section><Section><SectionID>6850</SectionID><SectionName>Points of Contact</SectionName><Attributes></Attributes></Section><Section><SectionID>6900</SectionID><SectionName>Enrollment Verification</SectionName><Attributes></Attributes></Section><Section><SectionID>6950</SectionID><SectionName>Enrollment Confirmation</SectionName><Attributes></Attributes></Section></Sections></System>
    {code}
    *The execution plan:*
    {code}
    Execution Plan
    Plan hash value: 2641045985
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    ------------

    Thanks for the data.
    I thought you would have included data from TBL_RESPONSE, as the interesting part is how to deal with this "special" design ;)
    So, to run some tests, I've generated the following data for FORM_SECTION_ID 5350 and 5360 :
    insert into tbl_response (FORM_ID, FORM_SECTION_ID, COL_ATTR_ID1, COL_ATTR_VAL1, COL_ATTR_ID2, COL_ATTR_VAL2, COL_ATTR_ID3, COL_ATTR_VAL3, COL_ATTR_ID4, COL_ATTR_VAL4, COL_ATTR_ID5, COL_ATTR_VAL5, COL_ATTR_ID6, COL_ATTR_VAL6, COL_ATTR_ID7, COL_ATTR_VAL7, COL_ATTR_ID8, COL_ATTR_VAL8, COL_ATTR_ID9, COL_ATTR_VAL9, COL_ATTR_ID10, COL_ATTR_VAL10)
    values (2371420, 5350, 30000, '05/03/2011', 30001, 'John', '30002', 'J', 30003, 'Doe', 30004, '(555) 123-1234', 30005, '(555) 123-1235', 30006, '1234567', 30007, '[email protected]', 30008, '10 Maple Street', 30009, '.');
    insert into tbl_response (FORM_ID, FORM_SECTION_ID, COL_ATTR_ID1, COL_ATTR_VAL1, COL_ATTR_ID2, COL_ATTR_VAL2, COL_ATTR_ID3, COL_ATTR_VAL3, COL_ATTR_ID4, COL_ATTR_VAL4, COL_ATTR_ID5, COL_ATTR_VAL5, COL_ATTR_ID6, COL_ATTR_VAL6, COL_ATTR_ID7, COL_ATTR_VAL7, COL_ATTR_ID8, COL_ATTR_VAL8, COL_ATTR_ID9, COL_ATTR_VAL9, COL_ATTR_ID10, COL_ATTR_VAL10)
    values (2371420, 5350, 30011, 'MA', 30012, '02668', '30013', 'jdoe', null, '', null, '', null, '', null, '', null, '', null, '', null, '');
    insert into tbl_response (FORM_ID, FORM_SECTION_ID, COL_ATTR_ID1, COL_ATTR_VAL1, COL_ATTR_ID2, COL_ATTR_VAL2, COL_ATTR_ID3, COL_ATTR_VAL3, COL_ATTR_ID4, COL_ATTR_VAL4, COL_ATTR_ID5, COL_ATTR_VAL5, COL_ATTR_ID6, COL_ATTR_VAL6, COL_ATTR_ID7, COL_ATTR_VAL7, COL_ATTR_ID8, COL_ATTR_VAL8, COL_ATTR_ID9, COL_ATTR_VAL9, COL_ATTR_ID10, COL_ATTR_VAL10)
    values (2371420, 5360, 30014, '123456789', 30015, 'My Company', '30016', '50 Main Street', 30017, '.', 30018, 'Marstons Mills', 30019, 'MA', 30020, '02648', 30021, '(555) 123-1236', null, '', null, '');And here's the query :
    WITH attr_unpivot AS (
      SELECT form_section_id
           , attr_val
      FROM (
        SELECT form_section_id
             , XMLForest(col_attr_id1 as "AttrID", col_attr_val1 as "AttrValue") as attr01
             , XMLForest(col_attr_id2 as "AttrID", col_attr_val2 as "AttrValue") as attr02
             , XMLForest(col_attr_id3 as "AttrID", col_attr_val3 as "AttrValue") as attr03
             , XMLForest(col_attr_id4 as "AttrID", col_attr_val4 as "AttrValue") as attr04
             , XMLForest(col_attr_id5 as "AttrID", col_attr_val5 as "AttrValue") as attr05
             , XMLForest(col_attr_id6 as "AttrID", col_attr_val6 as "AttrValue") as attr06
             , XMLForest(col_attr_id7 as "AttrID", col_attr_val7 as "AttrValue") as attr07
             , XMLForest(col_attr_id8 as "AttrID", col_attr_val8 as "AttrValue") as attr08
             , XMLForest(col_attr_id9 as "AttrID", col_attr_val9 as "AttrValue") as attr09
             , XMLForest(col_attr_id10 as "AttrID", col_attr_val10 as "AttrValue") as attr10
        FROM tbl_response
        WHERE form_id = 2371420
      UNPIVOT (
        attr_val FOR attr_pos IN (attr01,attr02,attr03,attr04,attr05,attr06,attr07,attr08,attr09,attr10)
      UNION ALL
      SELECT form_section_id
           , XMLForest(fr.attr_id as "AttrID", fr.attr_val as "AttrValue")
      FROM frm_response fr
      WHERE fr.form_id = 2371420
    SELECT XMLElement("System",
             XMLForest(
               rft.form_type_id as "FormTypeID"
             , rft.system_name as "SystemName"
             , rft.form_type as "FormType"
             , f.form_id as "FormID"
           , XMLElement("Sections",
                SELECT XMLAgg(
                         XMLElement("Section",
                           XMLForest(
                             rs.section_id as "SectionID"
                           , rs.section_name as "SectionName"
                         , XMLElement("Attributes",
                              SELECT XMLAgg(
                                       XMLElement("Attr",
                                         XMLForest(
                                           ra.attr_desc as "AttrDesc"
                                         , ra.attr_name as "AttrName"
                                       , v.attr_val
                              FROM attr_unpivot v
                                   JOIN ref_section_attr rsa ON rsa.attr_id = extractValue(v.attr_val,'AttrID')
                                                            AND rsa.form_section_id = v.form_section_id
                                   JOIN ref_attr ra ON ra.attr_id = rsa.attr_id
                              WHERE rsa.form_section_id = rfs.form_section_id
                FROM ref_section rs
                     JOIN ref_form_section rfs ON rs.section_id = rfs.section_id
                WHERE rfs.form_type_id = f.form_type_id
           ) as xmldoc
    FROM ref_form_type rft
         JOIN form f ON rft.form_type_id = f.form_type_id
    WHERE f.form_id = 2371420
    ;The WITH clause builds a normalized result set out of TBL_RESPONSE and FRM_RESPONSE.
    That result set is then joined in the main query for each section of the form.
    The resulting XML document looks like :
    <System>
      <FormTypeID>900</FormTypeID>
      <SystemName>ENROLLMENT</SystemName>
      <FormType>ENR</FormType>
      <FormID>2371420</FormID>
      <Sections>
        <Section>
          <SectionID>6750</SectionID>
          <SectionName>Personal Information</SectionName>
          <Attributes>
            <Attr>
              <AttrDesc>Enrollment Date</AttrDesc>
              <AttrName>ENROLLMENT_DATE</AttrName>
              <AttrID>30000</AttrID>
              <AttrValue>05/03/2011</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s First Name</AttrDesc>
              <AttrName>ENROLLEE_FIRST_NAME</AttrName>
              <AttrID>30001</AttrID>
              <AttrValue>John</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Middle Initial</AttrDesc>
              <AttrName>ENROLLEE_MIDDLE_INIT</AttrName>
              <AttrID>30002</AttrID>
              <AttrValue>J</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Last Name</AttrDesc>
              <AttrName>ENROLLEE_LAST_NAME</AttrName>
              <AttrID>30003</AttrID>
              <AttrValue>Doe</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Work Phone Number</AttrDesc>
              <AttrName>ENROLLEE_WORK_PHONE</AttrName>
              <AttrID>30004</AttrID>
              <AttrValue>(555) 123-1234</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee Fax Number</AttrDesc>
              <AttrName>ENROLLEE_FAX</AttrName>
              <AttrID>30005</AttrID>
              <AttrValue>(555) 123-1235</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Work Extension</AttrDesc>
              <AttrName>ENROLLEE_EXT</AttrName>
              <AttrID>30006</AttrID>
              <AttrValue>1234567</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Email</AttrDesc>
              <AttrName>ENROLLEE_EMAIL</AttrName>
              <AttrID>30007</AttrID>
              <AttrValue>[email protected]</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Mailing Address #1</AttrDesc>
              <AttrName>ENROLLEE_MAIL_ADDR_1</AttrName>
              <AttrID>30008</AttrID>
              <AttrValue>10 Maple Street</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Mailing Address #2</AttrDesc>
              <AttrName>ENROLLEE_MAIL_ADDR_2</AttrName>
              <AttrID>30009</AttrID>
              <AttrValue>.</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s State</AttrDesc>
              <AttrName>ENROLLEE_STATE</AttrName>
              <AttrID>30011</AttrID>
              <AttrValue>MA</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s Zip</AttrDesc>
              <AttrName>ENROLLEE_ZIP</AttrName>
              <AttrID>30012</AttrID>
              <AttrValue>02668</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Enrollee&apos;s User Name</AttrDesc>
              <AttrName>ENROLLEE_USER_NAME</AttrName>
              <AttrID>30013</AttrID>
              <AttrValue>jdoe</AttrValue>
            </Attr>
          </Attributes>
        </Section>
        <Section>
          <SectionID>6800</SectionID>
          <SectionName>Company Information</SectionName>
          <Attributes>
            <Attr>
              <AttrDesc>Company&apos;s DB #</AttrDesc>
              <AttrName>DBNUM</AttrName>
              <AttrID>30014</AttrID>
              <AttrValue>123456789</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company Name</AttrDesc>
              <AttrID>30015</AttrID>
              <AttrValue>My Company</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company Adress #1</AttrDesc>
              <AttrID>30016</AttrID>
              <AttrValue>50 Main Street</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company Adress #2</AttrDesc>
              <AttrID>30017</AttrID>
              <AttrValue>.</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company City</AttrDesc>
              <AttrID>30018</AttrID>
              <AttrValue>Marstons Mills</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company State</AttrDesc>
              <AttrID>30019</AttrID>
              <AttrValue>MA</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company Zip</AttrDesc>
              <AttrID>30020</AttrID>
              <AttrValue>02648</AttrValue>
            </Attr>
            <Attr>
              <AttrDesc>Company Phone</AttrDesc>
              <AttrID>30021</AttrID>
              <AttrValue>(555) 123-1236</AttrValue>
            </Attr>
          </Attributes>
        </Section>
        <Section>
          <SectionID>6850</SectionID>
          <SectionName>Points of Contact</SectionName>
          <Attributes/>
        </Section>
        <Section>
          <SectionID>6900</SectionID>
          <SectionName>Enrollment Verification</SectionName>
          <Attributes/>
        </Section>
        <Section>
          <SectionID>6950</SectionID>
          <SectionName>Enrollment Confirmation</SectionName>
          <Attributes/>
        </Section>
      </Sections>
    </System>

  • Which is better, a G4-450 Dual or a Mac Mini 1.42?

    which is better in terms of Sequencing and plug in performace, the G4-450 Dual or a Mac Mini 1.42?

    G4-450GHz Dual with 896MB RAM
    Mac Mini 1.42GHz with 1 gig of Ram
    G4-450GHz Dual gets more instances with plugs, more tracks and performance then the 1.4GHz 17" Powerbook, 12" powerbook and Mac Mini which all have the same G4 processor.,
    Today, i took the same 34 track session,
    -all 34 tracks have a Logic Comp, Eq, Gate
    -and also 8 Buses with Comp, EQ, Gates, Delays, Flange, Phasors, Pitch Shifters, 2 Reverbs (1 long and 1 plated) as well as some other toys.
    -Master with Waves Ren Comp, Logic EQ.
    -6 esx24 Instruments with high loads ( Harps, Strings, Cellos, Drums and Perc)
    -8 Long (16 Bar) drum tracks ( Bass, HH, Snare, Toms, Overheads, Fills, Percussion dubs)
    -4 Vocal takes and Dubs (more then 16 Bars long)
    -Bass Track
    -2 Acoustic stereo tracks
    -4 Guitar tracks, dubbs and fills
    -4 Slide Acoustic guitar tracks
    -4 dubbed effect vocal tracks
    AT first, he G4-450GHz Dual choked with 2 errors, then it buffered into the session well and played everything back fine of the same FW drive.
    The mac mini got major problems and only performed 28 tracks with the esx24 tracks frozen, and from time to time after heating up chokes again, i had to wait a few minutes before i bounced the session due to overload errors.
    Over all, Both have G4 Processors and about 1GIG ram (450GHz Dual is under 1 GIG), but its a clear fact that double processors win, even the lowest 450GHz Dual is still hotter then any flashy fast Bused mac mini, powerbook or iMac.

Maybe you are looking for