To many rows returned

Hello,
I have a query in which I would like to return one result or another depending on the record returned. Using the 'IN' statement is returning multiple rows. I only want one of the rows with a preference. How can I do that?
If I have company records with more than one address type, I need address_type = 'PCFILING', if no 'PCFILING', return 'LEGAL' address. Can I do this in one select query?
Select query currently reads:
select a.company_name, a.naic, b.owner_eid, E.RELATION_SUB_TYPE_CODE ,
d.address_1, d.address_2, d.city, d.state_code, D.ZIP_CODE
from tmp_pac_mailing a, identifiers b, licenses c, addresses d, relations e
where
b.identifier_1 = a.naic
and b.category_code = 'NAICNUM'
and b.stop_date is null
and b.OWNER_EID = c.OWNER_EID
and c.license_type_code = 'B'
and c.active_inactive_code = 'A'
and b.owner_eid = e.owner_eid
and e.RELATION_TYPE_CODE = 'ADDRESS'
and e.stop_date is null
AND E.RELATION_SUB_TYPE_CODE in ('PCFILING','LEGAL')
AND E.RELATED_OWNER_EID = D.EID
Some compaines have both PCFILING and LEGAL, but I only want to return one row, PCFILING first, then LEGAL. Have tried DECODE and CASE functions to no avail.
Any ideas would be helpful.
Thanks, Toni

Instead of using the relations table directly, you could use an in-line view along the lines of:
(SELECT related_owner_eid, relation_sub_type_code
FROM  (SELECT related_owner_eid, relation_sub_type_code,
              ROW_NUMBER() OVER(PARTITION BY related_owner_eid
                                ORDER BY DECODE(RELATION_SUB_TYPE_CODE, 'PCFILING',1, 2) rn
       FROM relations
       WHERE relation_type_code = 'ADDRESS' and
             stop_date is null AND
             relation_sub_type_code in ('PCFILING','LEGAL'))
WHERE rn = 1) einstead. You could then remove all references to e.XXX from the WHERE clause except the join condition.
HTH
John

Similar Messages

  • Problem w/ geting a unique set of records. Too many rows returned

    This is a query that is looking at itself for two diff reasons.
    The d pass is to search the records that are not voided and pass lmc is the records that are the voids.
    I have to identify the valid recs to be voided and then mark them accordingly but I am getting repeating values
    SELECT DISTINCT
    d.CHARGE_ID,
    lmc.CHARGE_ID as CHARGE_ID_THAT_VOIDED_ME ,
    ROW_NUMBER() OVER (PARTITION BY d.charge_id ORDER BY LMC.SOURCE_SYSTEM_RECORD_ID DESC ) AS rown
    FROM CHARGES d
    INNER JOIN CHARGES lmc
    ON d.Encounter_id = LMC.ENCOUNTER_ID
    WHERE d.TRANSACTION_TYPE_CODE = 0 --not voided
    AND lmc.transaction_type_code = 1 --void records that have limited values to tell me what to void
    AND d.SOURCE_SYSTEM = 'MM' --this is my source system
    AND ( d.IMPUTED_SB_MAP + lmc.IMPUTED_SB_MAP) = 0 --sadly one of those values is the dollar amt. Problem occurs when there are two voids of the same value
    CHARGE_ID CHARGE_ID_THAT_VOIDED_ME ROWN
    10138466 10138459 1
    10138467 10138460 1
    10138468 10138462 1
    10138468 10138461 2
    10138469 10138462 1
    10138469 10138461 2
    10138470 10138463 1
    As you can see I will not get a proper set of values to record the Charge Id that voided me for the charge Id to be voided.
    I am having a real issue with this one.
    Please help

    So many looked and were not able to help.By all mean I hold nothing against anyone. Thankfully I never give up and this is what we did:
    1. A table called CHARGES_N_VOID_STG was created
    2. in the declaration section of my procedure:
    cursor c_voids is select * from CHARGES_N_VOIDS_STG;
    Then after the BEGIN:
              If there were any voids in these clean charges, then you must set the valid
              record that it is offsetting to a transaction type code of 2
    EXECUTE IMMEDIATE 'TRUNCATE table CHARGES_N_VOIDS_STG';
    --Insert the voids that have not been processed.
    --If the CHARGE_ID_I_VOIDED is null then it has not been processed                
    INSERT INTO CHARGES_N_VOIDS_STG
    (     CHARGE_ID_Void,
    IMPUTED_SB_MAP_Void,
    BATCH_ID_Void,
    RECORD_SEQ_Void,
    ENCOUNTER_ID_Void,
    SERVICE_CODE_VOID)
    SELECT     DISTINCT
    v.CHARGE_ID,
    v.IMPUTED_SB_MAP,
    v.BATCH_ID,
    v.RECORD_SEQ,
    v.ENCOUNTER_ID,
    V.SERVICE_CODE
    FROM      CHARGES v
    WHERE     v.TRANSACTION_TYPE_CODE = 1
    AND          v.SOURCE_SYSTEM = 'MM'
    AND           v.CHARGE_ID_I_VOIDED IS NULL;
    --For each void record in the temp table..
    FOR r_void IN c_voids LOOP
    --Update the stage table records with a valid charge to be voided          
    UPDATE      CHARGES_N_VOIDS_STG
    SET          CHARGE_ID_Valid =
    (     SELECT      MAX(CHARGE_ID) AS CHARGE_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0
    AND          SERVICE_CODE = r_void.SERVICE_CODE_VOID)
    WHERE     BATCH_ID_VOID = r_void.BATCH_ID_Void
    AND          RECORD_SEQ_VOID = r_void.RECORD_SEQ_Void     
    AND           ENCOUNTER_ID_Void IN
    (     SELECT      ENCOUNTER_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0);
    --Update a charge with the record's charge ID that voided it and change the trans type code
    -- to 2 and last mod and last modify process id
    UPDATE      CHARGES
    SET          CHARGE_ID_THAT_VOIDED_ME = r_void.CHARGE_ID_VOID,
    TRANSACTION_TYPE_CODE = '2',
    LAST_MODIFIED = sysdate,
    LAST_MODIFY_PROCESS_ID = pCHGDS_PROCESS_ID
    WHERE      CHARGE_ID IN
    (     SELECT      MAX(CHARGE_ID) AS CHARGE_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0
    AND          SERVICE_CODE = r_void.SERVICE_CODE_VOID);
    END LOOP; ----For each void in the temp table..
    --Update the voids in Charges with a value that indicates the void has been processed
    UPDATE      CHARGES
    SET          CHARGE_ID_I_VOIDED = (
    SELECT     CHARGE_ID_Valid
    FROM          CHARGES_N_VOIDS_STG
    WHERE     CHARGES.CHARGE_ID = CHARGE_ID_Void)
    WHERE     EXISTS (
    SELECT     CHARGE_ID_Valid
    FROM          CHARGES_N_VOIDS_STG
    WHERE     CHARGES.CHARGE_ID = CHARGE_ID_Void);
    We had no choice but to find the voids first then go through each and find only one records to void that matched our criteria. Some of you may have thought that the client should have put more data to make it easier to find each record but some clients are what they are and you have to make the best of it.
    Thanks and You are welcome
    NAMASTE

  • Too many rows return on query?

    I am trying to write a query to pull data from two different tables. There are 444 records in p table and 650 records in the T table yet when i run my query I am getting over 10,000+ records??? When I look at the results it seems that it is applying multiple dates per person when there is only 1 end date? and showing multiple languageid's when only 1 language is spoken?
    SELECT DISTINCT P.LASTNAME, P.FIRSTNAME, T.LANGUAGEID, T.TEST_TYPE, T.END_DATE, T.SCORE1, T.SCORE2
    FROM PS_TEST_SCORES T, PS_PERSONNEL P
    WHERE T.SCORE1 >='2'
    AND T.SCORE2 >='2'
    AND T.END_DATE between to_date( '01-jan-2009 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
    and to_date( '28-jan-2011 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
    ORDER BY P.LASTNAME;
    example result would be
    jones john german test_type 24-dec-09
    jones john german 22-jan-09
    jones john german 01-feb-10
    jones john spanish 05-aug-10

    user11384952 wrote:
    sorry .. I missed the join.. pardon that I am a newbie
    I changed it to ....
    SELECT DISTINCT P.SSN,P.LASTNAME, P.FIRSTNAME, T.LANGUAGEID, T.TEST_TYPE, T.END_DATE, T.SCORE1, T.SCORE2
    FROM PS_TEST_SCORES T, PS_PERSONNEL P
    WHERE SELECT DISTINCT P.LASTNAME, P.FIRSTNAME, T.LANGUAGEID, T.TEST_TYPE, T.END_DATE, T.SCORE1, T.SCORE2
    FROM PS_TEST_SCORES T, PS_PERSONNEL P
    WHERE PS_TEST_SCORE.SSN=PS_PERSONNEL.SSN
    AND T.SCORE1 >='2'
    AND T.SCORE2 >='2'
    AND T.END_DATE between to_date( '01-jan-2009 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
    and to_date( '28-jan-2011 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
    ORDER BY P.LASTNAME;That can't be right: it has 2 SELECT clauses, 2 FROM clauses and 2 WHERE clauses.
    Perhaps you meant
    SELECT DISTINCT
              P.LASTNAME
    ,        P.FIRSTNAME
    ,        T.LANGUAGEID
    ,        T.TEST_TYPE
    ,        T.END_DATE
    ,        T.SCORE1
    ,        T.SCORE2
    FROM        PS_TEST_SCORES     T
    ,        PS_PERSONNEL           P
    WHERE        PS_TEST_SCORE.SSN     = PS_PERSONNEL.SSN
    AND        T.SCORE1           >= '2'
    AND       T.SCORE2          >= '2'
    AND        T.END_DATE           between to_date ( '01-jan-2009 00:00:00'
                                    , 'dd-mon-yyyy hh24:mi:ss'
                        and      to_date ( '28-jan-2011 00:00:00'
                                  , 'dd-mon-yyyy hh24:mi:ss'
    ORDER BY  P.LASTNAME;Now you do have a join condition:
    WHERE        PS_TEST_SCORE.SSN     = PS_PERSONNEL.SSNso that looks much better. In all the other conditions, you referred to the tables by their aliases, t and p, and not by their real names. You need to do that in this new condition, too:
    WHERE        T.SSN     = P.SSN
    now I get "PS_PERSONNEL.SSN invalid identifier"?
    I ran a query to see what the constraint types are.. PK, FK?? on the tables and there is no PK or FK they all say "C" would that affect the join?
    select *
    from all_constraints
    WHERE owner = 'OWNER' and TABLE_NAME LIKE 'PS\_%' ESCAPE '\'
    order by table_name, constraint_type;constraint_type='C' means a CHECK constraint, which has nothing to do with joins.
    constraint_type='R' indicates a referential integrity constraint, but that, at best, only hints at what a correct join condition might be.
    No kidding: if you want help, the best thing is to post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.

  • How to get total number of rows return by query

    hi all
    i am using forms 6i with oracle 10G in windows environment....
    i have a tabular form now i want to know that how many rows return by the query...like when user click on enter query and then give any search criteria and then execute query..it displays the records but i want to count the records that how many rows are return.............
    hope you understant what i mean
    Thanks in advance
    Regards

    U can use
    "Select count(*) from <table> where <condition>"
    <condition> is the where clause being used during "Execute Query"
    this will give u the no of records in query.
    And second option is to take a summary column. whose function is set "COUNT" and
    "Summarized item" should contain a column that will never be blank. After execute query this column will give u no of records in block.
    Regards....

  • Tag Query History mode returning too many rows of data

    I am running a Tag Query from HQ to a plant site and want to limit the amount of data that returns to the minimum required to display trends on a chart.  The minimum required is subjective, but will be somewhere between 22 and 169 data points for a weeks data.  Testing and viewing the result is needed to determine what is an acceptable minimum. 
    I build a Tag Query with a single tag and set it to History Mode.  I set a seven day period going midnight to midnight.  And I set the row count to 22.  When I execute the query it returns 22 data points.  But when I go to visualization, I get 565 datapoints.  So obviously that is not what I want as I want a very slim dataset coming back from the IP21 server (to minimize the load on the pipe). 
    Any suggestions?

    Hi Michael,
    it looks to me like you have enabled the "Use Screen Resolution" option in your display template or in the applet HTML. Setting this option makes the display template fetch as many rows as there are pixels in the chart area. Like setting a rowcount in the applet HTML as a param, this will override any rowcount limitations you have set at the Query Template level...
    Hope this helps,
    Sascha

  • How to Customize the Message "No Row Returned" from a Report

    Hi,
    I've been trying to customize the Message "No Row Returned" from a Report.
    First i followed the instructions in Note:183131.1 -
    How to Customize the Message "No Row Returned" from a Report
    But of course the OWA_UTIL.REDIRECT_URL in this solution did not work (in a portlet) and i found the metalink document 228620.1 which described how to fix it.
    So i followed the "fix" in the document above and now my output is,..
    "Portlet 38,70711 responded with content-type text/plain when the client was requesting content-type text/html"
    So i search in Metalink for the above and come up with,...
    Bug 3548276 PORTLET X,Y RESPONDED WITH CONTENT-TYPE TEXT/PLAIN INSTEAD OF TEXT/HTML
    And i've read it and read it and read it and read it and can't make heads or tails of what it's saying.
    Every "solution" seems to cause another problem that i have to fix. And all i want to do is customize the Message "No Row Returned" from a Report. Please,...does anyone know how to do this?

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

  • How to restrict number of rows returned in a query

    Hi frnds,
    I'd like to restrict number of rows returned by my query to some 10 rows. how to do that.When I try doing with the rownum<10 its giving results for a particular dept and that too some 6 rows only...btw I'm grouping my table and includes joins from many a table and am ordering the table results by a column.. How to do this..

    776317 wrote:
    Hi frnds,
    I'd like to restrict number of rows returned by my query to some 10 rows. how to do that.When I try doing with the rownum<10 its giving results for a particular dept and that too some 6 rows only...btw I'm grouping my table and includes joins from many a table and am ordering the table results by a column.. How to do this..
    TELL ME HOW MANY ROWS YOU HAVE IN TABLE?
    Because you have only *6 rows* in you column, if you less than 10 rows then it displays only containied/exist rows. nothing much
    select ename,empno from emp where rownum < 10;Thanks

  • How to get the number of rows returned by a report?

    Hi,
    I'm developing my first application in APEX and so far everything seems fine, except I can't figure out this very simple thing: I have a report based on a PL/SQL block returning an SQL string. I'd like to have a message (something like "X rows returned") just before the report. The closest thing I could find was "X to Y out of Z" in the pagination styles, but that's not what I want. Also I don't think running the same query to get COUNT() is wise.
    Any help would be appreciated.
    Thanks,
    Konstantin

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

  • Count rows returned in a subquery in pl/sql block

    Hi,
    I'm working on a trigger in Oracle 11 to check that a student has met prerequisites before enrolling in a class. I need to determine how many rows came back on the query in order to determine if I should raise an exception or not. The following is raising the exception if the prereqs are complete or not. I've haven't included the code in the where clause because I've tested is seperately and get good results. I know this is limiited info, but is there some obvious mistake I've made here?
    CREATE OR REPLACE TRIGGER prereq
    BEFORE INSERT ON enrollment
    FOR EACH ROW
    DECLARE
      howmany  number;
    BEGIN
      select count(*)
      into howmany
      from dual
      where exists ((insert code here that returns 0 rows if prerequisites are not met);
      if howmany = 0 then
        raise_application_error(-20000, 'The prerequisites for this course are not complete');
      end if;
    end;
    /

    As you are selecting from dual you might hit no_data_found if the exist caluse doesnot return any row.
    Try this,
    CREATE OR REPLACE TRIGGER prereq
       BEFORE INSERT
       ON enrollment
       FOR EACH ROW
    DECLARE
       howmany        NUMBER;
    BEGIN
       SELECT COUNT (*) INTO howmany FROM DUAL;
                   WHERE EXISTS ((INSERT code here that returns 0 ROWS IF prerequisites are NOT met);
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
          raise_application_error (-20000
                                  ,'The prerequisites for this course are not complete');
    END;You dont need count(*) from dual you can simply use
    SELECT 1 INTO howmany FROM DUAL;
                   WHERE EXISTS ...G.

  • Limiting number of rows returned by SQVI

    I've created a query in SQVI and I need to limit the number of rows returned by the query.  (I'm using the query as an exploratory tool, and it's not easy to predict how many records will be returned based on the selection fields I'm using.)
    Is there any way to add a 'Maximum No. of Hits' field to the SQVI selection screen similar to what is found when using SE16?
    Thanks,
    Bob

    It's not surprising that you are confused because the documentation doesn't bother to explain what the "fetch size" actually is, it just says that setFetchSize sets it and getFetchSize gets it. As I understand it from some other documents I read about JDBC, the fetch size is a number that may be used internally by the JDBC driver. Here's an example of how I understand it (others, I know you will feel free to correct me if you disagree):
    When the driver produces a result set with a very large number of records, it has to generate those records and deliver them to the system that requested them. If the database is not on the same system, then those records must all travel over the network. It could be a performance problem if you had to wait for (say) 80,000 records to travel across the network. Enter the fetch size. If you set the fetch size to 100, then the driver will bring the records across in batches of 100, as the program calls for them. Now, this buffering is transparent to your program; the driver doesn't tell you that it's getting another batch and you can't tell it to get another batch. So it is not a solution to the problem that everybody has here, namely how to display your records 10 per page and allow the user to go back and forth among those pages, like search engines do.

  • Total Rows returned in interactive report

    Hi
    I have an interactive report that displays a warning message if more than 200 rows are returned. Is there anything within APEX that tells me the exact number of rows returned in my report, or at the very least if my report has exceeded my 200 row limit?
    I have a button on my page that I only want to display if the number of rows returned in my query is <= 200.
    I know that I could use say NDS to execute my select statement in order to determine the number of rows as a seperate statement - but this seems a bit of over-kill.
    Many thanks
    Paul

    M Tajuddin wrote:
    Hi Paul,
    You can change the this from report attributes. Click on Edit page >> click on the Interactive report >> click on Report Attributes on the top >> down the bottom there is an option where you can change the row numbers and error message etc.
    Hope this helps,
    M Tajuddin
    http://tajuddin.whitepagesbd.com
    Hi
    I dont want to modify the number of rows returned. I just want to know how many rows are returned so that I can display or hide a button.
    Thanks
    Paul

  • Explain rows returned in a plan for group by

    I have a (select statement) that returns 18 rows.
    wrap a nested select with a group by around it
    select col_a, col_b from
    (select statement)
    group by col_a, col_b
    still returns 18 rows as expected
    explain it and I see the 18 rows returned at Id 2 and the hash group by and select showing 1 rows.
    | Id  | Operation                                   | Name                           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |                             
    |   0 | SELECT STATEMENT                            |                                |     1 |    95 |       | 90897  (75)| 00:00:02 |       |       |                             
    |   1 |  HASH GROUP BY                              |                                |     1 |    95 |       | 90897  (75)| 00:00:02 |       |       |                             
    |   2 |   VIEW                                      |                                |    18 |  1710 |       | 90896  (75)| 00:00:02 |       |       |        reason Im asking is I rewrote the SQL in the inner statement for tuning purposes and I still get 18 rows as expected but now I have 2 rows returned to hash group by.
    | Id  | Operation                                  | Name                           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |                              
    |   0 | SELECT STATEMENT                           |                                |     2 |   190 |       | 82657  (80)| 00:00:02 |       |       |                              
    |   1 |  HASH GROUP BY                             |                                |     2 |   190 |       | 82657  (80)| 00:00:02 |       |       |                              
    |   2 |   VIEW                                     |                                |    18 |  1710 |       | 82656  (80)| 00:00:02 |       |       |                              
    ..In terms of the above plans what does "rows" mean for the hash group by.

    Purvesh K wrote:
    961469 wrote:
    reason Im asking is I rewrote the SQL in the inner statement for tuning purposes and I still get 18 rows as expected but now I have 2 rows returned to hash group by.And in fact, how many rows does your entire query return?
    Does the output of two of your queries differ?
    If they do not, then I do not see any issue.No, the output doesnt differ, and its not a problem for me, just something I wanted explained.
    >
    >
    From the Cost and the Rows, posted in Explain plan, it looks like some different plan is being used.Yes, there is, I rewrote it, but only on the inner select statement but I don't have a question on that. If take the inner select statement from both I get the 18 rows correctly.
    Were the statistics pertaining to the tables in use, collected between execution of two queries?no but that last select is only on the outer select, ie shouldnt be affected by the stats, anyway, The queries are run straight after each other.
    I will suggest to read the {message:id=3292438} and post the relevant details.
    Also, do not forget to mention the Table/Index details (actual and with statistics) and the Query.I can, buts its VERY lengthy as theres a lot of nested tables/views and for me not relevant as if I run the inner select on both queries the datasets match. I was hoping for a simpler answer like Ajays which was my understanding of it too but as the outer select and group by hasnt changed, I cant understand the difference in the rows.
    thanks for your reply though.
    >
    How many columns you specified in group by function before & after query modification I thought this too and was my understanding but the group by clause hasnt changed, only the inner select.
    Edited by: 961469 on Jan 3, 2013 7:42 AM

  • Wish to find out number of rows returned from query

    hi,
    is it possible to determine how many rows have been returned after a query has been executed?
    thank you.

    It doesn't seem like there is a method to do it for you, [...]There can't be such a method that's guaranteed to work for all databases. Many databases just hand you a cursor with the query results, and you have to walk the cursor to find the complete set. It's even possible for the DB to continue computing the query in the background and just give you a cursor to walk and consume what it has already generated.
    So no, you have to walk the result set (effectively pulling everything over to the client) to count the number of rows..

  • Exception too many rows...

    Hi
    I am getting two different outputs with following code depending upon i declare the variable in first or second way...
    when i declare the variable v_empno as number(10) and too many rows exception is raised....and after that i dbms this variable..it is null...
    but when i declare the same variable as table.column%type....and the similar scenario happens and i dbms the value of variable...it is not null...rather the first value from output of the query...
    declare
    --v_empno number(10);
    v_empno emp.empno%type;
    begin
    dbms_output.put_line('before '||v_empno );
    select empno into v_empno from emp;
    dbms_output.put_line('first '||v_empno);
    exception when too_many_rows then
    dbms_output.put_line('second '||v_empno);
    dbms_output.put_line('exception'||sqlerrm);
    end;
    is there any specific reason for this....
    ur comments plz
    Thanks
    Sidhu

    In 9i:
    SQL> declare
      2  --v_empno number(10);
      3  v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11  end;
    12  /
    before
    second 7369
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.
    SQL> declare
      2  v_empno number;
      3  --v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11  end;
    12  /
    before
    second
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.
    SQL> edit
    Wrote file afiedt.buf
      1  declare
      2  v_empno number(10);
      3  --v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11* end;
    SQL> /
    before
    second 7369
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.In 10G:
    SQL> declare
      2  v_empno number(10);
      3  --v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11  end;
    12  /
    before
    second 7369
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.
    SQL> edit
    Wrote file afiedt.buf
      1  declare
      2  v_empno number;
      3  --v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11* end;
    SQL> /
    before
    second 7369
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.
    SQL> edit
    Wrote file afiedt.buf
      1  declare
      2  --v_empno number;
      3  v_empno emp.empno%type;
      4  begin
      5  dbms_output.put_line('before '||v_empno );
      6  select empno into v_empno from emp;
      7  dbms_output.put_line('first '||v_empno);
      8  exception when too_many_rows then
      9  dbms_output.put_line('second '||v_empno);
    10  dbms_output.put_line('exception'||sqlerrm);
    11* end;
    SQL> /
    before
    second 7369
    exceptionORA-01422: exact fetch returns more than requested number of rows
    PL/SQL procedure successfully completed.Anyhow you should not rely on the fact Oracle fetches the first value into variable
    and keeps it when the excaprion is raised.
    Tom Kyte discusses the SELECT INTO issue here:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:7849913143702726938::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1205168148688
    Rgds.

  • Display query's result (with many rows & field) into a list ?

    I'd like to display the result of a query wich returs many rows without using a list of values but another component which allowed the display of sereval columns at the same time.
    Note: I can't use a LOV because I don't want to return no value, and I need a TLIST presentation.
    null

    A kludgy solution would be to create a database view that combines the multiple columns into a single standardly formatted column, and use that for displaying in a jcombobox.
    Depends upon whether you like to code Java or like to play in the database. grin
    If you do that Java solution please post the code here!

Maybe you are looking for

  • GroupFilter and sum(); filtered records should not be included in the sum()

    Hi All, I am working on a report that has the following requirement. 1. Query records from the database (multiple queries) 2. Filter records based on a certain criteria. 3. Sum() the rows. 4. Cannot use where clause because of the complexity of the r

  • Deployed Files getting overwritten every time when I do a server restart

    Hi, I have deployed a web application in weblogic server. For testing purpose, instead of placing the changed file inside the war our team will change the files directly in the deployed area. Once when we restart the application server, the new files

  • Do all Flash FLV players resize the incoming video?

    I'm finding that the animations I make look best if rendered at full size and then played back in a player that is of a smaller size. I want to offer my content for syndication in websites that I don't have any control over. Is it standard practice f

  • Should i download adobe photoshop elements 10

    Good grief, this is like my 15th screen... My question is this, should I install Adobe Photoshop Elements 10 on my new mac book?  Will it cause problems?

  • Online Data Archival

    Hi, In my new project, I need to work on online data archival where application can access the archived database online. Can yuo please help me with any link where I can find information/steps for same. Thanks