Question of the insertion-selection

Hi all

I need help with this issue:

[code]

    with table2 as
(
    select 'N' col1,1 NR from dual union all
    select 'N',2 from dual union all
    select 'S',3   from dual union all
    select 'S',4  from dual union all
    select 'S',5 from dual union all
    select 'N',6  from dual union all
    select 'N',7  from dual union all
    select 'S',8  from dual
   )
   
        INSERT INTO table1 aa
        SELECT        
            CASE
            WHEN pl.col1 = 'N'   THEN '10'
            WHEN pl.col1 = 'S'   THEN
                             ............
                             .....
        FROM table2 PL 
        WHERE ....

[/ code]

Table 1 has a column

How can insert into table 1, the value

[code]

        insert '10' into first(1)  row of table1 when DML process first row of table2  AND has in col1=N
        insert '10' into second(2)  ......
       
             insert '11' into (3) row of table1 when DML process 3 row of table2 and has in col1=S (it should be 11 (10 inserted in previous row(max value in table1)  and sum + 1)
             insert '12' into (4) row of table1 when DML process 4 row of table2 and has in col1=S (it should be 12 (11 inserted in previous row and sum + 1)
             insert '13' into (5) row of table1 when DML process 5 row of table2 and has in col1=S (it should be 13 (12 inserted in previous row and sum + 1)
        insert '10' into (6) row of table2
        insert '10' into (7) row of table2
             insert '14' into (5) row of table1 when DML process 5 row of table2 and has in col1=S (it should be 14 (13 inserted in previous rows because max value in table1 is 13 and sum + 1)

[/ code]

It is my goal in table1:

[code]

1--> 10
2--> 10
3--> 11
4--> 12
5--> 13
6--> 10
7--> 10
8--> 14

[/ code]

Thanks in advance for any help

Hello

You can use the ROW_NUMBER analytic function to generate consecutive numbers.

Here's a way to do what you asked:

INSERT INTO table1 (num_1)

SELECT THE CHECK BOX

WHEN col1 = ' don't

THEN 10

ANOTHER 10 + ROW_NUMBER () OVER (PARTITION BY col1

ORDER BY NULL

)

END

FROM table2

;

Tags: Database

Similar Questions

  • A question about the insertion of the localTimeStamp returned the value into a timestamp with time zone column

    Hello

    Oracle version: Enterprise Edition Release 12.1.0.1.0 - 64 bit

    OS: CentOS 4.6 X86_64                  

    I have a question about the localTimeStamp function. According to the documentation for this function is
    the same thing as current_TimeStamp except that the returned value does not include the time zone.

    Consider the following example:

    SQL > create table tmptab (colval timestamp with time zone not null);

    Table created.

    SQL > insert into tmptab (colval) values (localTimeStamp);

    1 line of creation.

    SQL > select t1.colval, tmptab from t1;

    COLVAL

    ---------------------------------------------------------------------------

    24 JANUARY 14 09.45.42.253732 H + 01:00

    SQL >

    Why introduce the foregoing did not fail? the data type of the column in my table colval expects a timestamp with time zone

    during each which inserts as I understand (correct me if I'm wrong) is not provided by the localTimeStamp function.

    Could someone kindly tell me what I misunderstood?

    Thanks in advance,

    dariyoosh wrote:

    Hello

    Oracle version: Enterprise Edition Release 12.1.0.1.0 - 64 bit

    OS: CentOS 4.6 X86_64                  

    I have a question about the localTimeStamp function. According to the documentation for this function is
    the same thing as current_TimeStamp except that the returned value does not include the time zone.

    Consider the following example:

    SQL > create table tmptab (colval timestamp with time zone not null);

    Table created.

    SQL > insert into tmptab (colval) values (localTimeStamp);

    1 line of creation.

    SQL > select t1.colval, tmptab from t1;

    COLVAL

    ---------------------------------------------------------------------------

    24 JANUARY 14 09.45.42.253732 H + 01:00

    SQL >

    Why introduce the foregoing did not fail? the data type of the column in my table colval expects a timestamp with time zone

    during each which inserts as I understand (correct me if I'm wrong) is not provided by the localTimeStamp function.

    Could someone kindly tell me what I misunderstood?

    Thanks in advance,

    Then, when you do

    create table t (neck DATE);

    Insert into t (to_date ('1st January 2014', ' mon-dd-yyyy "");)

    Are you surprised that it works? After all a DATE column contains a time component, you do not provide: but he

    works and gives you 00:00:00 as the component "hour".

    Similarly, the timezone component is being developed to automatically with, I think, time zone of your system.

  • Newby question about the Quick Selection tool

    I have what I think must be a simple background to remove a portrait.  This photo was taken near a white wall and a flash shadow was precipitated on the left.  The quick selection tool has no problem of selection of wall area in a mask.  The problem is when you try to register the shadow of the hood.   He has no problem with the hair.  There is a color difference evident between the hood and its shadow and its quite a different gray in the red channel.  Is it possible to adjust the tool quick selection to recognize different color or gray?

    TIA.

    Open the document you want to move to the first.

    Then return to this document (as in the screenshot), right-click on the selected layer in layers, "Duplicate layer", select the document target destination, press OK. Your layer, so that the mask is moved to the new document.

  • Simple question of the DataGrid selection...

    I have a simple datagrid that is filled by a HTTPService...

    I want to return an Alert.show ("Please select point databagrid'"); If a user has NOT selected one of the items in the datagrid... Seems simple, but for some reason any one can understand...

    Any suggestions?

    If you look in the removeModule function, you access the mm.selecteditem.id property and the property of the system, THEN you check to see if it is null.  You need to put the control in front of the var null: string title... because they will error with an error "access to the property of a null object" that you said earlier.  As the written code will run never If(mm.selectedItem == null) code, because if mm.selectedItem is null, it would have already returned an error.

    Mark

  • Undo the insert does not properly - Popup

    Friends

    To speak frankly fed up with Oracle ADF (Newbie .net was much easier)

    I have a use case for the edition of Masters details... Details are displayed in the table... For detail edit and create operation I use popup with the Control Panel window.

    My problem.

    I used a managed bean and operation of 'Create' to add new lines of appeal. Works well, but when I cancel my code does not work, I still see a blank line in the table of means...


    I get the rwStatusfrom method AM to check the status of the line. Please see the code.


    If (NEW".equalsIgnoreCase (rwStatus)) {" "}


    RW. Refresh(Row.REFRESH_UNDO_CHANGES |) Row.REFRESH_REMOVE_NEW_ROWS);


    }
    on the other
    {
    RW. Refresh (Row.REFRESH_UNDO_CHANGES);

    }


    If I add dtIter.getViewObject () .clearCache (); the code above Houston line concurrency exception is thrown, but new line is deleted.

    I even regenerated my table... No use.



    At the beginning I used "CreateInsert" for the insert operation and it was much easier remove the line but the question during the insertion of the first record my validation was immediately called in the showPopup (before adding data) so I tried the "Create" operation.


    Advice me please. I'm in the third day with this problem. (Creation of Bothe and CreateInsert works perfectly well in a form (view) but only question in popup).

    Thank you

    Published by: KK_Ash on May 26, 2013 08:13

    Hello

    in fact + "to speak frankly fed up with Oracle ADF (Newbie .net was much easier)" + "

    is a very very very bad start for a question of aid - honestly. Its never a good idea to disrupt a forum before asking for their time to solve your problem. To delete the line of the display, you must remove the link layer and not in the morning (which should get updated automatically). Then in the dialog box change the logic to cancel it if you access the current row of the iterator

      BindingContext bctx = BindingContext.getCurrent();
      BindingContainer bindings = bctx.getCurrentBindingsEntry();
      DCIteratorBinding iter = (DCIteratorBinding ) bindings.get("iterator name");
      iter.getCurrentRow().remove();
    

    See for how to handle the OK/Cancel button in a dialog box: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/77-ok-cancel-support-in-dialog-351871.pdf

    (which is basically your use case)

    Frank

  • INSERT the SEQ WITH the question of the Select clause

    Hello
    I have Insert statement that I want to use seq with the select clause, but does not please help in this...

    Insert in aaa (rowname, rowid, rowadd)
    aa_seq.nextval, empaddress, and Select empname from emp;
    Please, do not help to accommodate seq in the insert statement.
    Insert into aaa(rid,rowname,rowadd)
    select aa_seq.nextval, empname,empaddress from emp;
    

    Do not use as ROWID column name.

  • Question related to the INSERT statement

    Imagine this scenario:

    -table_a has 5 000 000 records at time t1

    -table_b is empty at time t1

    -At time t1, I execute the following statement:
              insert into table_b
                select * from table_a;
        
    -L' insert statement ends in time t2

    -Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
    Thus, at time t2, table_a has 5 003 000 records.

    My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
    5 003 000 or somewhere between these two counts?

    I guess it will be 5,000,000 because that is the number when the insert statement
    has started to run.

    Any comment is appreciated.

    Syed Ullah says:
    Imagine this scenario:

    -table_a has 5 000 000 records at time t1

    -table_b is empty at time t1

    -At time t1, I execute the following statement:

    insert into table_b
    select * from table_a;
    

    -L' insert statement ends in time t2

    -Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
    Thus, at time t2, table_a has 5 003 000 records.

    My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
    5 003 000 or somewhere between these two counts?

    I guess it will be 5,000,000 because that is the number when the insert statement
    has started to run.

    Any comment is appreciated.

    At time t2, it is possible that the answer is 0. Once the insert operation finishes (can be any time after t1 in your example, possibly before t2, possibly after) and assuming you checked in the same session where you run the insert, you would see 5 000 000. In other sessions you would continue to see 0 up to what the session who made the done insert one COMMIT.

    http://docs.Oracle.com/CD/E11882_01/server.112/e25789/consist.htm#CNCPT121

    Is something that you should read. He described these concepts much better than what you'll probably find in a few posts on the forum.

  • Insert select on the same table: possible without side effects?

    I have a very large table T1 containing millions of records. I need to treat its lines and create a few new lines based on selection.

    Table T1 contains events and one of them, with the code 100, is created by the further development of other events inside the table.

    My code is as follows:

    insert /*+append */ into T1 (code,...) values (100, c1,c2,...)
    select c1,c2... from T1 where (code=20 or code=10) and <other conditions>...
    
    

    as you can see I'm extract T1 lines to insert again in T1 with a different code and I use the direct path in order to get good performance.

    My fear is: choose is made from the same table I risk data loss? In general it is a good practice? Or is it better to create another table?

    Hello

    No I don't think that there may be loss of data. But that may depend on the behavior of the application and your where clause.

    I will explain how it is treated, so you can see if it's ok:

    1. the table is locked because of the insert add, (as)

    2 lines are read by select and make compatible from the State that was at the beginning of the query - 1.

    3 rows are inserted at the end, after the high-water line

    4 columns for new lines are sorted to be merged in the index

    5. high watermark is adjusted - visible new lines and lock is released

    Note that 2. and 3. occur at the same time: rows are inserted all read.

    Note that anyone can choose in the table during the operation - they see the changes committed only - if the State 1.

    all other DML are waiting for the lock being released, and will see new ranks and then

    If you have things that prevent the direct-path insert, append the hint will be ignored. So, if you must rely on close to 1. then the best lock explicitly with table lock. But I don't think that you need.

    Kind regards

    Franck.

  • Stupid question CS6. How can I get rid of my experience after using the quick selection tool?

    Stupid question CS6. How can I get rid of my experience after using the quick selection tool?

    The best way would be to make sure that your layer is not a background layer: click the lock icon in this case. Then click the icon at the bottom of the layer panel layer mask. This will create a mask that you can refine and not be destructive.

  • I'm opening table row in a popup with the help of change. If I opened a line to edit, and then if I cancel the popup and if I open some row of the table, then instead of the newly selected line diff, previously selected line becomes open question. Help, p

    @Code is:-

    I have a panelCollection which is having an ADFTable (VO) and < f: toolbar > < coomandToolbarbutton > IE change by clicking on modify the selected line of the tbal adf becomes open in edit mode in a popup. Buttong ActionListner change creation popup

    {} public void handleEdit (ActionEvent actionEvent)
    Add the code in the event here...

    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1Iterator.currentRow}");
    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1.currentRow}");

    Tips RichPopup.PopupHints = new RichPopup.PopupHints ();

    this.getAddEditpopup () .show (hints);
    }

    Pupup has two buttons for Submit and cancel.
    Click on Cancel button on the popup, it id hide. The question is, suppose that the table is to have 4 lines so if I first select third row and click on change that becomes open editing on a popUp, but if I click on the Cancel button and their selection a few rows of table (Say first line), the previously selected (3rd row) rank only becomes open again in popup instead of the newly selected row.
    Cacel code

    {} public void handleCancelAwards (ActionEvent actionEvent)

    Add the code in the event here...

    ADFUtils.invokeEL ("#{bindings.") Rollback.Execute}");

    this.getAddEditpopup (.cancel ()); [I also tried with hide and seek but not worked]

    }

    Thanks in advance and thanks for your time

    It may be a problem with the combination of: immediate = true, rollback, and af:popup.

    You can try adding af:resetActionListener to the Cancel button.

    BTW, your managed bean is in the package that start with uppercase ("Bean"). (if you should refactor this to "beans" (for example))

    Dario

  • Best practical Question - update the query (see object) based on the drop-down list selection

    I have a question about the most efficient way to perform the following task:

    I create a page that contains several DVT components to display data based on specific requests.  Top of page I am hoping to have a drop down menu (selectOneChoice) that contains dates different and based on what the user selects (i.e. 2010, 2011, 2012, 2013, etc.), this will update the query in the view object of some (i.s. WHERE Date = '2011', or WHERE Date = 2013"), and then you view the appropriate data in the DVT.  What is the best way to do this - from a point of view bean managed / page, as well as the View object?  Advice/documentation would be appreciated.

    Thank you!

    When you drag the vo executeWithParams one another that will create links for operations such as 'executeWithParams2', 'executeWithParams3 '. On the method that you use to update a view by calling the executeWithParams operation, you call the other operations too.

    Timo

  • Hello! My question is, why so many photoshop is making selection when using the quick selection tool, before that it was unable to myself. Can someone tell me aolucion, please. Thank you!!

    Hello! My question is, why so many photoshop is making selection when using the quick selection tool, before that it was unable to myself. Can someone tell me aolucion, please. Thank you!!

    Hi Axe_Juan,

    Could you please let me know the version of Photoshop installed on your computer?

    Also you want to State as Photoshop not to do a quick selection?

    If so, then head over to the Photoshop preferences, then the performance tab and click on 'Big and flat', restart Photoshop and then use the selection tool.

    If something else, please let me know.

    Kind regards

    Tanuj

  • to refine my question. The Lasso tool does not work.  When I select the content aware lasso shrinks and nothing changes.  Help please.

    to refine my question. The Lasso tool does not work.  When I select the content aware lasso shrinks and nothing changes.  Help please.

    A simple reset will often be the case if a tool becomes awkward. Go to this link, then select the lasso tool:

    Difficulty of tool

  • Question 1: The button "Buy now" does not work when you select a plan. Question 2: Can not select "Monthly Plan" for a "unique App."

    Question 1: The button "Buy now" does not work when you select a plan.

    How to reproduce the problem:

    1. go in terms of pricing and membership creative cloud | Adobe Creative Cloud

    2. choose a plan, then click on 'buy now '.

    3. you go to a blank page instead of the next steps in the payment.

    Question 2: Can not select "Monthly Plan" for a "unique App."

    How to reproduce the problem:

    1. go into "https://creative.adobe.com/plans".

    2. under "Unique App", select a product and then try to select the "monthly Plan" in the second menu drop-down.

    3. for some reason, it isn't get selected and the price is replaced with the ellipsis (...). I expect the monthly price to appear.

    Please notify.

    Thank you.

    Contact adobe during the time pst support by clicking here and, when available, click on "still need help," http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • By selecting in the Insert Panel does not add the closing tag

    Hello

    I wish to emphasize the part of the text in the Document window and select an item in the Insert panel to frame part.

    However, when I select the section or paragraph, it only adds the opening, such as < h > and < p > without his counterpart of the fence.

    It of just a bug or am I skip a step? Please tell me how the closing tag can be implemented by using the Insert panel.

    Thank you in advance,

    EAD

    I can't my pCOC CARD on W7 2015 to do what you describe.

    What version of the program and which OS are you running?

    Your code is error free? Try to run the validator at http://validator.w3.org/nu for a list. Many features of DW depend on clean and valid code working properly, it is possible that a small mistake may be confusing program.

Maybe you are looking for

  • How can I transfer pictures on my Macbook Pro to a Flash drive

    I transferred my photos iPhone 5 c to my macbook Pro, but now I'm trying to transfer to my flash drive. I tried to find a way to transfer, but I can't find how. Please I need to find a way to transfer my phone is completely full on storage and I want

  • For loop runs with the value of N unwired

    In this case will be a loop run connected to the loop N worthless? I have seen a few examples of the loop for run without a certain number of times set to be ran wired or for example a size of table or something like that.

  • Media Player is not playing my videos from blackberry, why is this?

    I have downloaded on my "of WINDOWS XP" Flip Camcorder software and plays my videos without problems or errors; but not the same with my Blackberry software ' after I exported videos and photos of my touchscreen Blackberry 9860, he refuses to open an

  • Playmemories do not post video

    I recorded a short video (2 minutes and 44 seconds) yesterday. I used PlayMemories House to share publicly on Youtube. The video posted on Youtube was only the first 1 minute and 9 seconds of the video. I updated the software to the latest version an

  • UpdatingDell place 7-Android 4.4.4

    Currently my place 7 3730 (early 2014) is running Android 4.4.2 and is very unstable with applications and com.android.system stop frequently. It seems that I should update to 4.4.4 I've seen a lot of posts reflecting the instability of the 4.4.2 I k