How to upgrade a table column using the values in the Oracle collection

create or replace procedure test_coll

IS

CURSOR upd 
IS
SELECT CONTACT_NAME FROM Supplier_16;

TYPE dept IS TABLE OF upd%rowtype;
cur_var dept;

Type List Is table Of  varchar2(20);
Name List:=  List('Shilpi','Sunil','Shreyas','Saral');

BEGIN

OPEN upd;
LOOP
     FETCH upd BULK COLLECT INTO cur_var;
--    EXIT WHEN upd%NOTFOUND;

     FORALL i IN cur_var.FIRST..cur_var.LAST
  
     UPDATE supplier_16
**  SET Contact_name= name(i);  ***
     
     COMMIT;

END LOOP;
CLOSE upd;

END;
On the "BOLD" line, I don't know how I should move the values of the collection of name I said without which are set all the values in the table supplier_16 = 'Saral.

Help, please.

Aashish S. wrote:
Thank you very much...

Yes, I slide collections and was trying to reach somwthing on similar lines to which you provided the code example...

My essay is equipped to take a collection: initialized with values of say 3-4...

Take other tables... A column... and update the column in the table (not PK, FK anything) using the values of the initialized collection...

However, I am stuck between the two on how the UPDATE clause should be...

OK, if it's just because you want to practice with collections, you might do something like this...

SQL> set serverout on
SQL> create table supplier_16 as
  2  select 'Frederick' as contact_name from dual union all
  3  select 'Robert' from dual union all
  4  select 'Jeremy' from dual union all
  5  select 'Simon' from dual
  6  /

Table created.

SQL> create or replace procedure test_coll is
  2    CURSOR upd IS
  3      SELECT CONTACT_NAME
  4      FROM Supplier_16
  5      FOR UPDATE;
  6    Type List Is table Of  varchar2(20);
  7    Name List := List('Shilpi','Sunil','Shreyas','Saral');
  8    v_contact_name varchar2(30);
  9    v_idx          number := 1;
 10  BEGIN
 11    OPEN upd;
 12    LOOP
 13       FETCH upd INTO v_contact_name;
 14       EXIT WHEN upd%NOTFOUND;
 15       UPDATE supplier_16
 16       SET    contact_name = name(v_idx)
 17       WHERE CURRENT OF upd;
 18       DBMS_OUTPUT.PUT_LINE(v_contact_name||' update to '||name(v_idx));
 19       v_idx := v_idx + 1;
 20    END LOOP;
 21    CLOSE upd;
 22    COMMIT;
 23  END;
 24  /

Procedure created.

SQL> exec test_coll;
Frederick update to Shilpi
Robert update to Sunil
Jeremy update to Shreyas
Simon update to Saral

PL/SQL procedure successfully completed.

SQL> select * from supplier_16;

CONTACT_N
---------
Shilpi
Sunil
Shreyas
Saral

Of course, there is treatment rank by rank and is not best for performance, but it allows you to access your collection that you created names.

Tags: Database

Similar Questions

  • How to insert data into the table by using the expression builder in the assign activity

    How to insert data into the table by using the expression builder in affect business in BPEl, I use SOA Suite 11.1.1.5
    Can someone help me please

    Hello

    I don't think that oraext:query-database() can insert data into the table.

    What are your needs?
    Can not you plan to use the DB adapter with the insert operation?

    Kind regards
    Neeraj Sehgal

  • How to get the names of the table columns in the quick dashboard

    How to get the names of the table columns in the quick dashboard


    Thanks and greetings
    ------------------------
    Kishore P

    Make a prompt like:

    SELECT case when 1 = 0 then 'D0 time. " "" T02 by month name "other" 'D2 market' '. "" M04 region' ' the end 'Sample Sales' UNION ALL SELECT case when 1 = 0 then 'D0 Time. " "" T02 by month name ' else ' 'Time D0. "" T02 by month name ' ' the end 'Sample Sales.

    Put the name of column in single quotes.

    Make your rank as a function:
    Rank ('F1 income'. "" Recipes 1-01 (after all) "by @{pColumn} {'D0 time'. ({"" T05 annually name '})

    It works fine for me

    concerning

    John

    http://obiee101.blogspot.com

  • URG: How can I force APEX to use the specific schema: spaces of work APEX_040100 or entitled to another schema?

    Hi all

    Here's the scenario:

    1. My computer crashed. were to return to complete export (expdp 11.2.x to impdp 12 c). successfully done.
    2. Configured ADR blah blah... can access the admin of the apex.
    3. Problem is: administration interface does not SEE my workspaces apex Apex (only the workspace IN-HOUSE).
    4. After investigation it seems that APEX (after the upgrade) is somehow configured / run with: schema APEX_040200 and not

    APEX_040100 (as I have improved Apex in the old database versions).


    5. If I'm running the following:

    ALTER session set current_schema = APEX_040100;

    Select short_name, display_name

    of wwv_flow_companies

    where source_identifier is not null;


    I SEE all my beloved workspaces.

    6 my questions:

    a. How can I force APEX to use the specific schema: APEX_040100 instead of APEX_040200?

    b. or are there other alternatives to assign these workspaces in the current environment?


    Concerning

    Etay G

    Hello Brad,

    Thank you for your response. Appreciated.

    • Yet, as I had a little corrupted environment Apex after import (impdp), COMPREHENSIVE database this method of revocation (above) has failed several times to me.
    • Here's what I have (solves the problem):
    • Deleted APEX_040200 Apex 4.2 installation().
    • Text left in DB is the only APEX_040100
    • Then, the version 5.0.3 and it worked!

    More importantly, after the installation of APEX, all workspaces, users, etc. are automatically correctly resided in APEX.
    • I think that if you have only 1 version of apex corrupted in DB. It should work as well. Remove again, schema using the above script (check version) with caution (after backup, etc.).

    Kind regards

    Etay G

  • How can I get Mozilla to use the name of the page for the name of the real instead of the URL bookmark when I bookmark a page

    I just noticed that (in comparison to Internet Explorer): in IE, when you preferred a Web page, it uses the actual name of the Web page (for example, for this page, it would be "Ask a Question Firefox Help" as the name of the bookmark), but in Mozilla, it uses the URL as the name of the bookmark. I was wondering if it was possible to change my Mozilla settings so that it uses the name of the Web page as the bookmark name instead of the URL? I hope that everyone understands what I am getting? If anyone can help me, I would really appreciate it. Thank you.

    Firefox uses the tag title for the name of the newly saved bookmark.

    When I bookmark on this forum page I get this for the 'name' of the bookmark.

    How can I get Mozilla to use the name of the page for the name of the real instead of the URL bookmark when I bookmark a page | Firefox Support Forum | Firefox help

  • 4655 HP Office Jet: How can I fax multiple pages using the hp officejet 4500 desktop computer

    How can I fax multiple pages using the hp officejet 4500 desktop that you just bought

    can you please email me at [removed personal information]

  • My Apple ID has been locked for security reasons. I have all the details to recover my account that the account was created by a child of 6 years. How to unlock my account to use the same?

    My Apple ID has been locked for security reasons. I have all the details to recover my account that the account was created by a child of 6 years. How to unlock my account to use the same?

    < email published by host >

    It is illegal for a child from 6 years to create an Apple ID.

    You can take a date-genius bar with Apple and bring the original receipt Apple.

  • How can I turn OFF any possibility of use of private browsing OR - how to set a password to use the private browsing?

    How can I turn OFF any possibility of use of private browsing OR - how to set a password to use the private browsing?
    My children are free to use the internet - but I don't want them to be able to hide their internet activity to me.
    Thank you.

    Try this new extension - turn off private browsing:

    https://addons.Mozilla.org/en-us/Firefox/addon/disable-private-browsing/

    Ignore the review I did there on the 22nd, as both versions again, improving have been released during the 6 days and most of the articles I've written about have been fixed.

    Richie just needs to get to the function disable compensation no browsing history, who works at.

  • I'm unable to empty a jpg of the Trash because the element is used. How can I find what is using the element?

    I'm unable to empty a jpg of the Trash because the element is used. How can I find what is using the element?

    option of command, escape on the keyboard and then on the force quit button for all applications listed

    then empty the trash

  • How to rename a directory by using the command prompt

    How can I rename a directory using the command prompt?  Say I want to change c:\Users\User c:\users\user utilisateur\Mes Documents documents.  How can I do this?

    I looked in Google.  Here's what I found.

    G:\data>mkdir dir1
    G:\data>dir /b
    dir1
    G:\data>rename dir1 dir2
    G:\data>dir /b
    dir2
    G:\data>What would I write for the data? And what would I write for b?
    
    C:\docs>ren c:\docs\1.txt 2.txt
    C:\docs>dir /b
    2.txtPlease give me an example.Rod Computer
    

    OK, I fixed it.  I did go in safe mode, go to documents, right-click on the file, select Properties, security, advanced, owner and change the owner.  And that's all.

    They don't call me computer Rod for nothing!

    Thank you

  • Please how to create an e-commerce using the muse of adobe

    Please how to create an e-commerce using the muse of adobe

    ECWID is certainly the easiest to customize muse and it's very easy for customers to add/manage products. Another thing that many people love in Ecwid, it's that you can host several stores account. If you know css/javascript then you can do this on your own, but if you want a widget that does, make these widgets.

    If you are looking for some great Ecwid widgets, you can enter these ones that are free. And if you are wanting to customize even more (including the ability to host multiple account stores), you can get these even more impressive widgets for $14.99 with promo code: 1MUSESTORE #.

  • How can I add a link using the adobe reader software?

    How can I add a link using the adobe reader software?

    Hi johnny05,

    This isn't something you can do with Adobe Reader. To edit a PDF file, including adding a link, you must use Acrobat. We invite you to try Acrobat DC for 30 days; You can download a trial of this page: Download Adobe Acrobat free trial version | Acrobat Pro DC.

    Best,

    Sara

  • How to save a database to use the RMAN catalog using the OEM 11 g grid

    How to save a database to use the RMAN catalog using the OEM 11 g grid?

    ---------------------------------------------------------------------
    Enterprise Manager Version: 11.2.0.2

    See the availability tab, and then click 'Recovery catalog settings' under the Backup/Restore Configuration.

    Choose the option 'Use Recovery Catalog'. Click the 'Add Recovery Catalog' button to add the recovery catalog. And fill required fields like username, host, port, sid, etc..

    Talip Hakan Öztürk
    http://taliphakanozturken.WordPress.com/

  • How to start to use the Oracle client to access the database?

    People,

    Hello. I just installed Oracle Client (Instant Client) in the directory/home/myOracle/Oracle_Client.
    But I don't know how to start and configure the client to access Oracle database.

    Can all folk tell me how to start to use the Oracle client to access the database?

    user8860348 wrote:
    People,

    Hello. I've successfully used Oracle SQL Developer. But I want to know how to use the Instant Client.

    Can any folk tell me how to use the Client then just install it?

    I guess you're hurting understand the definition of Client instant, there isn't a tool or application or tool GUI as a sql developer or another that you can start using. It's just client installed with the minimum characteristics
    If you want to use the right application tool install sql developer in your instant client or simply running sqlplus

    See you soon

  • Hello, we have a company agreement and we are entittled to use the master collection package. Based on thi

    Hello

    We have business agreement and we are entittled to use the master collection package. Based on this, we want to upgrade Flash builder 4.7. Please let us know how can we do it and how to get the keys.

    -Med

    @Anamika018: please contact Adobe volume licensing representative technical support to access Fb 4.7 under a volume license business - they'll be able to give the right for the product.

Maybe you are looking for