What is the problem with this query? exception does not work.

DECLARE
v_employee_id EMPLOYEES. EMPLOYEE_ID % TYPE;
v_last_name EMPLOYEES. LAST_NAME % TYPE;
v_salary EMPLOYEES. % SALARY TYPE.
e_invalid_emp EXCEPTION;
BEGIN
SELECT last_name, salary v_employee_id, v_last_name, v_salary, employe_id
EMPLOYEES where employee_id = & employee_id;

IF SQL % NOTFOUND THEN
RAISE e_invalid_emp;
END IF;

DBMS_OUTPUT. Put_line(v_employee_id||) e '|| v_last_name | » '|| v_salary);

EXCEPTION
WHEN e_invalid_emp THEN
DBMS_OUTPUT. Put_line ("' employee not found...");
END;
/

Tags: Database

Similar Questions

  • What is the problem with this query?

    Hello

    I need some advice on how to change the following query (with perhaps some analytical function) to speed it up. Currently, it takes 6 + minutes. This query is executed in response to a request from the front-end application and 6 + min is certainly unacceptable.

    I am trying to provide as much information I can think, but if more information is needed, please let me know.

    I have a table called "wave_result". It contains millions of rows. PK is Wave_Id, Version_nbr, node_nbr and prod_nbr. For each 'wave_id + node_NBR + prod_nbr' there are several versions (version_nbr). In the following query, I try to extract a line with MAX version_nbr for combination of ' wave_id + node_NBR + prod_nbr.

    H3. Request:
    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE  wr.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.version_nbr =
                    (SELECT MAX (wr1.version_nbr)
                       FROM wave_result wr1
                      WHERE   wr1.wave_id = wr.wave_id
                            AND wr1.node_nbr = wr.node_nbr
                            AND wr1.prod_nbr = wr.prod_nbr)
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
             AND s.wave_id = wr.wave_id
             AND s.node_nbr = wr.node_nbr 
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat
    H3. Rank of charges:
    ========
    "wave_result" is the largest table with millions of rows.
    Table                Total Rows       Rows for wave_id = 51
    Ideal_prod           188K             38K
    Ideal_store          3K               574
    Wave_result          90M              19M
    H3. Stats
    are updated almost daily by the DBA (not sure if that's a good or bad).

    H3. Explain the Plan:
    =========
    SELECT STATEMENT ALL_ROWS Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
         12 HASH GROUP BY Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
              11 VIEW VIEW SYS.VM_NWVW_2 Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
                   10 FILTER 
                        9 HASH GROUP BY Cost: 330,737 Bytes: 2,425,603 Cardinality: 14,881 
                             8 HASH JOIN Cost: 327,183 Bytes: 41,233,784 Cardinality: 252,968 
                                  1 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKIDEAL_STORE Cost: 4 Bytes: 13,202 Cardinality: 574 
                                  7 HASH JOIN Cost: 327,178 Bytes: 35,415,520 Cardinality: 252,968 
                                       5 HASH JOIN Cost: 198,619 Bytes: 18,764,328 Cardinality: 183,964 
                                            3 TABLE ACCESS BY INDEX ROWID TABLE APAPOPR.IDEAL_PROD Cost: 939 Bytes: 2,272,380 Cardinality: 37,873 
                                            4 TABLE ACCESS FULL TABLE APAPOPR.WAVE_RESULT Cost: 197,063 Bytes: 7,974,414 Cardinality: 189,867 
                                       6 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKWAVE_RESULT Cost: 82,467 Bytes: 721,495,854 Cardinality: 18,986,733 
    H3. Sample data:
    ===========
       For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    H3. Version of database information are below to:
    =========================
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE            11.1.0.7.0                        Production
    TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thank you very much!!

    Concerning
    For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    

    As you mentioned that this particular request is called by a front screen, how different search criteria you get it to show on the front end?
    Assuming that if the user is searching just of wave_id = 51 which lines returns to 28466854, it is certainly not a good approach to go look up many records to put end Front end is very light and can not hold many records and will be finally the web server will throw off out of memory exception. Always a limit on the number of records that you retrieve from the database and display it on the front plane.
    OR
    The second case where the user makes a search by wave_id, node_nbr and prod_nbr, even if she returns to 3 lines, behind the scens, he still made a full scan on the wave_result table. If we go with analytical function, we can reduce a sweep of extra table on the wave_result table. Also the table has millions of lines and the max (version_nbr) seems to be a frequently used on this table sub query. While inserting a record into the table wave_result, you must probably have a calculated value that will tell you its value max and you will choose just the rank of this value, instead of at each time max(). something like below...

    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE ipl.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.wave_id = s.wave_id
             AND wr.node_nbr = s.node_nbr
             AND wr.precomputed_max_value = 'MAX'
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat;
    
  • What is the problem with this query? My head is numb!

    Can someone tell me why this request;

    < cfquery datasource = "manna_premier" name = "qGetstats" >
    SELECT the user name,
    UserFirstName,
    UserLastName,
    LastLogin,
    TotalLogins,
    UserZone,
    TM_Name
    USERS
    WHERE UserID = ' #. TM_log UserID # '.
    < / cfquery >

    generates this error message;

    Run database query error.

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Too few parameters. 1 expected.
    The error occurred in D:\Inetpub\mannapremier\TM_log_report2.cfm: line 28
    26 :         TM_Name
    27 : FROM Users
    28 : WHERE UserID = "#TM_log.UserID#"
    29 : </cfquery>
    30 : 
    

    SQLSTATE07002
    SQLSELECT the user ID, UserFirstName UserLastName, LastLogin, TotalLogins, UserZone, TM_Name FROM USERS WHERE UserID = '10120.
    VENDORERRORCODE-3010
    DATASOURCEmanna_premier

    I see that my variable WHERE comes through but the domain name is not working. I'm sure that the answer is obvious, but it drives me crazy!

    Help, please!

    I tried and got this result;

    No, you now use different data. Now, the user ID is empty, while she was 10120 first.

    The only problem seems to be double quotes. To check this, test with

    WHERE UserID = 10120
    

    I'm assuming that the userID field to be an integer. If it is text, then use single quotes (not!), as in

    WHERE UserID = '#TM_log.UserID#'
    
  • What is the problem with this query in the source

    A blank page is region 2. Region1: enter rec_no (-rec_no is varchar2) region2:hide and show that displays one record based on rec_ no region1 entered.
    The problem is that I get the following error

    ORA-06550: line 1, column 7: PLS-00428: an INTO clause in this SELECT statement

    Here's my simple query in a process of pl/sql
    Start
    Select rec_no, rec_name from mytable where rec_no = upper(:P16_rec_no);
    end;

    Why? The same query works under the sql command.

    what I'm trying to accompolish here, it is because he has given huge if I want to display hide also multiples, regions and allow users to update each region as a result. Help, please. It kills me that I just can't understand what is causing the problem to the query. Thank you.

    Hello

    The list is set to the field EMPLOYEE_ID itself? What is the primary key of the table? In my example, DEPTNO is the primary key and I used the element generated by the wizard page to display the list. The parameters of the Source of the item itself or the column DEPTNO and database so that the process "process line...". "to identify the updated row.

    Andy

  • What is the problem with this WHERE statement?

    What is the problem with this WHERE statement?

    < cfquery datasource = "manna_premier" name = "kit_report" >
    SELECT SaleDate,
    TerritoryManager,
    Distributor,
    DealerID,
    Variable,
    US_Dealers.ID,
    DealerName,
    DealerAddress,
    DealerCity,
    DealerState,
    DealerZIPCode
    Orders, US_Dealers
    WHERE US_Dealers.ID EQ DealerID AND SaleDate BETWEEN #CreateODBCDate (FORM. Implementation) # AND #CreateODBCDate (FORM. End) #.
    ORDER BY SaleDate
    < / cfquery >

    It's driving me crazy!

    Syntax error (missing operator) in query expression ' US_Dealers.ID EQ DealerID

    You accidentally use the CF equals operator: "EQ".

    Instead of MS Access: «=»

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver]...

    in a query expression. AND SaleDate BETWEEN #10/1/2009 #-October 18, 2009 #'.

    I don't see how CreateODBCDate() would produce these values.  But maybe it's just a quirk of the error message?

  • How I download 80070103 windows update is update safe what is the problem with this update

    Just got the update installation today to download update 80070103 time ever I go to download the update fail what is the problem with this update & how do I get updated.

    Hello

    Thanks for posting in the Microsoft Community.

    If I understand correctly that you have problems with Windows Update.

    Please answer these questions:

    1. What is the update's KB number?

    2 have you made any changes to the computer before the show?

    Let us try the following methods:

     

    Method 1: Run the following fix - it:

     

    The problem with Microsoft Windows Update is not working:

    http://support.Microsoft.com/mats/windows_update/

    Method 2: See the following article:

    Windows Update 80070103 error code:

    http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-Update-error-80070103

    Hope the helps of information. We know if you need help. We will be happy to help you.

  • What is the problem with this URL

    Can someone tell me what is the problem with this url
    owa_util.redirect_url(apex_util.prepare_url('f?p='||:APP_ID||':25:'||:APP_SESSION||'::'||:DEBUG||':25,28'||':P25_JOBID,P25_PG:&P3_JOBID.,3, null,||:APP_SESSION'));
    It gives me a value for P25_PG, that is to say 3 but always sets P25_JOBID to 0

    Gus

    Hello Gus,

    It looks like point P3_JOBID has no value for the rendering of the page.
    If the value is set subsequently, you can try the following change

    owa_util.redirect_url(apex_util.prepare_url('f?p='||:APP_ID||':25:'||:APP_SESSION||'::'||:DEBUG||':25,28'||':P25_JOBID,P25_PG:'||:P3_JOBID||',3, null,||:APP_SESSION'));
    

    But the part at the end

    ||',3, null,||:APP_SESSION'
    

    Wil do nothing because you give only 2 items in the list separated by commas of the page elements you want to submit. Everything after the second comma in the comma separated value list is of no use for the url of the apex.

    As additional info, the URL of the Apex is built like this:
    >
    1 - application ID or alias
    2 - page ID or Alias
    3 - session & SESSION. : APP_SESSION
    4. application (for example, PRINT_REPORT = REPORT_1) & ASK. : REQUEST
    5 - debug (YES or NO) & DEBUG. : DEBUG
    6 - cache framework

    APP - clear the cache for the entire application
    SESSION - clear the current user session cache
    PR - Reset pagination
    x - clear the page cache x
    -empty the cache for the element y

    7 - separated by a comma list of items on the page
    8 - the list of values separated by commas
    9 - mode printer friendly (YES or blank)

    f? p = & APP_ID.: 1010: & APP_SESSION. : & DEBUG. : RP, 1010:P1010_ITEM1, P1010_ITEM2, P1010_ITEM3:A, B, C
    >

    Kind regards
    Kees Vlek
    -----
    Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66
    If the answer to question please change replied and mark the appropriate post as correct / helpful.

  • What is the problem with this Forum? Why Adobe taking so long to reply to messages?

    What is the problem with this Forum? Why Adobe taking so long to reply to messages?
    It is in fact 'specific' Forum of Photoshop.
    I usually come back another Adobe forum responses quickly.

    Chime.

    Hi people,

    For what it's worth, there are several of us who try, in addition to our regular work, to keep an eye on two other forums.  Quite simply, we care about the product and try to make sure that we give our customers the best experience as possible.  Plus, what better way to hear about your weak points in order to solve them.  But, as Mylenium and Christmas as well stress this, the forums are officially a user experience.  If you need help fast or official, it isn't the best place to do it.

    Regarding your question of Arab, Rahzah, I answered in two different threads and would be happy to help you with your problem.  Please choose a single thread and stick with it. two tabs is a pain.

    Thank you
    David

    PS - some of us do check the forums on our time, as I did last week at the launch while I was on vacation.

  • Could someone explain to me what is the problem with this refined expression?

    Hi, could someone explain to me what is the problem with this refined expression

    faultCode:Server.Processing faultString:' unable to invoke CFC - regular expression malformed ' ^ [0-2][0-9][/][0-1][0-2][/][1-2][0-9]{3}+$ '.»»

    Thank you

    I think that the + should not be there. Do you have a match?

  • What is the problem with this pl/sql code?

    What is the problem with this statement of the cursor? I am getting PLS-00341 error for her:
    CURSOR cur_rsource(p_sql_stmt IN VARCHAR2) IS
            SELECT plan_table_output FROM v$sql s, table(dbms_xplan.display_CURSOR(s.sql_id, s.child_number)) t WHERE sql_text LIKE '''%'||p_sql_stmt||'%''';
    How to solve this problem?

    Thank you

    Published by: PhoenixBai on December 14, 2009 14:05

    I don't have time right now to study exhaustively, but for me his vomit ORA-00942 table or view does not exist on this line:

        SELECT sql_id, child_number into tmp_sql_id, tmp_child_number
             from v$sql where sql_text like sql_statement||'%' and sql_text not like '%v$sql%';
    

    I am able to select from v$ sql in normal SQL as user I am compiling as, so don't know why it's complaing.

    Anyone know if there are certain restrictions on access to the views v$ through PL/SQL?

    EDIT: http://www.dbasupport.com/forums/showthread.php?t=22299

    Access to the views of $ v seems to be through a role - try giving explicit access to it.

    As SYS, you must grant select permissions on V_$ SQL (V$ SQL is synonymous with V_$ SQL) to your owner of the procedure. Just tested on my system and it allows him to compile.

    Published by: Cyn on December 14, 2009 10:30

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • What is the problem with this point of view?

    Hello
    Im trying to write a review, I can query and when adding a filter to the owner/view_name, it will give me the list complete tables underlying source based on dba_dependencies

    Here is what I have
    CREATE OR REPLACE VIEW VW_VIEWS_DB_REF AS
    SELECT 
         V2.OWNER           VIEW_OWNER,
         V2.VIEW_NAME,
         V2.REF_NAME           DB_OBJECT,
         V2.REF_TYPE
    
    FROM
         ( SELECT DISTINCT
                 v.OWNER,
              v.VIEW_NAME,
              db.REFERENCED_NAME           REF_NAME,
              db.referenced_type           ref_type                                   
         FROM DBA_DEPENDENCIES db,
              (SELECT VIEW_NAME,
                      OWNER
              FROM ALL_VIEWS
              ) v
    START WITH NAME                  = v.VIEW_NAME
    CONNECT BY PRIOR REFERENCED_NAME = NAME
         ) V2
    WHERE V2.REF_TYPE='TABLE'
    Of course, it does not work correctly
    When I do
    select * from VW_VIEWS_DB_REF 
    where view_owner= 'x'
    and view_name ='Y'
    the query runs and never stops
    so I wanted to ask if anyone can help to rewrite that code?
    Thank you for the advice
    Thank you very much
    Rgds

    You obviously have an infinite loop in their. A likely problem is that you join only on

    REFERENCED_NAME = NAME
    

    You should join without doubt on the TYPE and the OWNER.

    Cheers, APC

  • What is the problem with this WMF?

    Hello

    The next WMF is extracted from a word document:

    x_and_f_onTopOfEachOther.wmf

    When placed in another Word file or when it is placed in an Open Office Writer document WMF seems fine, but when placed in a product Adobe (Illustrator or InDesign), the letters 'x' and 'f', and 'd' and 'x' stack up to each other.

    What is the problem and how to fix it?

    Thank you

    She helps all select and set auto kerning. Here is what happened to me

    Don't notice any specified kerning.  Now

    With Auto kerning value

  • What is the problem with this page and IE?

    Gents,

    I have this page, exported from Excel to a HTML file, added some jQuery and Spry ToolTips and published it.

    It works very well with Firefox and Chrome, but IE trips on it. It simply display a blank page.

    Here is the link to the home page: Référence PPBM5

    With FF or Chrome test results page appears without a problem with IE, it's just a blank page. It's the page that causes these problems: http://ppbm5.com/Benchmark5.html

    Who am I to spoil that IE does not work? Any suggestion is welcome.

    Ready for the same problem of crazy...

    You have

    Benchmark results<p class="reply"> <p class="reply">When I changed it to</p> <p class="reply"><title>Benchmark results

    It worked.

    Gary

  • Can't stop... What is the problem with this button code?

    Hello

    I am totally confused as to why I can't navigate to another frame.

    I put 2 days in this simple problem now and I'm ready to give up and go back to AS2.

    Help, please!

    I use CS4; publish the AS3 settings, 10.0


    I have a button on frame 2 that should take me to frame 3 when you click it.

    (So far I tried a hundred different ways, but I don't get to frame 3...)

    I tried different things...

    > Create the button dynamically from the library...

    > Insert statically library on frame 2...

    > referencing the mainTimeline by a variable...

    > wrapping the stop action in another function... (if it is placed directly on the timeLine of the movie properly goes directly to frame 3)

    > naming frame 3...

    > using "nextFrame" rather than "STOP"...

    etc...

    In most cases I don't get an error in the output panel and no compiler error either. It simply doesn't get it!

    (Just on the same frame after I click the button)

    Here is the code which I think should work; but does not work:

    function moveTo3 (event: MouseEvent): void {}

    trace ("Button_Clicked"); always redraws correctly; but the film does not go to frame 3.

    gotoAndStop (3);

    }


    f_btn.addEventListener (MouseEvent.CLICK, moveTo3);

    WHAT ME MISSING HERE?

    Thanks in advance...

    If you found the trace, you get frame 3.  Something else is causing the stop(); to ignore.  You have any kind of active continuous operation code in the file, as an ENTER_FRAME listener, or some other listener who might have been waiting in the wings?  As I said, it is not likely to be a bug, it is not impossible.  If you can save a copy of the fla file in a CS3 file and make it available via a server I can take a look and see if I can find the suspects.

Maybe you are looking for