SLQ: A loop with the select line, counters and variables

Hello!

I have a bit of a pickle SQL and would be very happy to any experienced help.
I have a big enough table that contains two columns in particular (illustrated by a few examples)

REFERENCE
Mouth Med Chem (2008) 16, 1111-1124
Bioorg Med Chem Lett. 2008 may 1; 9:2820 - 4 EPUB 2008 Apr 4
BR J Pharmacol. In February 1999; 3:665 - 72.

2_ YEAR
1996
2001

Sometimes, the two columns are null. What I want to do, it is to loop through the table and pull on the date of the REFERENCE column and update the YEAR_2 column with it.

My current code snippet is as follows:

declare
x number: = 1995;
cursor s1 is SELECT rowid, t.* FROM CB1ASSAYS t WHERE REFERENCE like "%x % ';
Start
While x loop < 2006
C1 loop s1
Update CB1ASSAYS set YEAR_2 = x
where REFERENCE like "%x % ';
x: = x + 1;
end loop;
end loop;
commit;
end;
/


However, it doesn't seem to work properly. He updated lines with 1995 in the year, but no date higher. Curiously, he updated a number of records with the year 2064, when there was no 2064 anywhere in the REFERENCE entry.

There are no errors encountered when I run this script.

Any idea?

Thank you!

In your code the where conditions update should be:

WHERE REFERENCE like '%'||x||'%';

and you can get rid of the slider at all:

declare
 x number := 1995;
begin
 while x < 2006 loop
   update CB1ASSAYS set YEAR_2 = x
   where REFERENCE like '%x%'
   AND YEAR_2 is null --To update only null years
   ;
   x := x + 1;
 end loop;
--commit;  IT's better you you commit after checked if all is ok...
end;
/

Max

Published by: Massimo Ruocchio July 5, 2011 19:59
got rid of the cursor loop for...

Tags: Database

Similar Questions

  • For loops with the cursor line and indexing

    Hi all

    I have a question about the loops with the cursor, line and indexing.

    How can I scan via a cursor with an iterator?

    I would use an iterator as

    Whole LoopIndex;
    Whole LoopIndex2;

    for LoopIndex at the beginning of the cursor at the end of the cursor
    loop
    line =: cursor [LoopIndex];
    for LoopIndex2 of LoopIndex at the end of the cursor
    etc...
    end loop;

    I need to use an iterator because I need to use a nested for loop.



    OR


    How can I solve the following problem?

    Class name % ofClass average test Score
    1 Niobe 7 8 8.4
    1 alena 4 7 7.5
    1 9 7 8.9 Estia
    1 Lilly 10 8 9.8
    1 Sandra 6 8 8.3
    1 Melanie 8 8 8.1
    Nadia 2 8 3 4.4
    Sayuki 2 9 8 8.4
    Diasy 2 7 8 8.0
    Flower 2 7 8 6.5
    Diana 2 6 8 7.3
    3 Flora 7 8 5.8
    Sukiya 3 4 8 8.4
    Samantha 3 10 8 7.7
    Roxanne 3 7 8 6.9
    Eline 3 8 8 7.4

    I need to
    -By class, I need to recalculate each average people
    -By class, I need to calculate the % of class score (sum averages / people in the class)

    So it can be done in a nested for loop?
    Or do I just step by step?

    Well, based on this information it would be something like...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 1 as Class, 'Niobe' as Nm, 7 as Score, 8 as Tests, 8.4 as Average from dual union all
      2             select 1, 'Alena', 4, 7, 7.5 from dual union all
      3             select 1, 'Estia', 9, 7, 8.9 from dual union all
      4             select 1, 'Lilly', 10, 8, 9.8 from dual union all
      5             select 1, 'Sandra', 6, 8, 8.3 from dual union all
      6             select 1, 'Melanie', 8, 8, 8.1 from dual union all
      7             select 2, 'Nadia', 3, 8, 4.4 from dual union all
      8             select 2, 'Sayuki', 9, 8, 8.4 from dual union all
      9             select 2, 'Diasy', 7, 8, 8.0 from dual union all
     10             select 2, 'Blossom', 7, 8, 6.5 from dual union all
     11             select 2, 'Diana', 6, 8, 7.3 from dual union all
     12             select 3, 'Flora', 7, 8, 5.8 from dual union all
     13             select 3, 'Sukiya', 4, 8, 8.4 from dual union all
     14             select 3, 'Samantha', 10, 8, 7.7 from dual union all
     15             select 3, 'Roxanne', 7, 8, 6.9 from dual union all
     16             select 3, 'Eline', 8, 8, 7.4 from dual)
     17  --
     18  -- END OF TEST DATA
     19  --
     20  select class, nm as "NAME", score, tests, average
     21        ,round(((average*tests)+score)/(tests+1),1) as avg_person
     22        ,round((average / sum(average) over (partition by class))*100,1) as class_average
     23  from t
     24* order by class, nm
    SQL> /
    
         CLASS NAME          SCORE      TESTS    AVERAGE AVG_PERSON CLASS_AVERAGE
    ---------- -------- ---------- ---------- ---------- ---------- -------------
             1 Alena             4          7        7.5        7.1          14.7
             1 Estia             9          7        8.9        8.9          17.5
             1 Lilly            10          8        9.8        9.8          19.2
             1 Melanie           8          8        8.1        8.1          15.9
             1 Niobe             7          8        8.4        8.2          16.5
             1 Sandra            6          8        8.3          8          16.3
             2 Blossom           7          8        6.5        6.6          18.8
             2 Diana             6          8        7.3        7.2          21.1
             2 Diasy             7          8          8        7.9          23.1
             2 Nadia             3          8        4.4        4.2          12.7
             2 Sayuki            9          8        8.4        8.5          24.3
             3 Eline             8          8        7.4        7.5          20.4
             3 Flora             7          8        5.8        5.9            16
             3 Roxanne           7          8        6.9        6.9          19.1
             3 Samantha         10          8        7.7          8          21.3
             3 Sukiya            4          8        8.4        7.9          23.2
    
    16 rows selected.
    
  • The hand with the red line icon and cursor freezes HP Compaq Presario CQ57-402SV

    I recently purchased (2 days) the laptop above in Greece. Sometimes no reason apparent, while using the touchpad, I get an error sound and a big hand icon with a red line through it and the cursor hangs. It cannot be erased by sleep, then reopened. Any help would be welcome. Thank you.

    most counsumer laptop touchpad leftside corner has for the touchpad toggle switch. If you tap on this area, it will be enable and disable the touchpad. Once disabled, you get the hand with the red line.

    Please avoid pressing on the area on the side right touchpad upper-left that turned on like a light switch.

  • [JDev12c, ADF] How to get the value of a field from the selected line in af:table and...

    Hallo,

    I want to double click on a line of an af:table to call a page that displays a form (based on a View object) with the details of the selected line.

    I need to go to the second page the value of a field on the line that is selected on the first page.

    How can I do this? In particular, how can I get the value of a field from the selected line? How can I call the second page on double-click on the af line: table?

    Thank you

    F.

    Why would user, you need to pass a value of the line to the shape?

    The framework selects the line you want to display in the form. All you have to do is to show the form with the selected line. It is the framework automatically as long as you use e vo even the same data control.

    Timo

    Post edited by: Timo Hahn
    And the handling double-clicks is described here http://www.oracle.com/technetwork/developer-tools/adf/learnmore/56-handle-doubleclick-in-table-170924.pdf

  • I opened my photos of my SDCard with File Explorer, select them all, then I select move to fill after that I saw the bar of loading with the green line. After that all my photos from my computer disappered and were removed from my SD card. Please, he

    I opened my photos of my SDCard with File Explorer, select them all, then I select move to fill after that I saw the bar of loading with the green line. After that all my photos from my computer disappered and were removed from my SD card. Help, please

    I looked everywere in my computer, but they are not found

    I bet that you have selected the folder Adobe Bridge CC or CS6, and it would be in there under Program Files/Adobe/or Program Files (x 86) / Adobe /.

    Move to... in the file Explorer apply only to records not the bridge program.

    You open Bridge and Photo Downloader allows you to move pictures from your SD card in the deck (also called import)

    Gene

  • All the solutions to the tool polygonal lasso that is not in line with the selection?

    In PhotoShop CS4, the polygonal lasso tool is not consistent with the selection when it is closed, but creates a curvy almost segment of circle.

    I think you may have a radius of large feathers defined in the Options bar you upstairs when the lasso tool is selected. Make sure that it is 0.

  • Deployment of final application with the command line Question

    OK so I have my finished application.

    on a folder in my office called "CODBOUG".

    So I tried different methods to run the application and complete the test on the Simulator with the command line. But it's just too much. So I need your help community!

    I tried:

    BlackBerry-deploy-installApp-package CallofDutyBlackOpsUltimateG

    uide.bar - device 192.168.18.128

    I'm a little lost with the help of the command line, if someone could guide me on the right lane.

    I'm on windows, btw.

    Thank you.

    When you run a command, Windows will search in a series of directories for this program to run. The list of directories is stored in what is called an environment variable. You must add the path to the bin of the sdk at this variable directory (e.g. C:\Program Files (x 86) \Adobe\Adobe Flash Builder Burrito\sdks\blackberry-tablet-sdk-0.9.3\bin).

    You can access the path variable by right-clicking on my computer > properties. Select the Advanced tab and click on approx. Variables.

    Under System Variables, search PATH and edit it. Add the path to the sdk bin directory (make sure that there is a semicolon, that separates the directories).

    Open a command line window in the directory where your .bar file. When you run the command, Windows will look for blackberry - deploy and can be found in the directory that you have added to your PATH variable so to run it.

  • How to highlight the selected line in an interactive report in apex5?

    Hello

    I want to emphasize the selected line in the report by changing the background color of the line. Basically, I want to do this. I really want to do is, select a row in the report and according to the selected line, I want to retrieve other data to another interactive report on the same page. So, how can I do this?

    Hi geslin,.

    Garza says:

    But here shows a link to another page or something like that. But I don't need that. I just want to show when the user selects a specific row by clicking on this line, and it should show that it has been selected by changing the color of the line and after having extracted a few hidden field and according to those column data display data on another report on the same page.

    Check your Application-> Page 2 30870. I've set up a dynamic action to reach the line highlighted when selected.

    Here are the steps to achieve the highlighted line:

    • Changed the definition of class employee culminating point to CSS-> section of the line on the page:
    .highlight-employee
       {
        background-color: blue !important;
        color: white !important;
       }
    
    • Commented the code written in JavaScript-> Execute JS when the section of the page to load the page.
    • Edited the ROWID of your interactive report column and set the following properties for 'column link:

    Text link: #ROWID #.

    Link attributes: id = "" #ROWID # "class ="monlien""

    Target: URL

    URL: javascript:void (0);

    • Dynamic action created with the following properties:

    Name: highlight_selected_row

    Event: click on

    Selection type: jQuery Selector

    jQuery Selector: a.mylink

    Action: Run the JavaScript Code

    Fire on loading the Page: No.

    Code:

    var row_id = this.triggeringElement.id;
    $('#P2_NEW').val(row_id);
    $('#'+row_id).parent().closest('tr').find('td').addClass('highlight-employee');
    

    Scope of the event: Dynamics

    Kind regards

    Kiran

  • Updated all the selected lines in a table.

    Hello

    Jdev Version 11.1.2.3.0

    I'm trying to update all the selected rows in a table with several choices.

            AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
            ViewObject vo = am.findViewObject("RegistrationHistory1");
            RowKeySet selectedRegistrations = historyTable.getSelectedRowKeys();
    
    
            if (selectedRegistrations != null) {
                Iterator iter = selectedRegistrations.iterator();
                    while (iter.hasNext()) {
                        Object facesTreeRowKey = iter.next();
                        Row[] row = vo.findByKey((Key)((List)(facesTreeRowKey)).get(0), 1);
    
    
                        if (row != null && row.length == 1) {
                            Row r = row[0];
                             r.setAttribute("Attr", "1"); 
                        }
                    }
              }
    

    But after I put the attribute on the line. My iterator ignores most of the lines and they don't last updated.

    It works very well for the removal of the line well.

    Any suggestions?

    It turn out that I got a try catch and in the catch, I had a log (e.printStackTrace ()) and I do not see a single line in the diary saying ConcurrentModificationException appearing all the time.

    Looks for read-only access to an attribute or delete lines is OK to iterate over the selected lines, but it's different for the modification of an attribute.

    The code that worked:

    Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    Entry DCIteratorBinding = bindings.findIteratorBinding ("RegistrationHistory1Iterator");

    RowSetIterator regRSiter = regIter.getRowSetIterator ();

    RowKeySet selectedRegistrations = historyTable.getSelectedRowKeys ();

    Object [] keys = selectedRegistrations.toArray ();

    for (Object key: keys) {}

    Line currentRow = regRSiter.getRow ((Key) ((List) key) .get (0));

    removeOrModify (currentRow);

    }

  • Add line before or after the selected line in af:Table

    Hello

    Please let me know how we can add a line before or after the selected line in the display: table.

    Currently I have a table with 2 buttons on toolbar. 1. Add 2. Add after.

    The user selects the row and click a button AddBefore and after... then, a blank line must have added in the table according to the clicked button.

    Please suggest me your entries.

    Thank you
    Kiran

    chk this
    http://mjabr.WordPress.com/2011/07/02/how-to-control-the-location-of-the-new-row-in-aftable/

  • Multiple selection query to view the selected line

    Hi all

    I have a requirements make multiple selection of a region in the table and need to display the values of the selected line in the page.

    so I'm able to multiple selection of the table, but all when trying to print the values, it is still only printing selected values of line one not several.

    the code I use to print several rows below the selected values.

    for (int i = 0; i < fetchedRowCount; i ++) {}
    Rowi ABCEOViewRowImpl =
    (ABEOViewRowImpl) selectIter.getRowAtRangeIndex (i);

    If (rowi! = null) {}
    If (Y".equals (rowi.getReprint ())) {" "}
    for (int j = 0; j < fetchedRowCount; j ++) {}
    String srnum = rowi.getSerialNumber ();

    throw new OAException ("after Srno" +)
    srnum,
    OAException.INFORMATION);
    }
    }
    }
    }

    where fetchedrowcount - no lines in the region of the table
    Here srnum is printing only one value.

    Please guide me where to check this problem.

    Thank you
    Deb

    Hi Deb,

    Unable to get the requirement. Why the second for loop... ?

    Still, the OAException must be thrown exception during the first use that meets the condition.

    Please try to use "srnum" in tabular or use it to add all the required values in the for loop and finally throw the exception.

    Concerning
    Sanujeet

  • How can I default first line below the selected line in the table of the adf

    Hello

    I use Jdeveloper 11 g,
    I created Adf quick query with table and changed selectionListener table as #{CustRMMap.onRMGroupNameChange}.
    and when I click on find fast query no row is selected.
    I want the first row to be selected / highlighted by default when I click search.

    Patel Imran

    You can also set an attributeValue in pagedef.xml
    bind this attributeValue with column of your table. This sets the value of the selected line to the variable attruibute.
    Will now link this with your desired component attributeValue.
    Put partial trigger on the component that should display this value.
    This will save you to write custom code and use the default table selection listener property, which marks the first default line.

    Apart from this, if you want to govern the first default line of managed bean selection use this code...

    + _Table = selectionEvent.getSource ((richeTableau)) richeTableau; + *
    + / / the model in the Collection is the object that provides the structured data.
    + / / for rendering table +.
    + TableModel CollectionModel = table.getValue ((CollectionModel)); + *
    + / / the ADF object that implements the CollectionModel is JUCtrlHierBinding. IT +.
    + / /is wrapped by the CollectionModel API.
    + JUCtrlHierBinding adfTableBinding = tableModel.getWrappedData ((JUCtrlHierBinding)); + *
    + / / Acess the iterator ADF, binding that is used with the binding table ADF +.
    + DCIteratorBinding tableIteratorBinding = adfTableBinding.getDCIteratorBinding (); + *

    + / / the role of this method is to synchronize the table feature selection +.
    + / / with the selection of the model of the ADF +.
    + Object selectedRowData = table.getSelectedRowData (); + *
    + / / cast of JUCtrlHierNodeBinding, which is the subject of the ADF that is +.
    + / line/a +.
    + JUCtrlHierNodeBinding nodeBinding = selectedRowData (JUCtrlHierNodeBinding); + *
    + / / get the key of the node binding line and set it as the current line in the +.
    + / / iterator +.
    + Key rwKey = nodeBinding.getRowKey (); + *
    tableIteratorBinding.setCurrentRowWithKey (rwKey.toStringFormat (true)); + *

    and another way on the right is a custom like this code:

    + public void setDefaultRow (int count) {/ / call this method your method of selection custom, rom pass the line of the line to select index. count = 0, will select first row + *}

    + try {+ *}
    Object oldRowKey = tblMag.getRowKey (); *
    + try {+ *}
    This.

    .getSelectedRowKeys () .clear ();
    *
    * +} catch (System.Exception e) {+ *}
    System.out.println (e.getMessage ()); *
    +}+
    This..setRowIndex (count);
    *
    RKS RowKeySet =. getSelectedRowKeys();
    *
    (RKS). Add(. getRowKey());
    *
    RKS =. getSelectedRowKeys();
    *
    +.setRowKey (oldRowKey); +

    * +} catch (System.Exception e) {+ *}
    System.out.println ("error:" e.getMessage ()); + *
    +}+
    +}+

    Hope this helps

    Concerning
    Maryline Roussel

  • Getting a value from all the selected lines in the method of the AM

    Hi all

    I use JDev 11.1.1.4.0

    I have a table with the selection of several lines. In my module application I want to call a stored procedure with the parameter whose value depends on the selected line in the table.
    For the only selection I can make fallow:
        public void wypiszId() {
            ViewObject vo = findViewObject("ProcsklView1");
            String st = vo.getCurrentRow().getAttribute("IdProcskl").toString();
            System.out.println(st);
    How can I deal with multiple selection?

    Kind regards
    Wojtek.

    Hello

    VO/iterator will hold only selected line at a time. Thus, for multi table enabled selection, the last selected line would be the selected line (vo / Iterator). In order to obtain all the selected lines, you must obtain support bean by linking the Table of the ADF.

    Check out this blog on this goal.

    http://blogs.Oracle.com/aramamoo/2010/12/getting_all_selected_rows_in_adf_table_with_multiple_rows_selection_enabled.html

    Arun-

  • Why most of the tabs open empty with the label "New tab" and "topic: vacuum ' in the address line to the restart of Firefox since installing Firefox 28?"

    I have a system dual-bootable Windows Vista SP2 and Firefox updated to 28 on both systems. Since the update of the tabs more reopen empty with the label "New tab" and "topic: vacuum" in the address line of Firefox is restarted. The tabs that open correctly seem to be those who in fact, I was at the session of prefious. I can recover the missing tabs using the Session Manager to pick up a previous session, but of course it does not pick up the tabs open in future sessions. It seems that the tabs that I go to the session recovered are saved correctly, as indicated above, but which are not revisited in the context of the use of the session retrieved will drop the URL next time that I open Firefox it again.

    jdgale:

    I don't have the time to do it. However, 29 is just around the corner and we will put in the channel of exit 29, then hope that the issue is not you.

    P.S. I had originally chosen your last answer as the solution that you have migrated more to 29 but it seems that you have taken off. I'll be marking your last answer as the solution so that we can get out of the queue.

  • Not compatible with the selected drive - Satellite A300D firmware update

    Hi, I have a problem with the update of the firmware. When I try it says "the Firmware is not compatible with the selected driver.

    And another problem is that my dvd drive does not DVD - R and DvD + R is running very slow and big trouble, it must try several times to succeed.

    Please help me.

    Hello

    Maybe you should tell us what CD/DVD drive you have and where you have downloaded the update of the firmware.
    In my opinion firmware update is not normally necessary.

    Have you ever tried to remove upper and lower filters in the registry? This often solves problems with ODD.

Maybe you are looking for