Can we Improve the code Further

Hi All i 've the following code.
Can we improve the code further PROBABLY BY USING FORALL OR VARRAYS?
(MY ORACLE VERSION IS 10.2).
Thanks in Advance
CREATE OR REPLACE PROCEDURE PR_INS_TEM_EMP(M_USER_DEFINED_VALUE NUMBER,
P_ESAL NUMBER,
P_EDEPTNO NUMBER,
P_USER_ID VARCHAR2) IS
CURSOR C1 IS
SELECT ENO,ENAME FROM EMP WHERE ROWNUM <= M_USER_DEFINED_VALUE;
TYPE T_EMP IS TABLE OF C1%TYPE;
M_T_EMP T_EMP;
BEGIN
IF C1%ISOPEN THEN
CLOSE C1;
END IF;
OPEN C1;
FETCH C1 BULK COLLECT INTO M_T_EMP;
CLOSE C1;
FOR I IN 1..M_T_EMP.LAST LOOP
INSERT INTO TEMP_EMP(ENO,
ENAME,
ESAL,
EDEPT_NO,
USER_ID
(M_T_EMP(I).ENO,
M_T_EMP(I).ENAME,
P_ESAL,
P_EDEPTNO,
P_USER_ID
END LOOP;
END;

Hello, why use a cursor at all, why not:
CREATE OR REPLACE PROCEDURE PR_INS_TEM_EMP(M_USER_DEFINED_VALUE NUMBER) IS
BEGIN
  INSERT /*+ APPEND */ INTO TEMP_EMP(ENO,ENAME,ESAL,EDEPT_NO,USER_ID)
  SELECT ENO,ENAME
    FROM EMP
WHERE ROWNUM <= M_USER_DEFINED_VALUE;
END;And you are declaring but never using P_ESAL NUMBER,P_EDEPTNO NUMBER & P_USER_ID VARCHAR2. So why have them?
By the way, putting {noformat}{noformat} before and after your code will help the readability no end.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Can we improve the query further

    In Oracle 10g on Windows, can the following query be improved:
    update A
    set ( col3,col4 ) =
              ( select col3, col4
    from B
    where A.col1=B.col1
    and A.col2=b.col2
    where exists
         ( select 1
         from B
         where A.col1=B.col1
         and A.col2=b.col2
    The above query taken more than 2 hours to update table A from table B.
    Table A contains about 800 million records
    Table B contains about 1 million records

    I have just mailed the sample query,
    Following is the acutal query ( Currenlty both tables CsgSec and CsgSec_changes_pk are empty ):
    Query_
    update CsgSec
    set
    (GVKEY,
    IID,
    CUSIP,
    DLDTEI,
    DLRSNI,
    DSCI,
    EPF,
    EXCHG,
    EXCNTRY,
    IBTIC,
    ISIN,
    SECSTAT,
    SEDOL,
    TIC,
    TPCI,
    SECID,
    NAME) = ( select GVKEY,
    IID,
    CUSIP,
    DLDTEI,
    DLRSNI,
    DSCI,
    EPF,
    EXCHG,
    EXCNTRY,
    IBTIC,
    ISIN,
    SECSTAT,
    SEDOL,
    TIC,
    TPCI,
    SECID,
    NAME from CsgSec_changes_pk
    where CsgSec_changes_pk.UpdateFlag_ = 'X'
    and CsgSec.GVKEY = CsgSec_changes_pk.GVKEY
    and CsgSec.IID = CsgSec_changes_pk.IID)
    where exists
    ( select 1
    from CsgSec_changes_pk
    where CsgSec_changes_pk.UpdateFlag_ = 'X'
    and CsgSec.GVKEY = CsgSec_changes_pk.GVKEY
    and CsgSec.IID = CsgSec_changes_pk.IID
    Version_
    The version of the database is 10.2.0.2.0
    Optimizer Parameters_
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.2
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    Explain Plan_
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | UPDATE STATEMENT | | 1 | 279 | 1 (100)| 00:00:01 |
    | 1 | UPDATE | CSGSEC | | | | |
    | 2 | MERGE JOIN SEMI | | 1 | 279 | 1 (100)| 00:00:01 |
    | 3 | INDEX FULL SCAN | PKEY_IDX_CSGSEC | 1 | 259 | 0 (0)| 00:00:01 |
    |* 4 | SORT UNIQUE | | 1 | 20 | 1 (100)| 00:00:01 |
    |* 5 | INDEX RANGE SCAN | PKEY_CSGSEC_CHANGES | 1 | 20 | 0 (0)| 00:00:01 |
    | 6 | TABLE ACCESS BY INDEX ROWID| CSGSEC_CHANGES_PK | 1 | 262 | 0 (0)| 00:00:01 |
    |* 7 | INDEX UNIQUE SCAN | PKEY_CSGSEC_CHANGES | 1 | | 0 (0)| 00:00:01 |
    Edited by: Moazzam on Jun 1, 2009 3:30 PM

  • How can i improve this code ?

    DATA: t_bkpf TYPE bkpf.
    DATA: t_bseg type bseg_t.
    DATA: wa_bseg like line of t_bseg.
    select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.
    select single * from bseg into wa_bseg where belnr = t_bkpf-belnr.
    append wa_bseg to t_bseg.
    endselect.
    loop at t_bseg into wa_bseg.
      at new belnr.
         if wa_bseg-koart EQ 'K'.
            // pick vendor wrbtr
         else
           // pick other line item's wrbtr
         endif.
      endat.
    endloop.
    i am guessing my select statements arnt efficient performance wise, secondly in the loop when i use  'at new belnr' it aint showing my any values  whereas i get all the vendors(KOART EQ 'K') when i dont use 'at new belnr' .
    why is this so and how can i make the code efficient ?
    Thanks..
    Shehryar

    Hi,
    1.Dont read all the fields from the table unless it is required in your program.
    This will tremendously improve your performance.
    2.Make use of the key fields of the table wherever possible
    In your scenario you could use the fields BUKRS,BELNR,GJAHR of the table BKPF in the WHERE Clause rather than
    other fields.This will improve your performance a lot..
    3.As BSEG is a cluster table it will cause performance problem in most cases.So try to read
    the required fields from it rather than reading all the fields.Again Make use of the key fields in the WHERE Clause
    here too to improve the performance..
    4.Remove SELECT..ENDSELECT and replace it with FOR ALL ENTRIES to improve the performance.
    Cheers,
    Abdul Hakim
    Mark all useful answers..

  • Can not view the code for views, triggers or table definition

    Hello Gurus,
    I can not see the code for any of the triggers, views, tables etc. in sql developer. For instance a view code will be
    "create or replace" and then nothing, I could see the code in the past.
    When clicking on SQL tab for table I get following errors
    1. Ora-00904 Invalid Column name
    2. Ora-31600: invalid input value emit_schema for parameter name in function SET_TRANSFORM_PARAMORA-06512: at SYs.DBMS_SYS_ERROR............................
    please advice.
    Thanks

    Sqldev was only certified starting from 9.0.2, so it's possible that's the culprit. The latest update in the certification document even omits 9i entirely.
    Did it start happening after upgrading sqldev? What version are you on?
    K.

  • How can I improve the stability of itunes64bit 8.0.2 on my Vista system?

    Vista Home Premium: iTunes64bit: application crashes after adding album photos and then changing views (list, Album, split) or clicking on different playlists and back to the entire music library.
    The library has 42,000 items (mostly music) so it is quite large. At launch it takes a long time for itunes to load and display. There is no user cues telling me it is running. It simply displays after 60 or more seconds.
    Then I start working in the library, pasting pictures to multiple items, modifying album titles.
    After doing a few management tasks on my music items and navigating back and forth between the music library and playlist (changing views), the application stop being responsive and according to the log, the app just plainly crashes.
    Sometimes I can restart successfully but most of the times, I need to stop the itunes service or log-out before I can restart it successfully.
    I am using itunes64bit 8.0.2
    I am running it on a machine equipped with 4GB of ram and the library lives on a 500GB external hard drive plugged-in through USB 2.0.
    How can I improve the stability of itunes64bit on my system?
    Message was edited by: JF Boisvert

    This VI can be convert to labview 8.0 because subvi are not compatible with old version.
    I post a screenshot.
    Aurélien J.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Du 30 juin au 25 août, embarquez pour 2 mois de vidéo-t'chat ! Prenez place pour un voyage au coe...
    Attachments:
    image.jpg ‏38 KB

  • Just got an ipad air and while creating my apple ID with credit card, I got to itunes gift card/ itunes gift section and was asked to supply a CODE to proceed with the form but I don't have the code. please how how can i get the code?

    Just got an ipad air and why creating my apple ID with credit card, a CODE was requested in the itunes gift card/ itunes gift in order to preceed with the form but I don't have the code. Please how can I find the code so as to enable me complete the form successfully. Thanks alot

    The iTunes gift card field is optional, you don't have to fill it in - leave it blank if you don't have a gift card.
    iTunes gift cards are country-specific (they can only be used in their country of issue), and they are not available in all countries - so you might not be able to dill it anyway.

  • What do you do when you can't read the code on a iTunes gift card?

    What do you do when you can't read the code on a iTunes gift card? I tried taking it back to the store with my reciept, but they said I would have to contact Apple support. Am I out just out $25 dollars?

    See this support article:
    http://support.apple.com/kb/TS1292
    Instructions are at the bottom of that article.
    BTW, this forum is for questions about iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. Normally you want to ask your questions in the general iTunes forums.
    Regards.

  • How can I flip my iphone videos on my PC? My videos from my iphone are horrible when I transfer them to my PC. How can I improve the video on my PC? Can I just convert the files to WMV? When the video plays the speed is off, it's half slow-motion

    My videos from my iphone are horrible when I transfer them to my PC. How can I improve the video on my PC? Can I just convert the files to WMV? When the video plays the speed is off, it's half slow-motion and staggers into normal play. The clips are slightly cut as well, the clips do not roll continuously.  I'm taling about videos that are no more than 2 minutes long.  I'm frustrated and I could really use some advice-my kids basketball games is what I'm recording and I'm trying to send them to my family (they are not very tech savvy). Thanks

    Not it's only function but one for which it was most admirably suited, which is why I really hope someone can find a work around. I am hoping my post to the Apple feedback may prompt a useful response from Apple and I live in hope that my post here will elicit a useful response from another user. I did not miss the the text at the top of the feedback form but you presumably missed my initial text, 'someone here can explain' or my subsequent 'work around from another user'
    Just in case anyone reading this has a large collection of music videos, video podcasts or iTunes U then DO NOT upgrade your iPad to iOS 5. If you are considering purchasing the iPad as a useful mobile device to experience these media organised in your iTunes please don't as you will be wasting your money. (unless someone on this forum knows of a way to undo the mess created by those infallible folks at Apple)
    Yes I know it does other things but the purpose I bought it for doesn't work anymore

  • HT2736 Having emailed myself a gift voucher, I can't redeem the code. Everytime I try it tells me I need Itunes, but I have the most up to date version - help!

    Having emailed myself a gift voucher, I can't redeem the code
    Everytime I try via the email link, it keeps telling me I need to have Itunes
    I have the most up to date version, but nothing seems to allow the Pc (hp) to open it - can anybody help?

    If this page doesn't help then you will need to try contacting iTunes support (you will need to give them as much of the serial number and activation code from the card as you can read) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

  • How Can we improve the report performance..?

    Hi exports,
    I am learning the Business Objects XIR2, Please let me know How Can we improve the report performance..?
    Please give the answer in detailed way.

    First find out why your report is performing slowly. Then fix it.
    That sounds silly, but there's really no single-path process for improving report performance. You might find issues with the report. With the network. With the universe. With the database. With the database design. With the query definition. With report variables. With the ETL. Once you figure out where the problem is, then you start fixing it. Fixing one problem may very well reveal another. I spent two years working on a project where we touched every single aspect of reporting (from data collection through ETL and all the way to report delivery) at some point or another.
    I feel like your question is a bit broad (meaning too generic) to address as you have phrased it. Even some of the suggestions already given...
    Array fetch size - this determines the number of rows fetched at a single pass. You really don't need to modify this unless your network is giving issues. I have seen folks suggest setting this to one (which results in a lot of network requests) or 500 (which results in fewer requests but they're much MUCH larger). Does either improve performance? They might, or they might make it worse. Without understanding how your network traffic is managed it's hard to say.
    Shortcut joins? Sure, they can help, as long as they are appropriate. [Many times they are not.|http://www.dagira.com/2010/05/27/everything-about-shortcut-joins/]
    And I could go on and on. The bottom line is that performance tuning doesn't typically fall into a "cookie cutter" approach. It would be better to have a specific question.

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • How can i write the code in xml publisher desktop

    hi all
    How and where can i write the code in xml publisher desktop ???
    shall i know how to write xml code or what ??
    in which part can i write the code if i have more than one query ?

    hi dear
    Thanks for ur replay...
    What i mean is : i used to work on reports builder,so :
    1- i used to create more than query in some reports.
    2- create formulas ,procedures....
    NOW i want to create the same reports by using xml publisher desktop, so how can i do that...
    when i use {color:#ff0000}report wizard{color}, i can not or i don`t know how to use more than one query, create formulas or procedures.
    Please help me.
    Thanks again.

  • How can I get the code of a Custom Module?

    Hi guys.
    I'm in a new client, and they have a problem in one of their interfaces. The PI version is 7.1.
    The interface uses the Mail Adapter, and there is a Custom Module there. The company that did this module is no longer in this client, and they did´nt leave any document about this module.
    So, how can I find the code of this Module?
    Regards,
    Eric Freitas

    Hello,
    Check Vadim's reply
    Checking code in custom adapter module
    Thanks
    Amit Srivastava

  • Can we wrap the code written in Oracle Forms

    Can we wrap the code written in Oracle Forms or in Reports..........
    Edited by: user12889416 on 3/01/2011 21:08

    Usually you simply ship the compiled sources to your customers if you want to hide your code. There's no way to wrap the code within the fmb or rdf files.
    Regards
    Marcus

  • Photo has packet loss.  Can I improve the image with Aperature?

    I received a poor quality family photo (hard copy). Almost like "packet loss" on TV whereby the image edges are muted and/or missing. I wanted to enlarge the 3 X 5 inch photo but if the quality is poor at this resolution, I know enlarging will just make it worse.
    Can Aperature improve the photo quality? Compression or rendering or ??
    OR is this a photoshop opportunity?
    Please advise.
    Thanks

    Hi labratinaz;
    While I will admit I am now learning to use Aperture, IMHO this sounds like if it can be solve it will take Photoshop to do it. I don't think the adjustments in Aperture are powerful enough.
    Allan

Maybe you are looking for

  • Error in updating pricing using BAPI_QUOTATION_CREATEFROMDATA2

    Hi,     I am using the BAPI function module BAPI_QUOTATION_CREATEFROMDATA2. I am calling BAPI_TRANSACTION_COMMIT subsequently I need to change an existing pricing condition ZMLT which is automatically determined by the config while creating a sales q

  • Error message when creating a recordset :-(

    Hi! I am working with DW since years, now with version 8.02 and first time i have the following problem: When I want to create a recordset (PHP/MySQL) I always get the following message: "The Recordset script does not define the applyServerBehaviour

  • How to create DB partitioning in active data tables for ods?

    hi all, Can anyone let me know how to create DB partitioning in active data tables for ods. if any docs pls share with me at my email id : [email protected] regds haritha

  • Can anyone guide me on how to retrieve a stolen Apple 1 IPad ?

    Can anyone help me how I could retrieve a stolen Apple 1 IPad ?  I have the Walmart receipt for it.

  • CC Desktop Problem

    CC Desktop not responding.  When selected, CC opens in the Apps section, but no apps are displayed, and it seems to be downing loading - see screenshot.  It seems to be stuck in this position.  (CC icon at top of mac screen is black in color; used to