Loop Through Rows in SQL Report.

Hello Everyone,
I've been creating a very different application, and I've run into quite the roadblock.
Let me give you a breif about the problem.
I have a form that needs to be dynamic and thus is created at runtime.
I have used the APEX_ITEM and a SQL SELECT CASE to create a dynamic report.
For example if the DATATYPE column in my table says DATE, I create an APEX_ITEM.DATE_POPUP, if it says CHAR i create a textbox, and if a column called
LOV is populated APEX_ITEM.SELECT_LIST_FROM_QUERY using the number value of the LOV to query a List of Values from another table.
Now this brings me to say in a single column of the there could be different data_types. meaning the multi-row update functionality with apex will not work.
Getting the data to display is easy. However saving the updates is a different story.
Which brings me to my question. Does anybody know of way in which you can loop through each row in a SQL Report on APEX and assess each row individually.
I'd like to accomplish something like this
LOOP
MyUpdateProcedure(currentrow_id,currentrow_datatype, currentrow_value)
Go to Next Row in Report
END LOOP;
Pretty simple in theory? Do we have an APEX expert out there who could give me a hand with this?

Codes,
It sounds to me like you could add a hidden field to tell you what you need to know in order to determine the column to update.
Assuming it was created using the parameter p_idx = 50 and contained the names you provided (eg DATA_DATA) and your primary key is created using p_idx = 1 then you could add the logic for the update into an on submit process something like so
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
CASE apex_application.g_f50(i)
WHEN 'DATA_DATA' THEN
-- run the update against the data column
WHEN 'CHAR_DATA' THEN
-- run the update against the char column
etc.
If the multi-type column is created with the apex_item api using p_idx = 2 then you just refer to it in the loop as apex_application.g_f02(i) and the primary key is apex_application.g_f01(i).
I hope this helps.
Greg

Similar Messages

  • Looping through row selector exonentially duplicating

    Using Apex 4.2
    Background
    Created a Tabular Form based on a view. Removed all the default multi-row updates and deletions, buttons and processes.
    I am using a tabular form because of the fact that I can gain access to a row selector.
    The row data itself is all read only so in effect this is a report with a row selector.
    This is because I can't find a way to select a row an interactive report, well I can and did but this was a work around.
    Problem
    I have created a button to process the selector to run the below code:
    begin
    kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f01(1)) ;
    kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f02(1)) ;
       for i in 1..wwv_flow.g_f01.count
       loop
       kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'i:'||i) ;
          kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'WF ID:'|| wwv_flow.g_f02 (wwv_flow.g_f01.count)) ;
       end loop;
    end;
    I just wanted to see what would be output. For one row this works fantastically and I can find the ID based on the row
    When I select more than one row the loop run's through for the number of rows but then also runs for the number of rows selected.
    So if I selected threee rows this above procedure would run three times, each times looping three times.
    I have set the execution scope to: For Created and Modified Rows in the button condition that appears.
    Required
    I only want to loop through the selected rows once per button click
    OR
    Know which row I am currently looping through.
    Really would appreciate some kind of input here.

    I think the built in selector is making your life harder because the information that contains is 1,2,3,4,5.  You then need to map 3 to the ID of your 3rd row.
    So, if you check row 1 and 3, on submit, the row selector will have two rows, one with value of 1 and with with value of 3.
    I would remove the selector, use and ID column that I can change to be Simple Checkbox (or whatever value you can use to uniquely identify it).  Or add your own apex_item.checkbox(n, ID) to your SQL.
    Then your loop on apex_application.g_f01.count (if that's the checkbox column) will only contain the elements checked and their values will be the ID that are checked.
    All that said, here's a useful example from Denes Kubicek
    http://apex.oracle.com/pls/otn/f?p=31517:95
    Hope this makes sense
    Thanks
    -Jorge
    http://rimblas.com/blog/
    Message was edited by: jrimblas
    Added link to Denes example page

  • Problems looping selected rows in a report

    Hi,
    I have a report on my form, of type SQL Query (updateable report), that I populate using the following SQL:
    SELECT APEX_ITEM.CHECKBOX(1,prvidd,'CHECKED') " ", prvidd, prvnme, prvlev
    FROM vu_roleprivs
    WHERE rolidd = :P32_ROLIDD
    The first two columns are hidden, so that when it comes to inserting/updating then all rows will be processed (this is a requirement).
    I use the following process to loop through the report rows...
    DECLARE
    vROW VARCHAR2(4000);
    prvIDD NUMBER;
    prvLEV VARCHAR2(3);
    BEGIN
    FOR i IN 1..APEX_APPLICATION.G_F01.COUNT
    LOOP
    vROW := APEX_APPLICATION.G_F01(i);
    prvIDD := APEX_APPLICATION.G_F02(vROW);
    prvLEV := APEX_APPLICATION.G_F04(vROW);
    -- Delete the current row from PDROLPRV
    DELETE FROM pdrrolprv WHERE rolidd1 = :P32_ROLIDD and prvidd1 = prvIDD;
    -- Now insert the record from the table row
    INSERT INTO pdrrolprv VALUES(:P32_ROLIDD, prvIDD, prvLEV);
    END LOOP;
    END;
    ... but when the process runs I get the following error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    I can't see where I am going wrong - can anyone help, would be much appreciated.
    Best regards
    Simon

    Hi Simon,
    This might be stating the obvious, but first up I would determine exactly where the code is failing by putting dummy values instead of variables into the following statements: -
    DELETE FROM pdrrolprv WHERE rolidd1 = :P32_ROLIDD and prvidd1 = prvIDD;
    INSERT INTO pdrrolprv VALUES(:P32_ROLIDD, prvIDD, prvLEV);
    Assuming the code then runs correctly, start putting your variables back 1 by 1 until you find the failure. You might also want to dump out your variable values: -
    vROW := APEX_APPLICATION.G_F01(i);
    prvIDD := APEX_APPLICATION.G_F02(vROW);
    prvLEV := APEX_APPLICATION.G_F04(vROW);
    to a test table.
    Hope that helps. Give me a shout if you're still having trouble.
    Mike

  • How to exclude one or more rows of SQL report from sorting?

    In my SQL report I want to exclude one row from sorting. This row must be permanently at the bottom of the report.
    How to achieve this?
    Regards,
    Al

    Hi Al,
    Check out this thread: Sort within Break? I was looking to preserve a basic sort for break purposes, but the same solution should work for keeping one row at the bottom.
    Let me know if you'd like more details.
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Upload XLS File, Loop through rows query a DB

    What I would like to do is enable the user to upload an excel
    spreadsheet with one column and many row of IP's. Then put the ips
    in a list or array and loop through the list and query a table to
    get the IPs that match the list.
    Any help would be greatly appreciated.

    We have some similar apps except that, instead of uploading a
    file, the users copy and paste the column into a text area. Then we
    do this:
    <!--- First, replace carraige returns (chr(13)) and line
    feeds (char(10)) with commas --->
    <cfset
    hscnumbers=Replace(form.hscnumbers,chr(13)&chr(10),",","ALL")>
    <!--- remove last comma, if commas exist (there may be
    only one hsc number) --->
    <cfif find(",", hscnumbers) gt 0 and right(hscnumbers, 1)
    is ",">
    <cfset hscnumbers = left(hscnumbers, len(hscnumbers) -
    1)>
    </cfif>
    And then we have a list to send to the db.

  • How do i loop through a pl/sql collection based on a condition.

    hi, can any one help me or provide me sample code where  i have to loop through a collection  based on condition . just like where clause in sql. your help is highly appreciated....
    {code}
    create table MODEL1
      model_id  NUMBER ,
      model_seq NUMBER,
      p_ind     VARCHAR2(1)
    insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
    values (4, 103, 'U');
    insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
    values (3, 102, 'P');
    insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
    values (2, 101, 'U');
    insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
    values (1, 100, 'P');
    MODEL PROCEDURE......
    procedure (  param1,param2)        ( assume this procedure is being called from other procedure and collection has been populated already)
    TYPE  l_tab is table of  MODEL1%rowtype;
    begin
    loop through l_tab records where  ltab.model_id=param1  and  p_ind =p
    Join based on if else condition.
    if   param2 is not null then
       l_tab.model_seq=param2 and ltab.p_ind='P'
    if param2 is null then
             l_tab.p_ind='P'          etc...........
       {code}

    Hi,
    Try something like this:
    DECLARE
    TYPE L_TAB IS  TABLE OF MODEL1%rowtype;
    TAB L_TAB;
    param1 number := 1;
    param2 number := 999;
    BEGIN
    select
      model_id
      ,model_seq
      ,p_ind
    bulk collect into TAB
    from
      MODEL1
    DBMS_OUTPUT.PUT_LINE('PARAM1: ' || PARAM1);
    DBMS_OUTPUT.PUT_LINE('PARAM2: ' || PARAM2);
    DBMS_OUTPUT.PUT_LINE('     MODEL_ID, MODEL_SEQ, P_IND' );
    FOR X IN TAB.FIRST .. TAB.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('OLD: ' || TAB(X).MODEL_ID || '         ' || TAB(X).MODEL_SEQ || '        ' || TAB(X).P_IND );
        IF TAB(X).model_id = param1 AND TAB(X).p_ind = 'P' THEN
          IF param2       IS NOT NULL THEN
            TAB(X).model_seq := param2;
    --        TAB(X).p_ind := 'P';     -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
    NULL;
          END IF;
          IF param2     IS NULL THEN
    --          TAB(X).p_ind  := 'P'; -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
    NULL;
          END IF;
        END IF;
    DBMS_OUTPUT.PUT_LINE('NEW: ' || TAB(X).MODEL_ID || '         ' || TAB(X).MODEL_SEQ || '        ' || TAB(X).P_IND );
    END LOOP;
    END;
    PARAM1: 1
    PARAM2: 999
         MODEL_ID, MODEL_SEQ, P_IND
    OLD: 4         103        U
    NEW: 4         103        U
    OLD: 3         102        P
    NEW: 3         102        P
    OLD: 2         101        U
    NEW: 2         101        U
    OLD: 1         100        P
    NEW: 1         999        P
    Regards,
    Peter

  • How to loop through rows in datatable?

    Hi,
    I have a datatable component with a few columns bound to a database table but I have also added a new textfield column to the datatable. The purpose of this datatable is to present the user with a list of products from the database and then allow the user to enter a quantity value into the textfield for each product (ie datatable row).
    This all works fine until i need to capture the quantity values the user has entered. It seems the datatable component can only provide the current row details. However what I want to do is when the user finishes entering the quantities for all the products they click a button and then I loop through each row in the datatable from start to end and find out what quantities were entered for each product.
    I can find no documentation or threads on how to do this. It seems like a very basic concept but perhaps is not possible to achieve. Can anyone help?
    Also I entered a default value of "0" in the value expression (ie text) property of the new textfield in the datatable but this value never appears (ie the textfields are always empty). However the text property seems to work ok for normal textfield components not within a datatable. Any ideas?
    Thanks.

    thanks, I am able to iterate through the datatable rows now and get the values, however I still have one (actually two) big problem...
    1. I cannot get the textfields to be prepopulated with a value when the page first loads. I have the text property of the textfield set to a value but this makes no difference, the textfields are always blank.
    2. After a user enters values and clicks the button to calculate the page reloads and again all entered values are gone (ie the damn textfields are empty again). Is this normal behaviour for textfields within a datatable....surely not.
    So, I added some code to my prerender method to specifically populate the textfields and although it loops through each textfield only the last textfield gets populated. I cannot work this one out. Datatables should be easy to work with, but like most things Creator turns an easy job into an impossible one.
    Please help.

  • Loop through values in rows to find faulty data

    Hi all,
    We have a column which is supposed to have values in increasing order.(If it doesn't comply with this rule, we want to discard the row). How do I loop through rows for a particular column, in SQL or PL.SQL?
    Thanks.

    user12295995 wrote:
    If it doesn't comply with this rule, we want to discard the rowNot sure what you mean. It looks like you want to get rid of duplicates. If so, use:
    DELETE tbl WHERE ROWID NOT IN (SELECTMIN(ROWID) FROM tbl GROUP BY col)
    /If you want to identify gaps, use:
    with t as (
               select 1 id from dual union all
               select 2 id from dual union all
               select 3 id from dual union all
               select 4 id from dual union all
               select 5 id from dual union all
               select 11 id from dual union all
               select 12 id from dual union all
               select 13 id from dual union all
               select 21 id from dual union all
               select 22 id from dual union all
               select 23 id from dual
    select  '[' || (prev_id + 1) || ' - ' || (id - 1) || ']' gap
      from  (
             select  id,
                     lag(id) over(order by id) prev_id
               from  t
      where id > prev_id + 1
      order by id
    GAP
    [6 - 10]
    [14 - 20]
    SQL> SY.

  • Changing datasource of reports in a loop only works for first report.

    Hi,
    I have code that loops through a list of reports to change the datasource and save the change in the report. The idea is that this can be done at build time so time taken at runtime is only for opening the report and running it.
    The problem is that the first iteration of the loop works, and any further ones don't. Apart from closing the client document is there anything else that should be explicitly closed? I don't retrieve any ReportSource from the Client Document so I shouldn't need to dispose of that...I don't think. In particular is there something that should be done to the databaseController retrieved from the clientDoc after each loop?
    The code goes like the below:
    for(File report : reports){
         System.out.println("Preparing report: " + report.getAbsolutePath());
         ReportClientDocument clientDoc = CRJavaHelper.getReportClientDocument(
                   report.getAbsolutePath());
         CRJavaHelper.replaceDBConnection(clientDoc, props);
         clientDoc.close();
         System.out.println("Report " + report.getAbsolutePath() + " prepared.");
    getReportClientDocument does this:
    ReportClientDocument clientDoc = new ReportClientDocument();
    clientDoc.setReportAppServer("inproc:jrc");
    clientDoc.open(fullPath,
              OpenReportOptions.openAsReadOnly.value());
    return clientDoc;
    replaceDBConnection does the following:
    DatabaseController dc = clientDoc.getDatabaseController();
    logonDataSource(dc, username, password);
    prepareReport(dc, schema);
    ConnectionInfos cis = dc.getConnectionInfos(null);
    for (IConnectionInfo oldci : cis) {
         IConnectionInfo newci = new ConnectionInfo();
         newci.setKind(ConnectionInfoKind.SQL);
         newci.setAttributes(propBag);
         newci.setUserName(username);
         newci.setPassword(password);
         dc.replaceConnection(oldci, newci, null, DBOptions._useDefault
                   + DBOptions._doNotVerifyDB);
    SubreportController src = clientDoc.getSubreportController();
    IStrings strs = src.getSubreportNames();
    Iterator<?> it = strs.iterator();
    while (it.hasNext()) {
            String name = (String) it.next();
         ISubreportClientDocument subreport = src.getSubreport(name);
         DatabaseController sdc = subreport.getDatabaseController();
         cis = sdc.getConnectionInfos(null);
         for (IConnectionInfo oldci : cis) {
              IConnectionInfo newci = new ConnectionInfo();
              newci.setAttributes(new PropertyBag(propBag));
              newci.setUserName(username);
              newci.setPassword(password);
              sdc.replaceConnection(oldci, newci, null, DBOptions._useDefault
                        + DBOptions._doNotVerifyDB);
    clientDoc.save();

    What's the URL for the site where you are using this?  Offhand, it looks like it should work with your first example so you are either placing the script before those elements are loaded or you might try wrapping your current javascript inside the:
    $(document).ready(function() {
    --- your existing javascript here
    This make sure the code runs once all the html is loaded on the page.  Without seeing a URL and debugging with the js console in Chrome I can't give you a solid answer.
    But, I do know that you can probably do this with a lot less markup.  Once we figure out what the actual problem is I have a better solution mocked up for you on jsfiddle.
    When looking at my HTML code on jsfiddle, please realize I setup some dummy HTML and removed your tags and added actual values which would be output by your tags.  The main thing I did was remove the whole div.more-selection and instead, added a "data-is-selected" attribute on your div.more-option element.  Then, in my javascript for each div.my-option element on the page, we loop through them, find the value of that data attribute and hide that div if it's less than 1 (or 0).
    Here's the fiddle for you to look at:  http://jsfiddle.net/thetrickster/Mfmdu/
    You'll see in the end result that only two divs show up, both of those divs have data-is-selected="1".
    You can try pasting the javascript code near the closing </body> tag on your page and make sure to wrap my js inside a <script> tag, obviously.  My way is neater on the markup side.  If you can't get it to work it's likely a jquery conflict issue.  My version is using the $(document).ready() method to make sure all the code is loaded before it runs.
    Best,
    Chris

  • Looping through business partners

    I need to run a query that shows which BPs have NOT had a recent delivery.  Therefore, I am searching for values not present.  I have decided to run a subquery pulling up all deliveries within the last month and then looping through all BPs to see if they are in that query.  If not, I want to display their name as part of the result.  I am not sure how to loop through BPs in SQL using Query Generator.  Any idea of syntax?
    Thank you in advance for you help!
    Jacquie

    I'm not sure about this, but I guess that you can't set parameters in that second SELECT at all.
    This works:
    SELECT T0.CardName FROM OCRD T0
    Where T0.CardCode Not in
    (SELECT T0.CardCode FROM OINV T1
    WHERE datediff(Day,T1.DocDate, getdate())<0)
    This doesn't: (I changed only: getdate())<'[%0]')
    SELECT T0.CardName FROM OCRD T0
    Where T0.CardCode Not in
    (SELECT T0.CardCode FROM OINV T1
    WHERE datediff(Day,T1.DocDate, getdate())<'[%0]')
    Regarding your SQL. From the syntax point of view:
    - include a space between "NOT_in"
    - maybe you should eliminate T0.DocDate from the second SELECT
    HTH
    Juha

  • How to loop through classic report rows?

    Hi,
    I have a page that has a classic report region. Can I somehow loop through the rows in the report result?
    If I put a checkbox item in the query then using this works fine, but I would not like to add checkbox I just would like to loop through the records.
    FOR I in 1..APEX_APPLICATION.G_F02.COUNT LOOP
    Do something with record having  checkbox item value APEX_APPLICATION.G_F02(i);
    END LOOP;
    TIA,
    Tamas

    Andy,
    What I would like to do is to let the user click a report row, then navigate to a detail form page and display detailed information of the given report row. And should the suer decide to have a look at all the records, then let him/her click a next button on the detail form and display the next row in the report result on the detail form.
    Thanks for the tip. if there is no other way, I will probably do this way.
    Tamas

  • Urgent : Deleting a row in a sql report region

    Hi
    I have an SQL report, i must have an icon "delete row", when clicing this icon the row must be deleted from the report,
    what I have do but not sure of this :
    in my query I am containing some html in witch I have an icon, when the user click on this icon, I have to delete the currect row of the record
    How can I reference the currect row, and how can I clear the currect row of a report ?
    thank you

    Off course not.
    You will refer only those primary key column or composite column in your where clause. So, no matter if your table has 15 or 90 columns. All, you need to refer only those key columns in your where clause of your main query and also use them in the sub-query which is connected with IN clause.
    But, i think another approach is showing the use of exists operator. You can check that, too.
    And, in the last post Karthik has shown you the analytic approach which i prefer.
    I gave you my solution without modifying your existing sql. So, that you can understand it without a lot of hard-work and reading. ;)
    I would also request you to check the performance issue on all the solutions which have provided to you by all of us. And, you can choose the best from it after going through the explain plan details.
    So, final ball is in your court. ;)
    Take some breath - and make your wise judgment on it. :)
    Best Of Luck.
    Regards.
    Satyaki De.

  • Loop through result set and delete row

    so here is what I need -
    I have a query that pulls rows from the Database through a stored procedure.(these are properties in an area)
    Before I start looping through the query, I need to check the distance between my current location and the property. If it less than 5 miles, only then should I display that property. The distance in miles will be chosen while submitting the search form.
    So is there a way to delete rows from the result set based on the criteria? Or
    Is there a better way to accomplish this? I am using the the google api to get the latitudes and longitudes. The other issue to keep in mind is the load time.
    Thanks

    You can do this the easy way or the hard way.  Depends on whether your condition that needs to be checked can be expressed in the form of a SQL where clause.  If it can, then do what BKBK suggested, and use a query of query to create a new resultset that only has the rows from the original resultset that don't meet your condition.
    If the calculation of the condition is more complex, then do a CFLOOP over the query and examine each row to see if you want to keep it or toss it.  if you want to toss it, the delete that row - there is a function in CFLIB.ORG called querydeleterow that should help you.  Or, you could just clear out the row's contents and then do the query of query as described in BKBK's post to create a new resultset that doesn't include the blank rows.

  • Loop through nested elements and insert via PL/SQL

    INSERT INTO Orders(id, OrderXML) VALUES
    (S_Orders.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <Order xmlns="urn:foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:foo foo-1.xsd">
    <OrderRef>BBB</OrderRef>
    <OrderDate>2005-03-29</OrderDate>
    <CustomerID>1051</CustomerID>
    <Items>
    <Item>
    <ProductID>7</ProductID>
    <Price>45.6</Price>
    <Quantity>2</Quantity>
    </Item>
    <Item>
    <ProductID>19</ProductID>
    <Price>73.5</Price>
    <Quantity>10</Quantity>
    </Item>
    </Items>
    </Order>'
    I some questions regarding index search of nested elements like,Items in the above example.
    I would like to know how I can LOOP through the Items like 1..2 LOOP
    and insert those elements(item) into one table. Order information should go in to another table.
    Can this be done with xpath and PL/SQL.
    Regards
    Ulf

    Hi Marco!
    Here's some more information:
    CREATE TABLE ITEM (ProductID NUMBER,
    Price NUMBER(8,2)
    Quantity 10 NUMBER);
    CREATE TABLE ORDER (OrderRef VARCHAR2(10),
    ORDER_DATE VARCHAR2(10),
    CUSTOMERID NUMBER);
    The main problem that I have is to create an solution that can be dynamic so that I can have for instance one order and four items in one XML.
    The second XML can have one order and 10 items.
    First I want to insert the order elements in the order table and then the items records in the item table.
    To complicate things futher my real XML have namespaces in the XML, but this I think I can handle.
    Summary: So for each order row(element) I want to traverse the Item elements and insert them to the Item table.
    Regards
    /Ulf

  • Insert Loop through a Report or Insert using a Column Link

    Hello!
    I think I have an easy one.
    I have created a site that tracks "issues" with the curriculum of a university's courses. If a curriculum developer sees something that must be updated, they use this site to log the "issue" so we have a running list of how the curriculum has changed for the particular course or courses. Some "issues" span multiple courses, so a table was created to allow the issue to be associated with as many courses as necessary.
    The "Courses" table holds a list of all courses at the university
    The "Issue_Courses" table combines the primary key for the "issue" and the "course" and creates the association between issues and courses.
    The page users use to create the associations has a report called "add_courses" which is searchable and filterable so the user can narrow down the list of courses they want to view (the list is well into the thousands), and this report contains a column with check boxes. This page also contains a hidden field containing the primary key for the issue, "p13_Issue_ID"
    I would like to create an insert statement that grabs the primary key for the issue from "p13_issue_ID" and loops through the report, inserting a new record for each checked box in the report. Any assistance would be great! Admittedly, my sql is pretty week.
    Another option that I think would work, if possible, would be to have a "column link" that simply runs the insert process by grabbing the issue primary key from "p13_issue_ID" and the course id from the report. Then, the user could simply click on an "Add" link or something similar on the report, which would run the insert statement, and basically create that association. Is this possible?
    Thanks in advance!
    Edited by: 846852 on Mar 23, 2011 3:12 PM
    Edited by: 846852 on Mar 23, 2011 3:14 PM

    Start with adding a checkbox column to the report in page (13 ??)
    select apex_item.checkbox(1,course_id) CHECK
           ,course_name
    FROM courses
    I assumed that course_id is the PK of the courses table , if not change the column names appropriately
    In report attributes of the "CHECK" column, change the column type to "*Standard Report Column*" (important).
    Now you should see a report with courses lists and checkboxes to choose them, You can also do the same with an interactive report(if you want to use it features to filter down records)
    Inorder to process the records create a PLSQL process that loops over the selected records(courses) and creates the relation in the Issue courses table using the hidden item and checked course primary key(course_id above)
    DECLARE
      ln_course_id NUMBER;
    BEGIN
      FOR 1 IN 1..APEX_APPLICATION.G_f01.COUNT
      LOOP
        ln_course_id := APEX_APPLICATION.G_f01(i);
        --Insert new relation using Issue Id and course ID
        INSERT INTO ISSUE_COURSES(course_id,issue_id) VALUES( ln_course_id,:P13_ISSUE_ID);
      END LOOP;
    END;If you have a submit/save button , make the process conditional for that button.

Maybe you are looking for