Delimited String To A Single Row Within A Table

I'll try to make a simple example of what I am trying to accomplish...
Let's say that I have a table (Blah) which has the following Fields:
User, DateTime, Q1, Q2.... all the way to Q50.  The Questions are radios with a value of 1,0, or null.
Since I didn't want to manually make 50 different items for the Radio questions, I am creating them from Javascript within a Region Source; as well as giving them id's and names.  This worked fine.
When I hit a submit button, I have Javascript create a delimited string for the questions, which I pass to a Shared Item.  (1,0,1,1,null,0,etc...)  I then have the Javascript run a Shared Procedure for the Insert into my Table.
Here is where I am stuck.  I am confused on how to merge the delimited string into my Insert statement, from PL/SQL.
Here is a dummied down sample of what I am trying to write.  (Shared Item is :ITEM_ARRAY, with a delimiter of ~:~ )
DECLARE
    array APEX_APPLICATION_GLOBAL.VC_ARR2
BEGIN
    array := APEX_UTIL.STRING_TO_TABLE(:ITEM_ARRAY, ':~:' );
    INSERT INTO tbl_blah (
        :APP_USER
        ,SYSDATE
         FOR z IN 1..array.count LOOP
             array(z);
         END LOOP;
END;
Every which way I tried, I always get Not Enough Values Error.
I tried to make everything in a delimited string as well:
Insert Into tbl_blah (SELECT * FROM array)
Can someone please enlighten me on the correct way to do this.  All of the examples I have seen are to write to multiple rows, via the loop.  I want to just have 1 record, horizontally.
Thanks !!!

Hi,
Why can't you insert a row into table with first two columns and do update for that row???
Just for simple work around, I have created a table with below columns,
USER_NAME VARCHAR2 
EXAM_DATE DATE
M1 NUMBER
M2 NUMBER
M3 NUMBER
M4 NUMBER
M5 NUMBER
M6 NUMBER
M7 NUMBER
M8 NUMBER
M9 NUMBER
M10 NUMBER
I wrote a below code to insert a row into that table,
declare
v_arr APEX_APPLICATION_GLOBAL.VC_ARR2;
v_stmt varchar2(1000);
begin
v_arr:= APEX_UTIL.STRING_TO_TABLE(:p_all_items,'~');
insert into test_group(user_name,exam_date) values (:APP_USER,sysdate);
dbms_output.put_line('row inserted');
FOR i IN 1..v_arr.COUNT LOOP
dbms_output.put_line('i='||i||' value='||v_arr(i));
if v_arr(i) is null then
v_stmt:='update test_group set m'||i||'=NULL';
else
v_stmt:='update test_group set m'||i||'='||v_arr(i);
end if;
dbms_output.put_line(v_stmt);
execute immediate v_stmt;
END loop;
end;
I just ran this block in 'SQL Commands', It worked for me. but i inserted only one row, so it updates a single row, In case of multiple row need to use the unique column for update. change the above code as per your requirement.
I hope this work around will help you. If not can you please create an example in apex.oracle.com and share login credentials.
Thanks
Lakshmi

Similar Messages

  • Drag and drop row within same table.

    Version 12.1.2
    I am trying to implement drag and drop row within same table, and I am trying to follow this sample from Frank:
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/106-reorder-table-rows-1921121.pdf
    But, I am getting this cast exception. The code I have in my dropEvent bean is identical to whats on the sample.
    oracle.jbo.server.ViewRowImpl cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
    ADF_FACES-60097:For more information, please see the server's error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #1
    Not sure if anything has changed on 12c release, or if I am missing anything.
    Here is my complete code:
    public DnDAction doDnD(DropEvent dropEvent) {
    RichTable table = (RichTable) dropEvent.getDragComponent();
    List dropRowKey = (List) dropEvent.getDropSite();
    if (dropRowKey == null) {
    return DnDAction.NONE;
    Transferable t = dropEvent.getTransferable();
    DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
    RowKeySet rks = t.getData(df);
    Iterator iter = rks.iterator();
    List draggedRowKey = (List) iter.next();
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    Row dragRow = draggeRowNode.getRow();
    JUCtrlHierNodeBinding dropRowObject = (JUCtrlHierNodeBinding) table.getRowData(dropRowKey);
    Row dropRow = dropRowObject.getRow();
    //get the table's ADF JUCtrlHierBinding
    CollectionModel collectionModel = (CollectionModel) table.getValue();
    JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
    DCIteratorBinding objectsIterator = treeBinding.getDCIteratorBinding();
    RowSetIterator rsi = objectsIterator.getRowSetIterator();
    int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
    dragRow.removeAndRetain();
    rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
    objectsIterator.setCurrentRowIndexInRange(indexOfDropRow);
    AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
    adfctx.addPartialTarget(table.getParent());
    return DnDAction.MOVE;
    It does not seem to like this line of code:
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    I would greatly appreciate any help.
    Thanks.

    Well there has bee a changes somehow. using 12c
    table.getRowData(draggedRowKey);
    returns a ViewRowImpl and no longer anything which can be convertet to JUCtrlHierNodeBinding. Anyway, the fix is easy:
        public DnDAction onDepartmentsRowDrop(DropEvent dropEvent) {
            //get the table instance. This information is later used
            //to determine the tree binding and the iterator binding
            RichTable table = (RichTable) dropEvent.getDragComponent();
            List dropRowKey = (List) dropEvent.getDropSite();
            //if no dropsite then drop area was not a data area
            if (dropRowKey == null) {
                return DnDAction.NONE;
            //The transferable is the payload that contains the dragged row's
            //row key that we use to access the dragged row handle in the ADF
            //iterator binding
            Transferable t = dropEvent.getTransferable();
            //get the row key set of the dragged row. The "rowmove" string is the
            //discriminant defined on the drag source and the collectionDrop target.
            DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
            RowKeySet rks = t.getData(df);
            Iterator iter = rks.iterator();
            //for this use case the re-order of rows is one-by-one, which means that the rowKeySet
            //should only contain a single entry. If it contains more then still we only look at a
            //singe (first) row key entry
            List draggedRowKey = (List) iter.next();
            //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
            Object objdrop = table.getRowData(dropRowKey);
            Row dropRow = (Row) objdrop;
            //get the table's ADF JUCtrlHierBinding
            CollectionModel collectionModel = (CollectionModel) table.getValue();
            JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
            //get access to the ADF iterator binding used by the table and the underlying RowSetIterator.
            //The RowSetIterator allows us to remove and re-instert the dragged row
            DCIteratorBinding departmentsIterator = treeBinding.getDCIteratorBinding();
            RowSetIterator rsi = departmentsIterator.getRowSetIterator();
            int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
            //remove dragged row from collection so it can be added back
            dragRow.removeAndRetain();
            rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
            //make row current in ADF iterator.
            departmentsIterator.setCurrentRowIndexInRange(indexOfDropRow);
            //ppr the table
            AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
            //note that the refresh of the table didn't work when refreshing the table
            //so I needed to refresh the container component (af:panelStretchLayout).
            adfctx.addPartialTarget(table.getParent());
            return DnDAction.MOVE;
    does the trick. I changed the line to
    //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
    so you don't need the detour through the JUCtrlHierNodeBinding any longer.
    Timo

  • ADF: How to get the attributes' values of one single row from a table?

    Currently I have a table with 3 attributes, suppose A,B and C respectively. And I've added an selectionListener to this table. That means when I select one single row of this table, I wish to get the respective value of A, B and C for that particular row. How do I achieve this?
    suppose the method is like:
    public void selectionRow(SelectionEvent se) {            //se is the mouse selection event
    .......??? //what should I do to get the values of A\B\C for one single row?
    Edited by: user12635428 on Mar 23, 2010 1:40 AM

    Hi
    Assuming you are using Jdev 11g.
    Try with this
    public void selectionRow(SelectionEvent se) {
    String val = getManagedBeanValue("bindings.AttributeName.inputValue");
    public static Object getManagedBeanValue(String beanName) {
    StringBuffer buff = new StringBuffer("#{");
    buff.append(beanName);
    buff.append("}");
    return resolveExpression(buff.toString());
    public static Object resolveExpression(String expression) {
    FacesContext facesContext = getFacesContext();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp =
    elFactory.createValueExpression(elContext, expression,
    Object.class);
    return valueExp.getValue(elContext);
    Vikram

  • Two radio buttons in a single row of a table

    Hi All,
    Can we have two radio buttons in a single row of ADF TABLE.
    My requirement is that i have a list of submitted records. The user can approve or reject the records.
    All the records are displayed in the table. there will be two columns in the table(Approve , Reject) The user can approve the first record and reject the second record and so on....
    using table selectOne we can select only one row. Using radio buttons how to select the multiple records, at the same time grouping is done between the two columns(radio buttons) in the table

    Hi,
    I don't think that you can do this with radio buttons. The usecase is more for chackboxes. It would have been a usecase for radio buttons if there was a single column with 3 possible options
    - pending
    - approved
    - rejected
    Frank

  • Adobe form from webdynpro : Getting a single row in the table

    Hello,
    I have a scenario in which I have to create a adobeform from webdynpro application.
    I have created the form and have the context designed in place.
    I am facing a problem in the table I have in my adobeform.
    I am adding rows to this table dynamically using a button using "addInstance"
    Now on the webdynpro side , when I try to read this table I get a single row from this table.
    This row is always the first row of that table.
    I checked the following things from blog   /people/juergen.hauser2/blog/2006/09/12/avoiding-common-mistakes-when-using-tables-on-sap-interactive-forms  , i.e. :
    Cardinality of the node.
    Tick on the option "Repeat Row for Each Data Item".
    But still no success.
    With deadlines to catch I had to post this question after trying a lot.Please help.

    Hello Otto,
    I had found this link before and used the same solution , but unfortunately is taking a long time.
    Now what I am doing is :
    1. I append 10 rows into the table then bind it to the node
    2. Then on the adobe form I have removed the check on "Add row for each line item" because of which it shows only 1 row 
         on the form.
         Now I add rows dynamically, but this puts a limit on the number of rows can be added to the table i.e. 10.
    But this again has added problems like while displaying the form or modifying I hav to handle it seperately and cannot use the same form as it is.( as I have removed the tick for "Add row for each line item" ).
    Thanks,
    Omkar Mirvankar

  • How to update a single row of data table

    How we can update a single row of the data table by clicking the button in the same row.
    Thanks in Advance.

    Hi!
    What do You mean 'update'? Get fresh data from DB or change data and commit it in DB?
    If commit, try to read here:
    http://developers.sun.com/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    Thanks,
    Roman.

  • Refreshing only the single row of  ADF Table

    Hi All,
    I have a webcenter application where the ADF Applications has been deployed.Now the Data is coming onto the ADF Tables from a webservice.In that particular table i need to refresh only the single row(whichever selected by the user to edit ) or even a particular field with the updated values as well as need to validate and to create a message box saying about the errors if the validation goes wrong.
    Please suggest!!

    Hi,
    if "updated value" mean that the value got changed on the middle tier (not the browser client) then the update requires the table to be partially refreshed. If the user edits a row and in this row has dependent fields, then this can be achieved by partially refreshing the column. Note that ADF Faces tables don't refresh just one cell
    Frank

  • Referencing rows within a table

    Hi all,
    I don't know if this has been brought up before, and believe me I have looked, but here goes...  I have a table with many tens of rows.  Cell 1 of those rows is a checkbox with the exit event scripted as (formcalc)
    if 
    (this.rawValue == "1") then
    form1.Main_Subform.GeneralTable.Row1.presence
    = "visible"
    else   form1.Main_Subform.GeneralTable.Row1.presence = "hidden"
    endif
    What I want to do is not have to put the above script in each event of each checkbox.  So is there a way of referencing all the checkboxes at once and having the same result of making the associated row go hidden if not checked?
    Also, I have a reset button for the form that I want to be able to reset all row presences to visible when clicked.  I should mention here that the form has several tables all with checkboxes in cell one and all with add buttons that addInstances at the bottom of the tables that I do not want reset with the reset button.  In short, the tables list controlled documents that need to be reviewed annually and that because of the sheer volume of them will need to be parsed out, and the parsing may or may not be entire tables and the tables need to be able to be added to.  Here is what I have regarding the reset of the presences of the rows (I have only just begun):
    xfa.host.resetData();
    form1.Main_Subform.GeneralTable.Row1.presence
    = "visible";form1.Main_Subform.GeneralTable.Row2.presence
    = "visible";form1.Main_Subform.GeneralTable.Row3.presence
    = "visible";form1.Main_Subform.GeneralTable.Row4.presence
    = "visible";
    So my question regarding the reset button is...  Is there a way of resetting the presences of all rows within either all tables or each table without listing each and every row individually within the click event of the reset button?
    Thank you all in advance.  -rpeterson

    Hi,
    You can add one more button to your form. On click event of this button you can put script, which will loop througth all rows of your table and check checkbox, if it will be checked then hide is bot - leas as it is.
    If you want to hide row after click on checkbox, you have to put scripts to each of it.
    BR,
    Paul Butenko

  • Can't compare a row with other rows within a table.. (many to many compare)

    Hi all..
    I am very new to PL/SQL..
    I need to travers through a table for comparing it's rows with in the table with other rows. For this I am trying to use bellow Pl/sql.
    create or replace compare()
    Declare
    VAR_HIT CHAR(1);
    SEARCH_RECORD_DATA UDB.table1%ROWTYPE;
    CANDIDATE_RECORD_DATA UDB.table1%ROWTYPE;
    CURSOR SEARCH_RECORDS_CURSOR IS SELECT * FROM UDB.table1 order by registration_id;
    CURSOR CANDIDATE_RECORDS_CURSOR IS SELECT * FROM UDB.table1 order by registration_id;
    BEGIN
    FOR SEARCH_RECORD_DATA IN SEARCH_RECORDS_CURSOR LOOP
    FOR CANDIDATE_RECORD_DATA IN CANDIDATE_RECORDS_CURSOR LOOP
    IF (CANDIDATE_RECORD_DATA.DECISION='P') THEN
    VAR_HIT:='y';
    IF(CANDIDATE_RECORD_DATA.FIRST_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.FIRST_NAME!=SEARCH_RECORD_DATA.FIRST_NAME) THEN
    VAR_HIT:='n';
    ELSIF(CANDIDATE_RECORD_DATA.LAST_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.LAST_NAME!=SEARCH_RECORD_DATA.LAST_NAME) THEN
    VAR_HIT:='n';
    ELSIF(CANDIDATE_RECORD_DATA.BIRTH_DATE!='unknown') AND (CANDIDATE_RECORD_DATA.BIRTH_DATE!=SEARCH_RECORD_DATA.BIRTH_DATE) THEN
    VAR_HIT:='n';
    ELSIF(CANDIDATE_RECORD_DATA.GENDER!='U') AND (CANDIDATE_RECORD_DATA.GENDER!=SEARCH_RECORD_DATA.GENDER) THEN
    VAR_HIT:='n';
    ELSIF(CANDIDATE_RECORD_DATA.FATHER_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.FATHER_NAME!=SEARCH_RECORD_DATA.FATHER_NAME) THEN
    VAR_HIT:='n';
    ELSIF (CANDIDATE_RECORD_DATA.MOTHER_NAME!='unknown') AND (CANDIDATE_RECORD_DATA.MOTHER_NAME!=SEARCH_RECORD_DATA.MOTHER_NAME) THEN
    VAR_HIT:='n';
    END IF;
    IF(VAR_HIT='y') THEN
    INSERT INTO UDB.BIO_DI_HIT_RESULT(REGISTRATION_ID,SEARCH_ID,HIT_CANDIDATE_ID,SEARCH_DETAILS,CANDIDATE_DETAILS) VALUES (SEARCH_RECORD_DATA.REGISTRATION_ID,SEARCH_RECORD_DATA.EGM_NO,CANDIDATE_RECORD_DATA.EGM_NO,VAR_SEARCH_DETAILS,VAR_CANDIDATE_DETAILS);
    UPDATE UDB.BIO_RECORDS_DEMOGRAPHICS SET DECISION='D';
    END IF;
    END IF;
    END LOOP;
    commit;
    END LOOP;
    END;
    Outer loop is working fine (it is raversing throughout the table) (say for 8000 records 8000 times)
    But Enner loop is not working fine e.i. it's running just for 8000 times for 8000 records. while it should run more then 8000 time..
    Can any one help me..
    Is the way of using two cursor on one table for comparing each row of record is correct????????? :(

    Finally I come up with this:
    INSERT INTO UDB.BIO_DI_HIT_RESULT(REGISTRATION_ID,SEARCH_ID,HIT_CANDIDATE_ID,SEARCH_DETAILS,CANDIDATE_DETAILS)
    SELECT SEARCH.REGISTRATION_ID, SEARCH.Key_NO,CANDIDATE.Key_NO,
    'First name='||SEARCH.FIRST_NAME||',Last name='||SEARCH.LAST_NAME||',Birth date='||SEARCH.BIRTH_DATE||',Gender='||SEARCH.GENDER||',Fathers name='||SEARCH.FATHER_NAME||',Mother name='||SEARCH.MOTHER_NAME,
    'First name='||CANDIDATE.FIRST_NAME||',Last name='||CANDIDATE.LAST_NAME||',Birth date='||CANDIDATE.BIRTH_DATE||',Gender='||CANDIDATE.GENDER||',Fathers name='||CANDIDATE.FATHER_NAME||',Mother name='||CANDIDATE.MOTHER_NAME
    FROM UDB.BIO_RECORDS_DEMOGRAPHICS SEARCH,UDB.BIO_RECORDS_DEMOGRAPHICS CANDIDATE
    WHERE (SEARCH.FIRST_NAME!='unknown' OR SEARCH.LAST_NAME!='unknown' OR SEARCH.BIRTH_DATE!='unknown' OR SEARCH.GENDER!='unknown' OR SEARCH.FATHER_NAME!='unknown' OR SEARCH.MOTHER_NAME!='unknown')
    AND SEARCH.REGISTRATION_ID != CANDIDATE.REGISTRATION_ID
    AND SEARCH.REGISTRATION_ID < CANDIDATE.REGISTRATION_ID
    AND (SEARCH.FIRST_NAME='unknown' OR CANDIDATE.FIRST_NAME IN (SEARCH.FIRST_NAME,'unknown'))
    AND (SEARCH.LAST_NAME='unknown' OR CANDIDATE.LAST_NAME IN (SEARCH.LAST_NAME,'unknown'))
    AND (SEARCH.BIRTH_DATE='unknown' OR CANDIDATE.BIRTH_DATE IN (SEARCH.BIRTH_DATE,'unknown'))
    AND (SEARCH.GENDER='U' OR CANDIDATE.GENDER IN (SEARCH.GENDER,'U'))
    AND (SEARCH.BIRTH_DATE='unknown' OR CANDIDATE.BIRTH_DATE IN (SEARCH.BIRTH_DATE,'unknown'))
    AND (SEARCH.FATHER_NAME='unknown'OR CANDIDATE.FATHER_NAME IN (SEARCH.FATHER_NAME,'unknown'))
    AND (SEARCH.MOTHER_NAME='unknown' OR CANDIDATE.MOTHER_NAME IN (CANDIDATE.MOTHER_NAME,'unknown'))
    ORDER BY SEARCH.REGISTRATION_ID;
    Now it realy meet all my final table requirement.. I am happy.. :)
    But again last requirement is like..
    In the final BIO_DI_HIT_RESULT table I need to add one more column named as match_count
    This column will have values of total no. of exact match field (not unknown) for each records in the BIO_DI_HIT_RESULT.....
    One way of duing this is--
    Step1: I will use a cursor for traversing through each of the rows in BIO_DI_HIT_RESULT.
    Step 2: And based on count of matches in search_details(substring) and candiate_details(substring) I update each and every rows of the table.
    It will be very slow.. And for records like 2 million records.. I can't think of this idea. :(
    Sooooo,, Is there ANY BETTER WAY OF DOING THIS AS WELL.. BETTER MEANS FAST WAY.. :(
    Thanks in advance....
    Edited by: user13367608 on Jan 8, 2011 2:13 AM

  • How to highlight a single row in the Table components

    Hi,
    I am trying to do the following :
    1) Select a staff member's name from a dropdown list
    2) click on dropdown.name and show all the projects the member is working in a Table1
    3) when clicked on the project in Table1, show all team members of selected project in Table2.
    I would like to highlight the original staff member's name in Table2. Any ideas how I should go about doing it ? I tried the setSelected() method, but this selects all rows.
    TIA

    Winston has a blog on that topic:
    http://blogs.sun.com/roller/page/winston?entry=setting_table_column_style
    Lark

  • Outputting Results in a single row from a Table

    Afternoon folks,
    I have a scenario in hand and I was hoping to get some pointers. I could write a PL/SQL program and all would be fine. I was hoping if there was a way to do it in SQL and not have to create a whole new sub-program for this. I already have a PL/SQL program that populates a table. I want to use that data now and output it in a certain manner.
    Any help is greatly appreciated and this is not something I need to solve by tonight. :)
    Script to create table and insert records into it:
    drop table FLIGHT_ROUTES;
      CREATE TABLE FLIGHT_ROUTES
       (FLIGHT_NO           VARCHAR2(7),
        ROUTE_ID            NUMBER,
        DAY_OF_OPERATION    NUMBER,
        ORIGIN              VARCHAR2(3),
        DESTINATION         VARCHAR2(3),
        STOPVER             VARCHAR2(3),
        ROUTE_TYPE          VARCHAR2(1)
    REM INSERTING into FLIGHT_ROUTES
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-1001',1,1,'SFO','LAX',null,'D');
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-1001',1,2,'SFO','LAX',null,'R');  -- Record 2
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,1,'SFO','JFK',null,'D');
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,2,'SFO','JFK','ORD','D');
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-2001',2,3,'SFO','JFK','DEN','R');  -- Record 5
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,1,'LAX','JFK','YYZ','D');
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,2,'LAX','JFK','YYC','D');
    Insert into FLIGHT_ROUTES (FLIGHT_NO,ROUTE_ID,DAY_OF_OPERATION,ORIGIN,DESTINATION,STOPVER,ROUTE_TYPE) values ('UX-3001',3,3,'LAX','JFK','YUL','D');What I would like to do is output the results by Flight Number, Origin1, Destination1, Origin2, Destination 2 and Origin 3, Destination 3. The maxium number combinations per Flight is 3. The other condition is that the listing should only show the Origin and Destinations and Stopover if it's a Day time Flight. If its a Red Eye, then don't show that option. So, Record 2 would be completely omitted here as it's a Red Eye flight and Record 5 would be omitted for Origin/Destination/Stopover 3 for flight UX-2001.
    Flight_No       Origin1     Destination1    Stopover 1      Origin2          Destination2      Stopver2      Origin3    Destination3     Stopover3
    ============================================================================================================================================================
    UX-1001         SFO         LAX
    UX-2001         SFO         JFK                             SFO              JFK               ORD
    UX-3001         LAX         JFK             YYZ             LAX              JFK               YYC           LAX        JFK              YULEdited by: Roxyrollers on Sep 9, 2011 3:59 PM
    Edited by: Roxyrollers on Sep 9, 2011 3:59 PM
    Edited by: Roxyrollers on Sep 9, 2011 4:00 PM

    Hi,
    Assuming that day_of_operation is what determines whether a row is 1, 2 or 3:
    WITH     got_r_num     AS
         SELECT     f.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  flight_no
                                   ORDER BY          day_of_operation
                           ) AS r_num
         FROM    flight_routes        f
         WHERE     route_type     != 'R'
    SELECT       flight_no                              || ',' ||
           MAX (CASE WHEN r_num = 1 THEN origin      END)     || ',' ||     -- Origin 1
           MAX (CASE WHEN r_num = 1 THEN destination END)     || ',' ||     -- Destination 1
           MAX (CASE WHEN r_num = 1 THEN stopver     END)     || ',' ||     -- Stopover 1
           MAX (CASE WHEN r_num = 2 THEN origin      END)     || ',' ||     -- Origin 2
           MAX (CASE WHEN r_num = 2 THEN destination END)     || ',' ||     -- Destination 2
           MAX (CASE WHEN r_num = 2 THEN stopver     END)     || ',' ||     -- Stopover 2
           MAX (CASE WHEN r_num = 3 THEN origin      END)     || ',' ||     -- Origin 3
           MAX (CASE WHEN r_num = 3 THEN destination END)     || ',' ||     -- Destination 3
           MAX (CASE WHEN r_num = 3 THEN stopver     END)  AS csv_text            -- Stopover 3
    FROM       got_r_num
    GROUP BY  flight_no
    ORDER BY  flight_no
    ;Output:
    CSV_TEXT
    UX-1001,SFO,LAX,,,,,,,
    UX-2001,SFO,JFK,,SFO,JFK,ORD,,,
    UX-3001,LAX,JFK,YYZ,LAX,JFK,YYC,LAX,JFK,YULThis does not assume that origin1 is always on the same row with day_of_operation=1. Origin1 will be from the row with the lowest day_of_operation, not counting red-eyes. Likewise, origin2 will be from the row with the 2nd lowest day_of_operation, whether that value is 2 or not.
    If your data is such that the row with day_of_operation=n will necessarily be the nth lowest one, not counting red-eyes, then you don't need the sub-query got_r_num; just use your real table (with the condition WHERE route_type != 'R'), and use day_of_operation where I used r_num. (This is what Solomon's solution, which I just saw, does.)
    Edited by: Frank Kulash on Sep 9, 2011 4:47 PM
    Edited by: Frank Kulash on Sep 9, 2011 4:53 PM

  • JAVA code for fetching a single row from a table in SAP

    Hi All
    Can anybody please tell me how to implement the "Select Single" query in JAVA while accessing SAP
    Our requirement is to fetch the Sales Document number(VBELN) by passing the Purchase Order Number(BSTKD) from any of the tables containing these two fields like VBKD.
    Thanks in Advance
    Sree Ramya

    Hi Vijay/Rich/Ravi
        I am already using this FM RFC_READ_TABLE.  In this FM, we have a parameter called <b>DATA</b> in <b>TABLES</b> list.  The length of the record of this table DATA is 512 charaters, whereas the length of the record of the table <b>VBKD</b>(the table which i am trying to fetch) is 586 characters.  As a result of which, an exception is being thrown stating that "The record does not fit into the table <b>DATA</b>".
    Plz clarify this.
    Thanks,
    Sree Ramya.

  • Can we delete a single row in SID table?

    I am having a problem with conversion exit in SID table. 
    These are the error messages.
    Value in SID table is TPV; correct value is TPV; SID in SID table is 875
    Message no. RSRV200
    Diagnosis
    The following data record either has an incorrect internal format or the characteristic value that is in the correct format appears as a corrected value of another incorrect value:
    ·     Characteristic value: TPV
    ·     SID: 875
    ·     Correct characteristic value: (see below) TPV
    ·     SID after correction: 875
    Value in SID table is TPV 2008; correct value is TPV; SID in SID table is 2887
    Message no. RSRV200
    Diagnosis
    The following data record either has an incorrect internal format or the characteristic value that is in the correct format appears as a corrected value of another incorrect value:
    ·     Characteristic value: TPV 2008
    ·     SID: 2887
    ·     Correct characteristic value: (see below) TPV
    ·     SID after correction: 875
    Now the row with SID 875 is causing the problem. Is it possible that I can delete only this row in the SID table.
    Thanks for your help
    Subra

    Hi.....
    Procedure :
    RSA1>>>InfoObjects >>Right Click on InfoObject >>delete Master Data >> u can see the option of deleting SIDs............
    Otherwise........u can delete value from a SID table......u can use tcode SE14...........to delete the entries.........
    Check this......
    deleting contents of SID table.
    But still I will suggest u not to delete SID...........it may lead to inconsistency of data.........
    Try to repair SId using the program : RSDMD_CHECKPRG_ALL or RSRV...........
    Regards,
    Debjani......

  • Edit a single row in af:table

    I am using af:table. In the af:columns I am using a h.Inputtext. Also I have placed one Edit af:command link in starting of every row. At first all the input fields are not editable.( ie I have set the readonly property to true). After click the Edit link all the columns in the particular row should be editable. I tried it so many times but couln't get any solution. Is anybody know the solution for this problem. I want it urgently.
    Thanks
    Satheesh

    One solution I can think of is to use the detail disclosure feature of the ADF Faces table.
    Your table will be a read only table and into the detailDisclosure area you drag an input form.
    Now when someone clicks the show link he'll be able to edit the row.

  • Trying to insert a single row in a table based on NOT EXIST

    Hi,
    I have a procedure where i am doing an insert into the table say
    create table ABC(PK number, valu varchar2(10));
    insert into ABC values(1,'hi');
    Now my problem is that this procedure may be run several times so if a PK already exists, it should not try to insert again. so I came up with the solution..
    insert into ABC select (1,'hi') from ABC where not exists (select 1 from ABC where PK=1);
    but the problem with this is that if Pk=1 does not exist and if the table already has 5 rows, 5 insertions of PK=1 are being done..
    can anyone plz help me.
    thanks

    Why dont you let Oracle handle the uniqueness of the records and you make your code robust to handle that exception?
    DUP_VAL_ON_INDEX exception can be caught in your procedure and no action needs to be taken on that in this case.

Maybe you are looking for