Need to update the collection

Hi gurus

I'm stuck on a problem related to the collection.

I have the following structure.

Sample data

DROP TABLE dept2;
DROP TABLE dept2_dtl;
CREATE TABLE dept2
(DEPTNO NUMBER (2),)
DNAME VARCHAR2 (14).
LOC VARCHAR2 (13),
DEPT_ID NUMBER (5))
;
-------
CREATE TABLE dept2_dtl
(DEPTNO NUMBER (2),)
DNAME VARCHAR2 (14).
LOC VARCHAR2 (13),
DEPT_ID NUMBER (5))
;

CREATE SEQUENCE dept_seq
START WITH 1000
INCREMENT BY 1;

-----------

Code so far

DECLARE
TYPE t_dept IS TABLE OF dept2% rowtype;
v_dept t_dept;
cursor c1 is select deptno, dname, loc, null of the Department;
BEGIN
OPEN c1;
loop fetch c1 COLLECT LOOSE v_dept limit 1000;
exit WHEN v_dept.count = 0;
ForAll indx IN 1.v_dept.count
INSERT INTO dept2
(DEPTNO,
DNAME,
LOC           ,
DEPT_ID)
VALUES
(
v_dept (indx). DEPTNO,
v_dept (indx). DNAME,
v_dept (indx). LOC,
dept_seq.nextval
);
-This section contains an exception


BEGIN

ForAll indx IN 1.v_dept.count
INSERT INTO dept2_dtl
(DEPTNO,
DNAME,
LOC
-DEPT_ID
)
SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC
OF the double
where v_dept (indx). DEPTNO = 10;
End;
-Now, I want to add

end loop;
END;

The above code work fine, but I want to add dept2. DEPT_ID in table of details that are dept2_dtl but unable to reference it. I need to change a code in my second insert something like below:

SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC,

v_dept (indx). DEPT_ID

OF the double

where v_dept (indx). DEPTNO = 10;

but the problem is that I don't have DEPT_ID in my collection at this time, please advice. Thank you

I'm stuck on a problem related to the collection.

I see NOTHING in what you posted indicating that the collections or PL/SQL is even necessary.

The first part of what you are doing is just selecting data in DEPT and inserting into DEPT2 with a new value in the sequence.

Then you say you want to insert the same data into another table that you just inserted in the first table.

Why don't you just use SQL to query DEPT and do insertion in DEPT2?

Even if you were to use the collections and that the solution is pretty simple, don't you think?

This is the cursor you have defined:

cursor c1 is select deptno, dname, loc, null of the Department;

And that's what you say, what is the problem:

the problem is that I don't have DEPT_ID in my collection right now

So FIX THIS PROBLEM! is not the solution the more simple, just to add DEPT_ID to this collection?

Define your collection on the projection of CURSOR and add DEPT_SEQ. NEXTVAL in the cursor query.

Now you have DEPT_ID in the cursor AND in the collection, you can use the collection to INSERT in the two tables.

DECLARE

cursor c1 is select deptno, dname, loc dept_seq.nextval deptid of the Department;

TYPE t_dept IS TABLE c1% rowtype;

v_dept t_dept;

BEGIN

OPEN c1;

loop fetch c1 COLLECT LOOSE v_dept limit 1000;

exit WHEN v_dept.count = 0;

ForAll indx IN 1.v_dept.count

INSERT INTO dept2

(DEPTNO,

DNAME,

LOC           ,

DEPT_ID)

VALUES

(

v_dept (indx). DEPTNO,

v_dept (indx). DNAME,

v_dept (indx). LOC,

v_dept (indx). DEPTID

);

ForAll indx IN 1.v_dept.count

INSERT INTO dept2_dtl

(DEPTNO,

DNAME,

LOC           ,

DEPT_ID

)

SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC, v_dept (indx). DEPTID

OF the double

where v_dept (indx). DEPTNO = 10;

end loop;

END;

The big question is why you are using this TERRIBLE to begin implementation?

Tags: Database

Similar Questions

  • Satellite Pro A120: Need to update the BIOS after upgrade CPU

    Hello

    I have a Toshiba Satellite Pro A120 and I need to update the bios of a change in cpu cause.
    The laptop works very well, but for some reason any with the new processor fan runs always full.

    A lot, I searched but found nothing.
    The model number is PSAC1E-0QL04CG3 of ideas where I can find the bios?

    THX in advance,
    John

    Hello

    First of all: update BIOS doesn t help you.
    Why do you think that BIOS update should help reduce the activity of fan?

    I guess that your new processor is faster. Right?
    So it offers more performance and this leads to higher heat dissipation... so finally the CPU must be cooled and this can be done only if the cooling module would turn faster you agree with me?

    By the way: the update of the BIOS is on the page of the Toshiba UE driver. Since the satellite Pro A120 is very old series, you will need to search for drivers in area Archive (Type of product-> Archive)

  • Need to update the Bios on the Satellite 4060XCDT to install Linux

    I need to update the bios to be able to install ubuntu 7.10 - where can I get the latest version of the BIOS?
    Thank you

    This laptop is a bit old and there is no real new version of BIOS.

    Take a look on this site
    http://EU.computers.Toshiba-Europe.com/cgi-bin/ToshibaCSG/download_drivers_bios.jsp

    In the Archive you will find-> Satellite Archive-> Sate 40xx you notebook series and the BIOS.
    The most recent one was released the 16/05/02-> it s BIOS 8.20

  • We need to update the drivers... Where can I get these and free would be great

    We picked up a nice all-in-one Photosmart C7200 series and run Windows 7 x 64 we need to update the drivers where I can get these and without would be great, I looked on the web, but I find virus and pilot will post that costs $ 40 and then I can download the drivers (I assume) this printer is clean looking again , but I guess that it is older that Windows 7 any help would be very appreciated

    Hi woodbywallace

    http://h30639.www3.HP.com/pub/softlib/software11/COL30662/MP-76036-1/PS_AIO_02_Net_Full_Win_WW_130_140.exe

    311,96 M
  • Need to update the license key of TEO

    Hello

    Does anyone know how to get the TEO license key? Please give me the steps to do...

    I used the trial version of TEO in training which has been exceeded, now I can't access TEO because I need to update the license key.

    Please share information... thank you.

    Kind regards

    Floriana

    External customers must follow the procedures given to them by their account manager and pass by [email protected] / * / and use SWIFT codes to ask for the keys.

    If you are internal cisco, please send an e-mail to Clint Havard (please look for it in the directory) and send him an email asking for an extended license for TEO/CPO. Be sure to include the hostname of your server of TEO in the query.

  • Good afternoon! I had a problem with Adobe Muse to pay. I was transferred to the free subscription. In a letter to the mailbox said he indicated that the need to update the card payment in detail, but I can do, and the site gives a

    Good afternoon! I had a problem with Adobe Muse to pay. I was transferred to the free subscription. In a letter to the mailbox said he indicated that the need to update the card payment in detail, but I can do, and the site gives an error. Credit card remains the same.

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • I need to update the screenshots for a new version of an app existing Itune application to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    I need to update the screenshots for a new version of an existing iTunes Connect App asks me to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    You must call the assistance of the company and ask them to help you with this. You can find contact information by logging on http://digitalpublishing.acrobat.com/ and looking at the Middle at the bottom of the page.

    Neil

  • I can't update my CS5 because I loaded Yosemite on my iMac. you will need to update the files camera raw.

    I can't update my CS5 because I loaded Yosemite on my iMac.  You will need to update the raw files.

    Please try and reinstall CS5: stalling-yosemite-version-10-10-on-imac http://feedback.photoshop.com/photoshop_family/topics/problems-with-photoshop-cs5-after-in it seems that the update of the OS is corrupt PS CS5 if it was installed before the upgrade to Yosemite. Let me know if that will fix it for you.

    With the permission of Jeffrey Tranberry

  • OBIEE 11g Patch. We need to update the RPD?

    I have a question. There are a lot of articles to patch OBIEE 11 g to the latest version. A few articles describe only patching process and I forgot the important step. This step is the upgrade catalog after patched and we can found in the documentation. But I can't find any reference for the upgrade of the repository.
    I guess if the BI server files then changes it may be the structure for the RPD file changes. We need to update the client tools for corresponding to the current version. So I think that we need to upgrade the repository file.
    Does anyone know how to do?
    Maybe patch process in automatic mode?

    When you apply a patch, it used upgrate the RPD.

    The upgrade of the RPD to ex: 11.1.1.5 to 11.1.1.6.2 is very simple open the RPD 11.1.1.5 using 11.1.1.6.2 Admin tool Client and save with Save as option, it does it automatically.

    Thank you
    Saleem.

  • need to update the first, but it stops and has to close CEPHtmlEngine... what?

    I need to update the first on the creative cloud but it stops and 62% and needs to close "CEPHtmlEngine" to continue. What is this and how do I close/change app?

    Jason2494 you want to use the Activity Monitor/Task Manager to close the adversarial process.  What operating system do you use?  You can also try restarting your computer and then try to apply the update again.

  • If I get a new laptop I need to update the subscription of the CC?

    Hello

    I recently got CC of Adobe Photoshop and Lightroom 5 and they are wonderful and now I don't always have to use the programs at the school.

    But my laptop is old and starts to slow down and it works fine but I know finally that he won't be able to manage the CC from Adobe.

    If I buy a new computer, I'll be able to download Adobe CC without any problem or I have to update my subscription? If I only uninstall programs adobe on the old laptop and then reinstall everything to the new, so no question. I don't know if I you need to update the news or not, if I get a new computer/laptop and download programs Adobe CC to the new.

    If I buy a new computer, I'll be able to download Adobe CC without any problem or I have to update my subscription? If I only uninstall programs adobe on the old laptop and then reinstall everything to the new, so no question.

    There is nothing to update.

    On the old laptop, open any CC application, click Help > Sign Out and then all will be disabled. Freeing an activation to use elsewhere.

    On the new computer, install CC as usual and they will activate automatically as part of the installation.

  • need to update the date of the end of the user using the API of the IOM

    We have a requirement where we need to update the date of the end of the user. The details of the user as usr_key, number of days to extend (such as 30 days or 60 days), and affects manager is provided by SOA (maybe by BPEL). In the java class, I need to add the number of days of the closing date of the user and then update the table of the usr by IOM API method - usrMap.put ("USR_END_DATE", updatedEndDate);

    I wrote a small program, but it has erros. Please help me in this situation.
    ' public boolean updateEnddate (String usrKey, String managerKey, String NombreJours) {}
    Boolean result = false;
    String NombreJours;
    int totalNumUsers = 0;
    HashMap usrMap = new HashMap();
    usrMap.put ("Users.Key", usrKey);
    usrMap.put ("USR_MANAGER_KEY", managerKey);
    try {}
    DateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd");
    Date date = sdfSource.parse("USR_END_DATE");
    SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MMM-yyyy");
    String userEndDate = sdfDestination.format (date);
    tcResultSet = this.usrIntf.findUsers (usrMap) users;
    totalNumUsers = usersList.getRowCount ();
    If (totalNumUsers > 0)
    for (int i = 0; i < totalNumUsers; i ++) {}
    usersList.goToRow (i);
    updatedEndDate = userEndDate + NombreJours;
    usrMap.put ("USR_END_DATE", updatedEndDate);
    this.usrIntf.updateUser (users, usrMap);
    result = true;
    }
    on the other
    result = true;
    }




    Thank you
    Kalpana.

    Calculate the new date

    /**
    * This method is used to obtain the new date after adding x-days
    @param strDate - date today
    @param daysToAdd - x-days
    * @return Nouvelle_date - date after the addition of x days
    */
    private String incrementDate (Date strDate, int daysToAdd) {}
    Start date
    Logger.info("NotifyLastDayOfService::incrementDate(): entrez»);
    SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-DD 00:00:00");
    Dim str As String = sdf.format (strDate);
    Calendar c = Calendar.GetInstance ();
    try {}
    c.setTime (sdf.parse (str));
    } catch (ParseException exception) e {}
    e.printStackTrace ();
    }
    c.Add (Calendar.DATE, daysToAdd); number of days to add
    String PROMOTIONDate = sdf.format (c.getTime ());
    System.out.println ("calculated End Date:" + PROMOTIONDate);
    Logger.info("NotifyLastDayOfService::incrementDate(): sortie»);
    return Nouvelle_date;
    }

    This should solve your problem :)

  • How to capture the paging and sorting of events to update the collection?

    I use a manual tabular form based on the collection. If I add/edit the data in the form and click next/previous page, all the changes are gone. The same thing happens when I sort the data by clicking on the column header.

    Apparently, I need to call APEX_COLLECTION. MERGE_MEMBERS the new or changed data in the collection. However, I could not imagine how to do it. One way would be to set up the javascript function called $a_report and precede wit a call to my js function that would proceed to an update of the collection. But how?

    Maybe there's a better way?

    Igor

    Igor,

    You will need to spend to use rendering partial Page to full page on this report. In the 4.0 version we should get more management control in the RRP, but to what extent is it still unknown events.

    Kind regards
    Dan

    http://danielmcghan.us
    http://sourceforge.NET/projects/tapigen
    http://sourceforge.NET/projects/plrecur

  • lost the external monitor feature: NVIDIA GeForce GT 330 M video card needs to update the driver in El Capitan?

    Hello
    Apparently Apple no longer supports the NVIDIA GeForce GT 330 M 256 MB and did not update the driver in the operating system to account for its recent update Linux (below)? What is a macbook pro user to do? I know my MBPro is now 5 years - but with an i5 and 8 GB of RAM I think I shouldn't need to take immediately for new?
    Running any video seems to disrupt communication between my Vizio E240AR and MBPro - El Capitan OS (with NVIDIA GeForce GT 330 M 256 MB).  Power cycling the monitor and then force the MBP via a modification of the resolutions seems to temporarily improve the issue - until I have run video or insist on graphics card memory.

    Model name: MacBook Pro

    Model identifier: MacBookPro6, 2

    Processor name: Intel Core i5

    Processor speed: 2.53 GHz

    Number of processors: 1

    Total number of cores: 2

    (By heart) L2 Cache: 256 KB

    L3 Cache: 3 MB

    Memory: 8 GB

    Processor speed of interconnection: 4.8 GT/s

    Boot ROM version: MBP61.0057.B11

    Version of the SCM (System): 1.58f17

  • Need to update the display driver for Equium L20

    Hi all

    Just upgraded to Windows 7 on my Equium L20, I need to update my video card driver but can't find where do.

    Any help would be greatly appreciated.

    Thank you

    Ryan

    Hi Ryan

    Your satellite is supported for Win7?
    As I can see on the Toshiba support page this old notebook is not supported for Win7.

Maybe you are looking for

  • acquisition of voltage compactRIO 9025

    Hello world I just got a new compactRIO 9014, I plugged a tension to the channel 0 of the series C 9205 with differential input card (pin 1 + and pin 20-). I get the ok on the front panel voltage, but if I drag the other channels on the same module i

  • DSC-Modbus IO Server

    My application processes reading registers a target of Modbus RTU (serial) then for the same iv set up a Modbus IO server which is available at DSC8.6. Lettering communicates well in the meantime real target & LabVIEW PC development but doesnot work

  • lost my video card when I downloaded windows 7

    When I downloaded windows 7 32 bit I lost my video driver and I searched my computer for him, but he disappeared

  • Printer HP4500: what do you do first, then second place, then third, etc.

    I'm lost in the installation of new HP4500 printer.  W/photos document shows how to get power to it, and that's all.  I don't have a CD, then receive information through their web sites.  I don't want to call wireless controls!  Once the current is p

  • Instruction in() allowed in triggers or DAL?

    Hi, new to all Documaker and working on certain triggers (custom rule settings). Everything that exists is using AND/OR to process multiple results then I wonder if IN() statement is allowed? Found zero issues on this by searching around.Example:I ha