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.

Similar Messages

  • Form report with both edit and column link

    hi experts,
    How can we create form report with both edit and column link. Ie, the form should have both the Edit link and column link. When we click on the edit link(in page1) it should go for the page2 and the page2 should display the corresponding row fields which should be editable. but when i click the column link it should bring me to the next page but the corresponding values of the column should not be editable.
    Regars,
    KK

    hi,
    Here i have achieved this by making the column link and page navigation.

  • 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

  • How to loop through records in the block

    Hello,
    I have 2 blocks one emp_control_block and the other one based on the emp. The emp control block basically has some search critieria which is then passed onto the emp block to execute the query. However, I don't want to show any emp block data until the user presses the search button in the control block then I automatically want to make visible the EMP block and also set the width of columns. Right now, in the properties I have not assigned any Canvas to the EMP Block
    Can anyone tell me How do I loop through the block and show the items/columns in a canvas that I have already created. Any example of the code would be really appreciated. Thanks

    Monica,
    I tried your code but I get NO NAVIGABLE ITEMS IN DESTINATION BLOCK error. In the property palette for the items in the EMP block I have assigned Null as Canvas because I want to programatically assign it to the emp_stack_canvas. How do I do that? Also I want to change the item width for each column to say a fixed width of 50.
    Thanks

  • No data found when adding column link to classic report

    Hi,
    Oracle 11g r2, APEX 4.1.1.00.23.
    I have some classic reports.
    I go to Report Attributes, then I click Add Column Link in the "Tasks" right menu, it adds me a column link, I just add some text for the link and a page to go to.
    Then I run the report and I get :
    report error:
    ORA-01403: no data foundTested with several classic reports on multiple pages.
    Debug mode shows me :
    0.43816     0.00240     ...Execute Statement: select distinct [...] order by 3,11 ,4
    0.44056     0.00162     print column headings
    0.44218     0.04816     rows loop: 25 row(s)
    0.49037     0.00141     report error: ORA-01403: aucune donnée trouvée
    0.49175     0.00078     Computation point: After Box BodyWhen I run the query in my favorite tool, I get expected results.
    Did I missed something ?
    Thank you.
    Yann.

    Yann39 wrote:
    <font size="4">Is it an APEX bug ?</font>
    - Create a new Region of type Classic Report, then set Region source as :
    begin
    return test_return_query;
    end;- Run the page, the report works as expected
    - Go to Report Attributes and click Add Column Link (and just specify a text for the link and a page to go to).
    - Run the page, you should get the error !This might be unorthodox but try wrapping your returned query within an SQL statement, like so:
       begin
          return 'SELECT t.* FROM ('||test_return_query||') t';
       end;
    I can reproduce it on oracle.apex.com if needed...If my suggestion doesn't work, I think this might be the only option. You could create a new forum posting with the word "BUG" in the title, along with a link to this thread and the relevant workspace details (with guest developer credentials).

  • Interactive report, conditional display of column link

    Hello,
    We have requirement to disable editing in case that status of field is 1 (1=Closed).
    Is there any way to disable it on interactive report.
    case when status=1 column link should be disabled (not visible) in order to prevent future edits on payroll.
    SELECT payroll_no, status
    FROM hr_payroll
    ORDER BY payroll_no DESC;
    I tried link below, but it's not working in my case.
    http://nerd.net.au/24-apex-application-express/report-layout/92-conditionally-show-report-link-column-based-on-value-of-…
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    Application Express 4.2.2.00.11
    Thank you in advance,
    Regards, FM

    CASE WHEN status = 'ACTIVE' then
    <a href="f?p=&APP_ID.:60:&SESSION.::&DEBUG.::P60_EMPLOYEE_ID:'||employee_id||'"> </span><br /><span class="Moobi_Code"><img src="#WORKSPACE_IMAGES#deactivate_button.png"></a>'</span><br /><span class="Moobi_Code">ELSE NULL END deactivate_employee,
    from
    EMPLOYEES
    What exactly is the error you get? What HTML is showing in the HTML source?
    Just by looking at this I would say you need to remove the "/" in front of the f?p
    Keep in mind this way could cause problems if you start to use checksum, then you might want to look into using APEX_UTIL.PREPARE_URL to create your URL.

  • Conditional display of a column link in sql updateable report

    Hi There,
    I've attempted to look thru the Apex forum about using an Authorization Scheme in an SQL Query (Updateble Report) where I can conditionaly enable (display) a column link based upon a value in the report but alas I cannot find a solution.
    What I have is a SQL Query (updateable report). What I want to achieve is dependant on the value of one of the columns in the report query conditionaly display a column link for the row being displayed. For example if the report dispayed the data from emp, dept only display a column link for rows where the deptno = 100 otherwise don't display the column link. Is this possible to achieve?
    I've tried to define in the authorizatuon scheme in the where clause of an SQL Statement to reference the report column as #deptno# but this doesn't work.
    TIA

    Boketi,
    I was unsuccessful yesterday in demoing what I believe you want to achieve. It appears that an authorization scheme will not process row by row within a standard report so as to allow a conditional display of a link or any other column attribute. You can conditionally display a column by the use of a page item but this method appears to be all or nothing.
    I was successful when I coded the return of the empno via a Case statement but the Link still appeared even though there was no value (empno) to link with. So essence the link to you to a blank for with no PK to read the database by.
    SELECT CASE WHEN deptno = 10 THEN empno ELSE NULL END empno,
           ename,
           job,
           hiredate,
           sal,
           comm,
           deptno,
           phone_nbr
    FROM   empJeff

  • Reports: Javascript in Region Footer and Links in cells

    Hi all!
    I need to put hyperlinks in my APEX (4.0) Report and I read there is no direct option for it... this is how I thought to do, then...
    My reports contains two columns:
    DEVICE and HEALTH.
    The first contains a String with Devices' name, and the second a Number to be intended as percentual.
    I need Strings in DEVICE columns are also links to another APEX page where I have to generate a "dynamical" chart.
    I.E.: we can intend a Report Row where DEVICE is "000x0" and HEALTH "30".
    APEX generate HTML like this:
    <td headers="DEVICE" class="data">000x0</td><td headers="HEALTH" class="data">30</td>
    But I also need "000x0" to be a link to: "f?p=104:4:2205607043123699::::THE_DEVICE:000x0".
    As to say: the fourth page of my APEX site, where "THE_DEVICE" is an APPLICATION_ITEM and it have to contains the name of clicked Device.
    First thing I tried is to re-write pl/sql query to automatically returns html code for the link, like:
    select
    ''||DEVICE||'' as DEVICE,
    trunc(HEALTH, 2) as HEALTH
    from [...]
    But APEX convert special characters to &x; values:
    &amp;lt;a href=&amp;quot;f?p=104:4:2205607043123699::::THE_DEVICE:000&amp;quot; target=&amp;quot;_self&amp;quot;&amp;quot;&amp;gt;000&amp;lt;/a&amp;gt;
    Second thing I thought is to give an Unique ID to Report's Region ("ALARM_DEVICES_REG") and try to modify that text dynamically by adding JavaScript to Footer Region.
    I checked and found in this forum a JavaScript suggested to somebody which had similar problem to mine, then I tried to adapt to my situation.
    The fact is that my JavaScript in Footer Region doesn't seems to work at all! Neither a simple document.write("bye!"); comand!
    How possible?
    The JavaScript I tried to create could also contains errors, and it's the following:
    <script type="text/javascript">
    var y = document.getElementById('report_ALARM_DEVICES_REG')
    var x = y.getElementsByTagName('TD');
    var s;
    if (x)
    for (var i = 0; i < x.length; i++)
    s = x.item(i);
    if(s.getAttribute('headers') == 'DEVICE')
    s.data = replaceHtmlEntites(s.data);
    </script>
    I noticed the innerTable for Reports area has "report_ALARM_DEVICES_REG" id (while the outer has "ALARM_DEVICES_REG") so I used it to be more selective.
    replaceHtmlEntites is a function which should bring back special character from "&x;" values, and it's the following (I put it in "Function and Global Variable Declaration" area of Report's APEX page):
    var replaceHtmlEntites = (
    function() {
    var translate_re = "/&(nbsp|amp|quot|lt|gt);/g";
    var translate = {
    "nbsp": " ",
    "amp" : "&",
    "quot": "\"",
    "lt" : "<",
    "gt" : ">"
    return function(s) {
    return ( s.replace(translate_re, function(match, entity) {
    return translate[entity];
    Shouldn't this work? And if not, why?
    Thank you all!

    But APEX convert special characters to &x; values:If you had changed the report column type to "Standard Report column" , it would not hav escaped your HTML codes
    As for the JS code
    the function "replaceHtmlEntites" had an error at
    "lt" : "<"gt" : ">"it has to be
    {code}
    "lt" : "<",
    "gt" : ">"
    {code}
    In any case , you are doing a lot of extra work unnecessarily , firstly by not using the "column link" functionality and secondly trying to 'unescape' html code.
    Anyways,Here's a bit of code that does 'unescaping'
    {code}
    function htmlDecode(value){
    return $('<div/>').html(value).text();
    {code}
    +Note: This method is not a safe one+

  • Creating a column link and using a date/time field as one of the Items

    I have created an Interactive Report and set up a column link to another page. One of the Items in the column link is a Date field. When I click on the link I receive 'ORA-01403: no data found' for the linked page. In the Session attributes only DD-MON-YYYY HH24 passed and MI (minutes) was truncated... causing the error. I have created the same link on a Non-Interactive Report, DD-MON-YYYY HH24MI gets passed and the link works. Anyone have any clues on why the full date/time format is not being passed?
    The Item on the linked page has been set to Date Picker (DD-MON-YYYY HH24MI)
    Application Date Format is DD-MON-YYYY HH24:MI

    Hi,
    As David says colon is separator in URL for parameters.
    This is same kind of post about problem about comma. Values are separated by comma in URL. It might help you
    value truncation while printing page field in HTML
    Regards,
    Jari

  • Looping through an array to insert contents into an HTML table

    Im trying to loop through a String array and insert the contents into an html table, unfortunately my coding is only filling in the first row in the table and ignores any additional info. Im using webservices that is connecting to a table in the database.
    Info = ID + ";" + played + ";" + won + ";" + lost + ";" is the String im pulling into my client.
    <table border = "1">
    <tr>
    <td><b>ID</b></td>
    <td><b>played</b></td>
    <td><b>won</b></td>
    <td><b>lost</b></td>
    </tr>
    <%
    try {
         leglessclient.LegendServiceService service = new leglessclient.LegendServiceService();
         leglessclient.LegendService port = service.getLegendServicePort();
    String Info = port.displayLog();
    String[] log = Info.split(";");
    out.println("<tr>");
    for (int a = 0 ; a < log.length; a++) {
    for (int b = 0 ; b < 4; b++){
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    b++;
    out.println("</tr>");
    out.println("</table>");
    } catch (Exception ex) {
         // TODO handle custom exceptions here
    %>
    Any help would be greatly appreciated
    thanks!

    firstly, if you have multiple rows.. you need to start each row with <tr> and end with a </tr>. You just have one in the beginning and end,which will obivously give data in one row.
    out.println("<tr>");
    for (int a = 0 ; a < log.length; a++) {
    for (int b = 0 ; b < 4; b++){
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    out.println("<td>" + (log[a]) +"</td>");
    a++;
    b++;
    out.println("</tr>");

  • Looping through a directory to insert BLOBS

    I have about 300GB of jpegs to insert into my database. Does anyone have an example of how to loop through the directories, a directory at a time, to insert all of the images? Thanks.

    The best way is to probably use Java it iterate through the directories. You could either store the files in the database (BLOB) or just reference their location (BFILE). Unless you have another 300 or so GB to load the files in the database you will have to reference them. Unless you load a few hundred jpgs, delete them, ... loop. That way you would have the storage requirements. Java handles file access great and because you can wrap the java methods with PL/SQL its a great one two punch. Of course, you will need a java developer (ie. me).

  • How to Insert using QBE report in portlet?

    [This is using the latest version of Portal, 9.0.2]
    I have created a portlet which is based on the Report QBE.
    It displays fine, with Update and Delete columns/links for each row.
    However...
    When I created the portlet, I specifically said I wanted to display the Query, Reset and Insert buttons in the "Customization Form Display Options" Button Options. When I click on "Customize" from the Develop tab for my portlet, it shows the full page customize, which includes these buttons. But when I add the portlet to a region, and then click on its Customize link (to the right of the portlet's navbar), the resulting customize page does NOT show these buttons.
    How do I get Insert functionality working from a portlet? Do I have to do something more to make the portlet customize page show the necessary buttons?
    I feel like I may be missing something obvious (again!), but I can't figure it out, and I've looked in all the places I can think of.
    Help much appreciated...
    Regards
    Bryan

    You are not 'missing something obvious' , this is how it works. The insert option is not available for qbe reports as a portlets. Reason being that you may not want all users who are able to customize the report to insert data into the base table.
    For insertion of data use a form portlet or a link on one of the qbe columns.
    Sunil.

  • Need help - Create an application to loop through folder of images & insert

    Hi,
    We have a requirement to loop through a folder of images (around 1000) and insert all of them to a database. What is the best way to approach this. I am new to Swing, so looking for a bit of direction (not for anybody to write the code..I can do that :). Ideally, the user would be able to select all of the images they would like to upload.
    Any feedback much appreciated.
    Thanks.

    what you don't understand is that there is rarely a single straightforward solution,
    due to the various customizations available, so most regulars test their solutions
    just to make sure it works. This takes time - perhaps only a few minutes, sometimes
    significantly longer.
    how do you think we feel when we click on another forum, only to find a/the solution
    posted there some hours earlier?
    our time totally wasted, trying to help an inconsiderate arsehole
    keep going through life with no consideration for others - your kind are the first ones
    to go when 'downsizing' - and the current financial situation is looking good for that.
    (free tip: find yourself a good streetcorner now)

  • 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

  • Loop through checkbox in Oracle APEX 4.2 (using JQuery Mobile)

    Hello!
    I want question text and a report containing the possible answers is shown on a page. An answer can be selected by clicking on the checkbox. After hitting the submit button, the selected checkboxes containing the Answer Text, an answer_id and the current session_id are to be inserted into a table within the database.
    Within Oracle APEX 4.2, I am using a classic report to achieve this. Thich is actually a bad solution, because the checkboxes within the report are shown as simple HTML checkboxes, instead of neat JQueryMobile checkboxes). Anyway, this is my current solution:
    Is use this code for creating the classic report:
    SELECT APEX_ITEM.CHECKBOX(1,answer_id), answer_id, answer_text
    FROM ANSWERS
    WHERE question_ID = :P10_Question_ID;
    The insert of the data is done via the on submit process "On Submit - After Computations and Validations"
    This is the code for the on submit process:
    DECLARE var_session_id NUMBER := :P0_SESSION_ID;
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    INSERT INTO STUDENT_ANSWERS (answer_id, answer_text, session_id)
    SELECT a.answer_id, a.answer_text, var_session_id
    FROM ANSWERS a WHERE a.answer_id = APEX_APPLICATION.G_F01(i)
    END LOOP;
    COMMIT;
    END;
    But this solution does not work. Instead, nothing is inserted into the database.
    I don't know why the process is not inserting into the database, maybe there is something wrong with this line here WHERE a.answer_id = APEX_APPLICATION.G_F01(i) ?
    I even tried a simple update process for testing purposes, but this doesnt work either:
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    UPDATE STUDENT_ANSWERS SET text = APEX_APPLICATION.G_F03(APEX_APPLICATION.G_F01(i))
    WHERE am_id = APEX_APPLICATION.G_F02(APEX_APPLICATION.G_F01(i));
    END LOOP;
    COMMIT;
    END;
    Can anybody tell me how to loop through a checkbox within ORACLE APEX 4.2 and how to insert the values ANSWER_ID, ANSWER_TEXT and SESSION_ID into the table STUDENT_ANSWERS after hitting the submit button? If you would know how to do it without using a report but a simple checkbox, this would be even more helpful for me!

    I would start by putting this after submit, to check the contents of the array.
    apex_debug.message('count:'||apex_application.g_f01.COUNT);
    FOR i IN 1..apex_application.g_f01.COUNT LOOP
        apex_debug.message('i:'||i||':'||apex_application.g_f01(i));
    END LOOP;
    Then compare the contents with your answers table.

Maybe you are looking for