Insert a line containing the same data but repeated for each foreign key availabl

So I use Jdeveloper11g.

I have a question where I have 2 tables, shops and rooms. Rooms now has a foreign key StoreId, which corresponds to the primary ID of stores and they are connected in a relationship 1 to many. Now I have over 600 stores. And only 2 have all the pieces that were (the building which is not even a main store in most of the rooms). The rest are not, but what I need is to assign to each store with the same name room1 1 room.

So the name would be the same, the primary key could get it I hope some sequences, but the foreign key ID, that StoreID field would have to change and insert for each store.

Is there a way to query sql for this type? Any means which is not manually create a 1 room, then assign to 1 store and repeating the process 600 times?

Thanks in advance

Hello

It looks like you want

INSERT INTO rooms (roomid, roomname, storeid)
SELECT  roomidseq.NEXTVAL
,     'room1'
,     storeid
FROM     stores
;

I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
In the case of a DML (such as INSERT) operation the sample data should show what look like the paintings before the DML, and results will be the content of the or a modified tables after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • Copy a few lines in the same table, but with different IDS

    Hi all
    I had this problem... I have a table with its pk (which is a sequence). With a statement select, I extract a few lines, and then I would record in the same table, but with IDS different (obviously eheheh).

    I don't know how to do...

    Thks for all help ;)


    p.s. I want to change some fields in lines before saving as well... don't know how do it more...

    example:

    ID NAME TYPE
    1 ferrari car
    2 cars lamborghini


    I'm trying to copy the second and changing its type in "BMW".

    I could result:

    1 ferrari car
    2 cars lamborghini
    3 bmw cars



    Thank you

    Assuming that your table is named cars_tb and the cars_seq of the sequence.

     insert into cars_tb
      select cars_seq.nextval, name, type
      from cars_tb
    

    This would overlap with any existing lines, but with a new id.

    If you want to duplicate a specific line and change a value, you could do something like:

     insert into cars_tb
      select cars_seq.nextval, name, 'BMW'
      from cars_tb
      where type = 'lamborghini'
    

    or better, use the PK

     insert into cars_tb
      select cars_seq.nextval, name, 'BMW'
      from cars_tb
      where id = 2
    
  • Can't understand why this query returns multiple lines with the same data

    Hi all
    I am a relative novice and self-taught when it comes to SQL. I wrote a query to our reporting tool that returns multiple rows, and I can't understand why. I know that I can use the SELECT DISTINCT option, but it really slows the execution when I do. I'd really rather understand if I can change the code to avoid the multiples. This is the query. I've included a few statements in italics to help explain the break. Any ideas?

    SELECT MATSITE, MATPONUM, FIRSTRECPTDATE
    Of
    Subquery that concludes the first date on which purchase orders have been implemented with ACK State
    (SELECT ACKSTAT. PONUM AS 'ACKPONUM', (MIN (ACKSTAT. CHANGEDATE)) AS 'FIRSTACKDATE '.
    OF PZMAX. POSTATUS ACKSTAT
    WHERE (ACKSTAT. STATE = 'ACK') AND (ACKSTAT.ORGID ='CGSALTUS)
    GROUP OF ACKSTAT. PONUM),
    Subquery that concludes the first reception against a purchase order transaction for purposes of comparison
    (SELECT TRANS. PONUM AS "MATPONUM", TRANS. SITEID AS 'MATSITE', (MIN (TRANS. TRANSDATE)) AS 'FIRSTRECPTDATE '.
    OF PZMAX. MATRECTRANS TRANS
    WHERE (TRANS.ORGID ='CGSALTUS) AND (TRANS. HOUR > =: startDate and TRANS. TRANSDATE < =: endDate)
    TRANS GROUP. SITEID, TRANS. PONUM)
    WHERE
    (ACKPONUM = MATPONUM AND FIRSTRECPTDATE < FIRSTACKDATE) OR (NOT EXISTS (SELECT 1 FROM PZMAX. POSTATUS ACKSTAT2 WHERE (ACKSTAT2. PONUM = MATPONUM) AND (ACKSTAT2. STATE = 'ACK') AND (ACKSTAT2.ORGID ='CGSALTUS)))

    The where the instruction is intended to find when one of two conditions exists. ((1) received happened before the command either in ACK or 2) a reception that's happened, but the purchase order is never in ACK State. It seems that this second condition that creates multiple lines.

    Any thoughts will be appreciated geratly.

    Dave Teece
  • How to create a formula that highlights the cell that contains the same data that I type in another cell

    Hi, can someone help me make a formula which detects and highlights the value of the cell that contains the items of data that I entered in another cell? Thank you

    resolved to myself

  • How to copy settings on a development folder and copy it to another folder containing the same photos

    Hello forum!

    I kinda made a mistake. I hope someone can answer me this.

    I have a folder under "Records" in the library. In this folder, I have 62 photos, which are also edited in lightroom.
    A mistake that happened and I've added a new folder containing the same images, but there is more than 200 pictures in this folder.
    Is it possible to copy my photos modified in my catalog to the new folder?

    I hope that the question was not confusing.

    Thank you!

    If you have two folders, which contains identical images, then you have the duplicate hard disk files.

    In this case, you will not be able to move the images published in the largest file because the file on any computer system will not allow that.

    Copy of the parameters is not the answer because that can be done individually (assuming that all the files have not the same settings)

    Identify files duplicate in the large folder and delete them from your hard drive. You can do this in Lightroom by pressing the DELETE key and choosing the option remove the disc (not delete)

    Select all 62 images in the grid, and then drag them to the folder you want to move them. Lightroom invite you you move them on the hard drive also. Ok.

    Let us know if this helps

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • Don't know what happened, but now, everytime I open a new tab, a new window opens that contains the same information as the tab.

    Don't know what I did, but now, everytime I open a tab, the tab opens as it should, but it ALSO opens a new window containing the same information as my original window. (same tabs, etc.) Almost a duplicate of my original window. I searched everywhere for a solution, but fails.

    Hello

    The reset Firefox feature can solve many problems by restoring Firefox to its factory default condition everything and save your essential information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

    Thank you.

  • accidentally create data file with the same name but different location

    Hi all

    I was accidentally create data file in the tablespace with the same name but in another location.

    / U03/DataFile/REKON65. DBF

    new data file: / u04/datafile/REKON65. DBF

    My question: what happens with data/u03/datafile/REKON65 file. DBF? the data inside/u03/datafile/REKON65. DBF went?


    Thank you

    Indra says:
    Hi all

    I was accidentally create data file in the tablespace with the same name but in another location.

    / U03/DataFile/REKON65. DBF

    new data file: / u04/datafile/REKON65. DBF

    My question: what happens with data/u03/datafile/REKON65 file. DBF?

    nothing

    the data inside/u03/datafile/REKON65. DBF went?

    not gone

  • Columns with the same name but different data or precision length.

    DB version: 10 gr 2

    In a diagram, I need to find all of the columns with the same name but different or precision data length (if the column is of type number). I know I have to use the USER_TAB_COLS view for this. But I need to find a logic to compare the names of columns and its lengths.

    something like

    select t1.table_name
         , t1.column_name
         , t1.data_type
         , t1.data_length
         , t2.table_name
         , t2.column_name
         , t2.data_type
         , t2.data_length
      from user_tab_columns t1
         , user_tab_columns t2
     where t1.table_name != t2.table_name
       and t1.column_name = t2.column_name
       and t1.data_type = t2.data_type
       and t1.data_length != t2.data_length
    

    ... could be a starting point.

  • I have created a complete either form, with fields to interrogate.  When a test the form and enter the date in a field - it automatically inserts the SAME date in all other areas. How do fix you this?

    I created a form to fill in professional, with several fields.  When I try the form and enter data in a field - it fills the SAME data in all other fields.

    Give a unique name to each field.

  • Can roads be part of the same group, but there are other paths inserted between them?

    CS4 on Mac. I would like to know something about the relationship between the Group and the organization. For example, these three boxes:

    Screen Shot 2015-01-03 at 1.33.57 PM.png

    Is it possible to make the part two blue boxes of the same group, but while maintaining this order? If I try the command to base group, the big box in the background moves above the yellow area.

    Mary,

    You cannot use a group for it, but you can use a selection: select the objects (the two blue boxes or whatever, even through layers), then select > Save selection and give it a name. Then, you can select the selection at the bottom of the Select drop-down list (you can have several other different).

  • After the migration of ESXi 4.1 to 5.0 Update 1, ESXi containing the missing data store

    I intend to upgrade to an ESXi 4.1 production host, but I want to run through an upgrade of test on a separate machine. I created this using a virtual machine and the upgrade went well. However, now when I insert my vSphere client, I don't see the data store that contains data to my VM.

    Before migrating to 5, I had 2 drives, a disk of 4 GB for ESXi, and a 40 GB drive for the data of the VM installation. I could see and access times stores via the 4.1 vSphere client, but once the upgrade only the VM data store is available. Is there a reason that this is the case?

    I've updated but has not changed the partitions of data store. I have selected to migrate and keep the VMFS store, which was VMFS-3. I also tried to add the store drive 4 GB with the customer data, but an error message: "the selected disk already has a vmfs data store or the host cannot perform a conversion of partition table.
    Select another disk.

    I found this article on error message: http://KB.VMware.com/kb/2000454 , but I never actually removed from the data store. With the help of the 5.0 ESXi update I can see the VMFS store on 4 GB drive, which should have about 3.2 GB of available disk space (the rest being used by the hypervisor).

    Recommended someone else try esxconfig-volume - the list, and then use the output to a mount (http://communities.vmware.com/message/1666168#1666168), but the list command had no output at all.

    I searched through the forums and Google but you saw nothing.

    ESXi 5 has a different architecture, and I think that the problem is the size of the disk (too small) and the partition of scratch required.

    Have a look here:

    HTH

    Sam

  • Click on search for result code doesn't display the line containing the search results

    I use the latest version of DreamweaverCC2014 on the latest version of Mac Mavericks. I use Dreamweavers find and replace to find code in an open html document. In the search results Panel results aren't clicking on me at the relevent code line in the document. It used to work well in the previous version of DW, I was using.

    In the DW help note it is said: ' display the results of a particular search in context: select window > results to display the search panel. " Double-click on a line in the search panel. If you are looking for the current file, the Document window displays the line containing that search result. ' http://helpx.adobe.com/Dreamweaver/using/Text.html#search_for_and_replace_text

    Double-click does not display the line containing the result of the search for me. It seems to work OK in my CSS files, but not in HTML longer (1010 lines).

    Any advice? Someone at - it the same problem? Thank you

    I have the same problem with all the HTML files that have external style sheets. for example .

    So it seems to be a bug around that. When you delete the above, double click functionality works.

  • AS3/Fx3, if no 'save' between several lines added, all the lines contain the last modified value.

    Hi all

    I'm a sucker for creating problems. I'm working on adding role and content to a client website management. Currently, I have problems with the management of the role page.

    It is a legacy application and the customer is unwilling to upgrade to Coldfusion 8 and Flex Builder 3 Professional, so 'use the new stuff' is not enough for a response. No, I did not select the colors and I don't have the power to change their .

    It is a populous example:

    roleMgmt.png

    Here's the situation:

    1. The management of roles (mxml) page receives its data from a pair of files xml, siteManagement.xml, and roleManagement.xml through cffile calls via a cfc
    2. The xml data is stored locally in vars XML until the clerk.
    3. If I click once on the button 'Add', change the 'Save Changes' and fields immediately (the changes to the file through cfc is validated), everything works as expected, except that resets the combobox of roles. This normally isn't a problem - it is often exactly the behavior you want, but I can't stop reset.
    4. If I click on "Add control" more than once between save changes, changin any field on a new line causes all other lines have the same value for the same domain. (problem 2)
      1. This behavior can be fixed by saving and reloading the xml data between each click on 'add a control '. the problem with this solution is that it clears the Combobox of roles, adding unnecessary clicks to add (sometimes several) controls for the datagrid control.

    Controls are added by adding a new child element var XML:

    private function btnAddControl_click (): void

    {

    var tempXML:XML = new XML;

    tempXML = controlXMLTemplate;

    If (ensureFileExistsForRole ())

    {

    rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.appendChild (tempXML);

    }

    on the other

    {

    Alert.Show ("something does not work...", "Error Control adding :");)

    }

    dgcControlLabel.editable = true;

    dgcControlID.editable = true;

    dgcControlType.editable = true

    updateControls();

    supposed selects new line - this isn't

    dgControls.selectedIndex = rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.control.length ();        xmlDisplay.text = rolesXML;

    saveRoles();

    where controlXMLTemplate is:

    < control controlID = "Control ID' controlLabel ="Label control"controlType ="type"editable ="false"visible ="false"/ >

    and is added to the filename element:

    < canAccess filename = "true" fileName = "" friendlyName = "" > "

    < controls >

    < / controls >

    < / name of the file >

    I don't know what is causing the problem with the datagrid control where a line edit causes changes in others. My first thought was that it is caused by all the changes and selections via xml calls for example;

    dgControls.dataProvider = rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.control;

    So I added the code to add a number to the values that feed the datafields hoping that have unique data would cure the problem. There can be no.

    It's the function/code that causes the role Combobox to reset but prevents the datagrid problem:

    private function loadSiteInfo (): void

    {

    cursorManager.setBusyCursor ();

    roleManager.RO.loadSiteData.addEventListener (ResultEvent.RESULT, loadSiteData_resultsHandler);

    roleManager.RO.loadSiteData ();

    }

    private void loadRoles_resultsHandler(re:ResultEvent):void

    {

    cursorManager.removeBusyCursor ();

    roleManager.RO.loadRoles.removeEventListener (ResultEvent.RESULT, loadRoles_resultsHandler);

    rolesXML = re.result in XML format;

    }

    I don't know how much information you need to help. I can post the code if necessary, but I have to be careful - it's something health.

    This line is suspect:

    tempXML = controlXMLTemplate;

    This means that you may re-use of the same instance for multiple lines.  Probably, you need to copy the template rather than just use it.

  • Adding code to each line at the same time?

    Is it possible to do this? Instead of having to select 400 separate lines and put the list around them item code, is it possible to make it to each line individual all at once? I really hope that nothing. I'm sitting here thinking, "there must be an easier way." Please, tell me there!

    Thank you!
    -Alyse

    Is the problem that you have plain text of 400 lines, and you are wanting
    to wrap

  • Tags around each line automatically? If so, try to stick a
    copy all the text in a separate empty file, then go in Edition > search
    and replace.

    Just a heads-up - I'm on a Mac, so if you're on a Windows computer, the
    keyboard shortcuts may vary a little.

    For the search field, enter the character of CR - on my Mac, I have to
    Hold down the command (probably the control in Windows) key while hitting
    Check back for it leaves the input field. That should put a line break
    in the search field.

    For the replacement field, enter this:

  • ... and then, place the cursor between 2 tags and it shift-return (or
    -have to insert a line break).

    If you run find/replace, should replace all line breaks, so
    you will need too just add the opening:



    • .. .and closing...

    There may be a better GUI or regex how to do in DW, but how is it
    I know what to do (if it is still what you ask).

    CuteAlyse wrote:
    > Is it possible to do this? Instead of having to select 400 separate lines and
    > put around them, list item code is possible to do in each
    > single-line at the same time? I really hope that nothing. I'm sitting here to make
    > this, thinking, "there must be an easier way." Please, tell me there!
    >
    > Thank you!
    > - Alyse
    >

Maybe you are looking for

  • HP Officejet 6500 a more impossible to connect to the server

    My HP Officejet 6500 a more printer was connected to my wireless network and was attached to the ePrint service; and I had an email address to send prints to my printer. But today, when I go to the ePrint, it shows that my printer is NOT connected to

  • Pavilion dv7-4080us: reminder of hp power cable

    In announcement regarding August 26, 2014 of a recall program on the cords power supply for HP Laptops: August 7, 2014, my PC Pavilion dv7 stopped working and I took it to Best Buy, where the problem resulted in a bad cord.  I bought a spare for $58,

  • printer Officejet 4630: keybord on printer

    I've just set up the new printer when I get to the IP address, I can't get the keybord to print a 9 I see the 9 on the second line, but when I push the key it gives me just w, x, y and z and will not go to the line with 9 in who am I'm doing wrong

  • LabVIEW 7.1 gives error when loading files

    Hi all I get missing VI error when I opened a file .vi .it charge about 480 sub translation problem - VI I face is that by loading of the Subvi will lack & when I opened this particular sub - VI, then the error message goes away.this is not specific

  • I chose "keep files" before deleting a user profile but nothing appears in the saved folder?

    When I deleted a user profile, I chose to "keep files" and a folder has been created and saved to the desktop on the Administrator profile.  However, when I opened this case nothing appears?  The properties of this reflex folder with precision the si