ORA-01422

hi
i am trying to create a function as follows
CREATE OR REPLACE FUNCTION T_NAME(PRD VARCHAR2,BR NUMBER)
RETURN VARCHAR2
IS
V_NAME VARCHAR2(50);
BEGIN
SELECT LONGNAME INTO V_NAME FROM ac_mast
WHERE TRIM(SUBSTR(PRD,1,8))=TRIM(SUBSTR(PRDACCTID,1,8))
AND LBRCODE=BR;
RETURN V_NAME;
END T_NAME;oracle creates it without any errors
but if i use the same in the below query
error is thrown by oracle (10g) as
ORA-01422: exact fetch returns more than requested number
select lbrcode,t_name(prdacctid,LBRCODE),cbldate,balance4,rnk from
(select bal_mast.*,rank() OVER(PARTITION BY LBRCODE,PRDACCTID ORDER BY CBLDATE DESC) AS RNK
FROM bal_mast
WHERE TRIM(SUBSTR(PRDACCTID,1,8))='PL'
AND CBLDATE<='31-MAR-2010'
AND FLOOR(SUBSTR(PRDACCTID,17,24))<>0
)WHERE RNK=1
ORDER BY LBRCODE,T_NAME(PRDACCTID,LBRCODE)
/However if i change *"WHERE TRIM(SUBSTR(PRD,1,8))=TRIM(SUBSTR(PRDACCTID,1,8))"* to
WHERE PRD=PRDACCTID
it works
Please explain.......
hemu

The error message tells it all:   SELECT LONGNAME
     INTO V_NAME
     FROM ac_mast
    WHERE TRIM(SUBSTR(PRD, 1, 8)) = TRIM(SUBSTR(PRDACCTID, 1, 8)) AND LBRCODE = BR;This query returns more than one record. SELECT INTO needs exactly one record, else it throws
TOO_MANY_ROWS.
Urs

Similar Messages

  • PL/SQL report errors: ORA-01422

    Hi all,
    (before i you read i would like to say i have searched the net for this error code but nothing shows up like this problem..)
    I am getting an error problem when i select certain Schemas from a list on an apex app. page, it only works for some schemas not all..
    When i select one schema, it is supposed to display one row.. when i select [ALL] it is supposed to show them all.
    It does work if i select '[ALL]' from the select list (p3_schema_name), just not for every single individual one.
    the error code:
    ORA-01422: exact fetch returns more than requested number of rows
    declare
      vSchema  varchar2(20);
      vStmt  varchar2(1000);
      vVersion number(5);
      vDBName  varchar2(20);
      vHostName varchar2(80);
      vStmt2  varchar2(1000);
      vVersion2 number(5);
      vDBName2  varchar2(20);
      vServer2 varchar2(80);
      vSchema2 varchar2(80);
      CURSOR c_schemas IS
        select owner from dba_tables@P3_DB_NAME.db_link where table_name = 'DDL_LOG' and num_rows > 0 order by owner;
    begin
      IF :P3_SCHEMA_NAME != '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
        vServer2 := :P3_SERVER_NAME;
        vSchema2 := :P3_SCHEMA_NAME;
          vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM';
          Execute Immediate vStmt2 into vDBName2, vVersion2;
            htp.p('<br>');
            htp.p('<table border="1">');
            htp.p('<tr>');
            htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
            htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
            htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
            htp.p('<th bgcolor="#FFCC99">PATCH</th>');
            htp.p('</tr>');
            htp.p('<tr>');
            htp.p('<td>');
            htp.p(vServer2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vDBName2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vSchema2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p(vVersion2);
            htp.p('</td>');
            htp.p('<td>');
            htp.p('<BR>');
            htp.p('</td>');
            htp.p('</tr>');
            htp.p('</tr>');
            htp.p('</table>');
       ELSE IF :P3_SCHEMA_NAME = '[ALL]' AND :P3_DB_NAME IS NOT NULL AND :P3_SERVER_NAME IS NOT NULL THEN
       vHostName := :P3_SERVER_NAME;
       vDBName := :P3_DB_NAME;
         open c_schemas;
          htp.p('<br>');
          htp.p('<table border="1">');
          htp.p('<tr>');
          htp.p('<th bgcolor="#FFCC99">SERVER NAME</th>');
          htp.p('<th bgcolor="#FFCC99">DB NAME</th>');
          htp.p('<th bgcolor="#FFCC99">SCHEMA NAME</th>');
          htp.p('<th bgcolor="#FFCC99">PATCH</th>');
          htp.p('</tr>');
        LOOP
          FETCH c_schemas INTO vSchema;
          EXIT WHEN c_schemas%NOTFOUND;
          vStmt  := 'select max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link where DDH_SCHEMA_NR = (select max(DDH_SCHEMA_NR) from '||vSchema||'.ddl_log@&P3_DB_NAME.db_link) and rownum < 2' ;
          Execute Immediate vStmt into vVersion  ;
          htp.p('<tr>');
          htp.p('<td>');
          htp.p(vHostName);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vDBName);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vSchema);
          htp.p('</td>');
          htp.p('<td>');
          htp.p(vVersion);
          htp.p('</td>');
          htp.p('<td>');
          htp.p('<BR>');
          htp.p('</td>');
          htp.p('</tr>');
        END LOOP;
          htp.p('</tr>');
          htp.p('</table>');  
      CLOSE c_schemas;
    END IF;
    END IF;
    END;I have checked the DDH_SCHEMA_NR for repeating entries of the highest number.. some of the ones that dont work do have repeating entries some don't.
    Sorry if this is confusing, i have tried to explain it as best as i can.
    Thanks in advance for any help.
    Ashleigh

    Hello Ashleigh,
    Based on your code, I'd start by running this piece of SQL via command-line (thru SQL Workshop, SQL*Plus, Toad, etc.), replacing &P3_SCHEMA_NAME. and &P3_DB_NAME. with values that are currently causing the routine to fail and see if it returns more than one row. I don't know your data, but DISTINCT and GROUP BY are typically used to return multiple (though grouped/summarized) rows. It appears to be the only statement that would cause the error your seeing (more than one row being returned into single variables).
    select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from &P3_SCHEMA_NAME..ddl_log@&P3_DB_NAME.db_link GROUP BY DDH_DB_NM;I'm actually surprised that the code runs at all. I didn't think 'execute immediate' would know what to do with substitutions indicated as "&something." (I've typically seen that when substituting in dynamic HTML/Javascript code but maybe I'm learning something new). But since you already have vServer2 and vSchema2, I'd be more apt to code it as:
    vStmt2 := 'select distinct DDH_DB_NM, max(DDH_SCHEMA_NR)keep(dense_rank last order by ddh_runstart_td) AS "PATCH" from ' ||
    vSchema2 || '.ddl_log@' || vServer2 || '.db_link GROUP BY DDH_DB_NM';Hope this helps,
    John

  • Ora-00604,ora-01422 error while dropping the table

    Hi gurus,
    I am using Oracle 10g R2 on windows 2000 platform,while dropping the table the following error occured.
    ORA-00604 : error occurred at recursive sql level 1.
    ORA-01422: exact fetch returns more than requested number of rows.
    Need urgent help.
    Thanks in advance

    Is there an AFTER EVENT trigger defined on this database? Can you check that?
    Secondly, was this database migrated from earlier version? I remember having seen this problem on 9i (it was 9.2.0.1 or 9.2.0.2; I can't recall exactly).

  • PL/SQL-Error: ORA-00604 - ORA-01422 makes no sense. Any Idea anyone ?

    Problem:
    No matter if creating new or recompiling old procedures
    (that had been compiled successfully lon ago),
    I always receive the very same error message:
    ORA-00604: ...recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-at line 5 (mouse cursor blinks at teh first line of code...)
    It is the same with PLEdit, HORA and SQL*PLUS:
    even the most simple procedures are not compiled
    Hints: I encounter this problem since I installed Forms 6i.
    I am using database 8.1.7 on Redhat Linux (as a server),
    and working on a W2K client.
    Any idea anyone ?
    ThanX in advance !

    Sorry, I found my error : Trigger on Database
    Maybe others are interested too:
    Be careful when using triggers "on schema" or "on database",
    because, as I have found, the error message doesn4t say that.
    I had a few such triggers for logging purposes.
    After I disabled my database triggers, I could continue compiling.
    Bye, Jan.

  • Error message: ORA-01422:

    Hi All
    while running a package I received an error message:
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    I wrote an exception for too_many_rows , which took care of the error but my question is does the exception condition get logged anywhere?
    Thanks

    if you want to log messages to a table within your code, but not in an exception handler, then consider an autonomous transaction;
    something like this:
    SQL> create table xyz (x varchar2(500))
      2  /
    Table created.
    SQL>
    SQL> set serveroutput on
    SQL> declare
      2 
      3    p_Value number := 0;
      4   
      5    procedure Log_Msg (p_Msg in varchar2) as
      6      pragma autonomous_transaction;
      7      begin
      8        insert into xyz (x) values (p_Msg);
      9        commit;
    10        exception
    11          when others then
    12            rollback; -- always ensure a rollback or commit occurs with an autonomous proc
    13    end;
    14   
    15  begin
    16    p_Value := 10;
    17    Log_Msg ('Value is now, ' || p_Value);
    18    p_Value := p_Value*10;
    19    Log_Msg ('Value ten times more, ' || p_Value);
    20   
    21 
    22    dbms_output.put_line('Done');
    23   
    24    exception
    25      when others then
    26        dbms_output.put_line('Error ' || sqlerrm);
    27  end;
    28  /
    Done
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from xyz;
    X
    Value is now, 10
    Value ten times more, 100

  • ORA-01422- exact fetch returns more than requested number of rows in D2K Report

    Hi All,
    Greetings.
    I am using a report which is being called from the from in one of my application. The report is working fine from quiet a long time. I have an error with a particular record alone and it is working fine for all other records.
    When I try to run the report, I am getting the error as Rep-1401- 'cf_vatformula' : Fatal pl/sql error occured.
                                                                                ORA-01422- Exact fetch returns more than requested number of rows.
    I opened the formula column and run the sql codes that are used in the formula column cf_vat and all of them are working fine. None of them are fetching more a single row. But, when I run the report, I am getting the same error as mentioned above.
    Please help me resolve the issue ASAP. Thanks in Advance.
    Regards,
    Bhaskar.

    Hi InoL,
    Thanks for your time.
    I am sure that there is no other procedure used in cf_vatformula. It has select queries in and all of them are fetching the data not more than a single row.
    I have tested each and every select query with every possible output.
    Regards,
    Bhaskar.

  • ORA-01422 exact fetch returns more than requested number of rows on invoice

    Hello developer,
    Current I m facing problem ORA-01422 exact fetch returns more than requested number of rows in Invoce Standard form when we select PO_Default invoice type for some specific PO Number not for all. I m not able to handle the error bcoz im new in oracle apps. it's urgent for user requirement. Plz guide me how to take approch to handle the situation.........
    select Po_Default invoice type=>enter po number=>press ok button=>got error ORA-01422
    I got query from POST_QUERY TRIGEER like
    function get_po_number (l_po_number varchar2,l_vendor_id OUT number) return number is
    l_po_header_id number;
    --Bug fix:1096002
    --Removed the function call UPPER from the WHERE clause so that the query
    --becomes case sensitive.
    -- BUG 2519682 vendor_id added in the Select statement and futher in the fetch statement
    cursor po_number_cursor is
    SELECT po_header_id,vendor_id
    FROM po_headers
    WHERE type_lookup_code IN ('STANDARD', 'BLANKET', 'PLANNED')
    AND approved_flag = 'Y'
    AND segment1 = l_po_number
    -- Bug 2289727. Enhanced Matching Controls to Finally Closed POs
    AND (NVL(closed_code, 'X') <> 'FINALLY CLOSED'
    OR :parameter.show_final_closed_po_flag = 'Y')
    AND PCARD_ID IS NULL; --bug4627502
    /* Commented out since this is not relevant even if executed.
    AND (segment1 LIKE SUBSTR(l_po_number, 1, 2) || '%' OR
    segment1 LIKE SUBSTR(l_po_number, 1, 1) ||
    SUBSTR(l_po_number, 2, 1) || '%' OR
    segment1 LIKE SUBSTR(l_po_number, 1, 1) ||
    SUBSTR(l_po_number, 2, 1) || '%' OR
    segment1 LIKE SUBSTR(l_po_number, 1, 2) || '%' );
    begin
    open po_number_cursor;
    fetch po_number_cursor INTO l_po_header_id,l_vendor_id;
    close po_number_cursor;
    return(l_po_header_id);
    end get_po_number;
    plz help me how to resolved this issue it's urgent.
    thanks in advance.........

    This bug is documented in the following note on metalink.oracle.com
    APXINWKB - Creating PO Default Invoice Errors with ORA-01422 Exact Fetch Returns More Than Requested Number Of Rows [ID 946578.1]
    The solution is to apply patch 8765847.
    Hope this answers your question,
    Sandeep Gandhi

  • RACUST errors out - racina: ORA-01422: exact fetch returns more than reques

    Hi,
    We are using standard RACUST interface( r12, 12.0.0). All the records are successsfully validated however, the standard program errors out at run time with the following error
    racina: ORA-01422: exact fetch returns more than requested number of rows

    Pl see if MOS Doc 802175.1 (Customer Interface Creates Duplicate Party Sites Used in Multi-Org (MOAC)) can help
    HTH
    Srini

  • Error during recover datafile - ORA-01422: exact fetch returns more than ..

    Hi,
    we have got actual a serious problem in our database. Some days ago we created a new datafile for a tablespace in the wrong directory:
    ALTER TABLESPACE "ANZSIIDX" ADD DATAFILE '/oralunadata/anzora8/ANZSIIDX08.dbf' SIZE 500M
    We recognized our mistake and generated the datafile with the same name in teh right directory:
    ALTER TABLESPACE "ANZSIIDX" ADD DATAFILE '/oralunaindex/anzora8/ANZSIIDX08.dbf' SIZE 500M
    We set the "wrong" datafile offline in order to rename and replace this in file in the right directory:
    alter database datafile '/oralunadata/anzora8/ANZSIIDX08.dbf' offline;
    ALTER TABLESPACE 'ANZSIIDX'
    RENAME DATAFILE '/oralunadata/anzora8/ANZSIIDX08.dbf',
    TO '/oralunaindex/anzora8/ANZSIIDX09.dbf';
    After this we wanted to bring the datafile online again with a recovery but
    this fails with teh strange error-message:
    SQL> recover datafile 109;
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 20
    ORA-00279: change 10322956311023 generated at 04/10/2013 18:51:23 needed for
    thread 1
    ORA-00289: suggestion : /oralunaarchiv/anzora8/anzora8_1_315326_636567403.arc
    ORA-00280: change 10322956311023 for thread 1 is in sequence #315326
    A similar thing happens with our RMAN backup from last weekend, which failed:
    channel c4: backup set complete, elapsed time: 00:32:33
    input datafile fno=00109 name=/oralunadata/anzora8/ANZSIIDX08.dbf
    input datafile fno=00103 name=/oralunaindex/anzora8/ITOPROTOKOLLEIDX01.dbf
    input datafile fno=00097 name=/oralunadata/anzora8/ITOPROTOKOLLE03.dbf
    input datafile fno=00096 name=/oralunadata/anzora8/ITOPROTOKOLLE02.dbf
    channel c4: specifying datafile(s) in backupset
    channel c4: starting compressed incremental level 0 datafile backupset
    continuing other job steps, job failed will not be re-run
    ORA-00600: internal error code, arguments: [krbbfmx_notfound], [109], [12801], [], [], [], [], []
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-00604: error occurred at recursive SQL level 1
    Has anybody an idea, how can we bring back the datafile online in order to run succesfull an RMAN backup?
    Actually we see just the workaraound to move the objects from the affected tablespace to new tablespace
    and the drop the empty tablespace what would be quite time consuming and not really practicable for us.
    kind regards,
    Marco

    Hi,
    actual we see this in v$datafile:
    /oralunaindex/anzora8/ANZSIIDX01.dbf     15     ANZSIIDX     10737418240     1310720     AVAILABLE     15     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX02.dbf     46     ANZSIIDX     10737418240     1310720     AVAILABLE     46     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX03.dbf     58     ANZSIIDX     10737418240     1310720     AVAILABLE     58     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX04.dbf     65     ANZSIIDX     10737418240     1310720     AVAILABLE     65     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX05.dbf     78     ANZSIIDX     10737418240     1310720     AVAILABLE     78     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX06.dbf     85     ANZSIIDX     10737418240     1310720     AVAILABLE     85     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX07.dbf     88     ANZSIIDX     10737418240     1310720     AVAILABLE     88     NO     0     0     0     10737352704     1310712     ONLINE
    /oralunaindex/anzora8/ANZSIIDX09.dbf     109     ANZSIIDX               AVAILABLE     109                                   RECOVER
    /oralunaindex/anzora8/ANZSIIDX08.dbf     110     ANZSIIDX     10737418240     1310720     AVAILABLE     110     NO     0     0     0     10737352704     1310712     ONLINE
    We dont use RMAN-Catalog for backup the information is only stored in the controlfile.
    The recovery datafile command with full path including for the datafile failed with the same error message:
    SQL> connect / as sysdba
    Connected.
    SQL> recover datafile '/oralunaindex/anzora8/ANZSIIDX09.dbf';
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 20
    ORA-00279: change 10322956311023 generated at 04/10/2013 18:51:23 needed for
    thread 1
    ORA-00289: suggestion : /oralunaarchiv/anzora8/anzora8_1_315326_636567403.arc
    ORA-00280: change 10322956311023 for thread 1 is in sequence #315326
    I guess it is a bug of oracle which will sometimes occur when you give two datafiles the same name in different directories that this poduces errors as above in the RMAN inerface(packages)!?
    Maybe we could force to set he tablespace offline, rename the new added datafiles and ry to bring the tablespace online but nobody knows if it works really and we get the tablespace online again?
    Therefore at the moment maybe it's the best way to move the objects away from this tablespace and than drop them, isn't it?
    regards,
    Marco

  • ORA-01422,,, Very Strange Error in my code!!!

    Dear,
    I need your help please,,,
    I have the below code in a database package which always throws (ORA-01422)
    SELECT (NVL(amount,0) - NVL(cash_disc,0)) INTO v_bill_amount
    FROM pac_bills
    WHERE pac_bills.bill_no = v_bill_no AND pac_bills.bill_type = 3;
    Now when I execute this code I get (ORA-01422) for v_bill_no = 207000003. when I execute same statement from TOAD or SqlPlus IT RETURN ONE ROW ONLY!!! for same bill_no
    This error make me mad and I need any help

    I would try to see what extra rows are selected in the pacakage. If it's a database package then it could be something like this:
    /* Temp table to register selected rows */
    CREATE TABLE Tmp_Debug(
      TS TIMESTAMP, /* to identify different statement executions */
      bill_no INTEGER,
      r ROWID
    /* DEBUG fragment to be inserted into the package */
    DECLARE
      PROCEDURE Trace(
        p_bill_no INTEGER
      ) IS
        PRAGMA AUTONOMOUS_TRANSACTION;
      BEGIN
        INSERT INTO Tmp_Debug(ts, bill_no, r)
          SELECT systimestamp, p_bill_no, (NVL(amount,0) - NVL(cash_disc,0))
          FROM pac_bills
          WHERE pac_bills.bill_no = p_bill_no AND pac_bills.bill_type = 3;
        COMMIT;
      END;
    BEGIN
      /* Original select */
      SELECT (NVL(amount,0) - NVL(cash_disc,0)) INTO v_bill_amount
      FROM pac_bills
      WHERE pac_bills.bill_no = v_bill_no AND pac_bills.bill_type = 3;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        Trace(v_bill_no);
    END;
    /* End of DEBUG fragment */Reproduce the error and see in Tmp_Debug, what rows are actually selected. Sure I didn't test it.
    If it's a forms package then you may implement some debug form or something else to see the actually selected rows.
    One more thought: is it possible that app logic produces extra rows? They are not commited and rolled back after the error, this is why you can't see them in TOAD/Sql*Plus.
    Regards,
    Dima.

  • Filling datarows before creating a new record  frm-40735 ora-01422

    Hello
    I want to create a user-control table where I Store in the Mastertable the user informations. in the 2 detail tables I store the programmnames of the first level, in the second table I store the name of the form and if the user is allowed to insert, amend or delete.
    I use a Master/2 Detail-Form. When I create a new record in the master block, I want to fill in the first and second detail block, informations of another user of the 2 detail tables. therefore I created a when-new-block-instance trigger with the following code:
    select programm
    into :k_zugriff.Programm
    from k_zugriff, K_benutzer
    where r_benutzer_zaehler=k_benutzer.zaehler
    and oracle_user='ROBERT';
    because this sql serves more than one row I receive the error code frm-40735 ora-01422
    so how could I solve the problem to insert 5-10 rows in :k_zugriff.Programm. I can not make an insert before I go to the block k_zugriff, because the user number is not commited known. Also I want to commit the form when all informations are filled in. in case of a mistake I want to exit the form with no commit;
    has anyone a usefull Idea?
    regards
    robert

    it works thank you. where can I get further information about this technik. are there any turtorials or something where I get information how to build this complex forms??
    right statement
    DECLARE
    CURsOR cr IS
    select programm
    from k_zugriff, K_benutzer
    where r_benutzer_zaehler=k_benutzer.zaehler
    and oracle_user='ROBERT';
    BEGIN
    FOR rec IN cr LOOP
    IF :SYSTEm.RECOrD_STATUS!='NEW' THEN
    CREATE_RECORD;
    END IF;
    :k_zugriff.Programm:=rec.PROGRAMM;
    END LOOP;
    END;

  • ORA-00604/ORA-01422/ORA-06512 Error on trigger

    Hi,
    I have an database which is of version 10.2.0.3.0 on Enterprise Edition.
    I want to restrict a user from usage of an schema . Therefore i have written a trigger but i have encountered with another errors:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 5
    Trigger Being::
    SQL> create or replace trigger session_access
    2 after logon on database
    3 declare
    4 v_username varchar2(30);
    5 v_osuser varchar2(30);
    6 begin
    7 select username,osuser into v_username,v_osuser from v$session;
    8 if v_username = 'SUSANJO' and v_osuser= 'ORACLE' then
    9 raise_application_error (-20001,'Access restricted for this USER');
    10 end if;
    11 end;
    12 /
    Trigger created.
    SQL> show errors;
    No errors.
    SQL> connect susanjo
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 5
    Warning: You are no longer connected to ORACLE.
    i have run out of ideas of whats to be done onto the trigger now.
    Regards.
    Susan John

    Um , i have implemented the following pl/sql. It seem to kick the person out BUT (now this is a big BUT) within the grid control it mentions :
    Details          Failed to connect to database instance: ORA-00604: error occurred at recursive SQL level 1.
    create or replace trigger session_access
    DECLARE
    v_username sys.v_$session.username%type;
    v_osuser sys.v_$session.osuser%type;
    BEGIN
    select s.username ,s.osuser into v_username,v_osuser
    from v$session s where s.username='SUSANJO' and s.osuser='oracle';
    IF (v_username ='SUSANJO' AND V_OSUSER='oracle' )
    THEN
    RAISE_APPLICATION_ERROR(-20001, 'You are not allowed to login using the program');
    END IF;
    END session_access;
    Output :
    SQL*Plus: Release 10.2.0.3.0 - Production on Mon Mar 23 12:36:43 2009
    Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning and Data Mining options
    SQL> connect susanjo
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: You are not allowed to login using the program
    ORA-06512: at line 10
    Warning: You are no longer connected to ORACLE.
    SQL>
    I did conduct a research which was not all that helpful too. So i am back to square one again.
    regards
    Susan John

  • URGENT IN The PL/SQL code..ORA-01422: exact fetch returns more than request

    Hi All,
    I am using the Oracle Streams to replicate the data...
    Below is the procedure
    CREATE OR REPLACE PROCEDURE proc_test(in_any sys.anydata)IS
    lcr sys.lcr$_row_record;
    rc pls_integer;
    v_type varchar2(20);
    col_1 sys.anydata;
    lcr_usercountry varchar2(20);
    TRANS varchar2(20);
    BEGIN
    rc:=in_any.GetObject(lcr);
    v_type:=lcr.get_command_type();
    col_1:=lcr.get_value('NEW','USER_COUNTRY');
    rc:=col_1.GetVarchar2(lcr_usercountry);
    select user_country into TRANS from test.TESTREP where USER_COUNTRY=lcr_usercountry;
    IF (TRANS=lcr_usercountry and TRANS='USA')
    THEN
    insert into strmadmin.history_row_lcrs VALUES (SYSDATE, lcr.GET_SOURCE_DATABASE_NAME(), lcr.GET_COMMAND_TYPE(),
    lcr.GET_OBJECT_OWNER(), lcr.GET_OBJECT_NAME(), lcr.GET_TAG(), lcr.GET_TRANSACTION_ID(), lcr.GET_SCN(),
    lcr.GET_COMMIT_SCN,lcr.GET_VALUES('old'), lcr.GET_VALUES('new', 'n'));
    lcr.EXECUTE(true);
    END IF;
    END;
    The procedure executed successfully, but the data is not replicating...
    I get the below error ORA-01422: exact fetch returns more than request in the dba_apply_error view.... because the query in the above procedure which am using returns more than one value ...select user_country into TRANS from test.TESTREP where USER_COUNTRY=lcr_usercountry;
    may be I need to use the cursor for this....
    Can anyone Please advice me writing the cursor ...
    Thanks in Advance..

    Got the solution ....
    Thanks..

  • ORA-01422: exact fetch returns more than requested number of rows in R12

    Hi All,
    Getting the below error in custom report of purchasing.
    REP-1401: 'afterpform': Fatal PL/SQL error occurred.
    ORA-01422: exact fetch returns more than requested number of rows
    To overcome this error I have added some exceptional handling as per below and the report is completed with Normal with output but the ouput is repeating in 150 pages in R12 but the same output in 11i showing only one page. Please advise.
    when no_data_found then
                 :P_po_num_type := 'ALPHANUMERIC'; 
            when too_many_rows then
                 :P_po_num_type := 'ALPHANUMERIC';
            when others then
                 :P_po_num_type := 'ALPHANUMERIC';
    Regards,
    Sushant

    You need to rewrite your query for R12 based on new architecture as 11i report will not work as it is.
    thanks

  • Problem with the ORA-01422

    Hello friends, tell you that I have a problem create me a function that is as follows:
    - 1 part
    Create or replace function Generar_correo1(a varchar, b varchar, NOMU varchar, f date) return varchar as
    dd varchar(5); mm varchar(5); aa varchar(5); correo varchar(335); reversed_string varchar(100); c char(1); i number; begin select extract(day from f) into dd from dual; select extract(month from f) into mm from dual; select extract(year from f) into aa from dual; reversed_string:=' '; – para invertir una cadena * for i in 1..length(a) loop select substr(a,length(a)-i+1,1) into c from dual; end loop; –* correo:=substr (c,1,2)||substr(b,1,1)||aa||substr(NOMU,1,length(NOMU))||'@hotmail.com'; return correo; end;
    –2 part
    declare cor varchar(400); begin select Generar_correo1(F.IdFuncionario,C.IdCargo,U.NombreUnidad,F.Fechanacimiento) into cor from Funcionario F, Cargo C, Unidad U where F.IdCargo=C.IdCargo and F.IdUnidad=U.IdUnidad; dbms_output.put_line(cor); end;
    and when I run the 2 part, gives me the following problem:
    ORA-01422: the exact recovery returns more rows than the requested
    Please help. Thank you in advance for your help
    alejandro

    Hi, Alejandro,
    Welcome to the forum!
    You'll find that there are are many people who will try as hard as they can to help you.
    Please try as hard as you can to help them.
    When you post code, format it to make it easier to read and understand. When you post any formatted text on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted text.
    A SELECT ... INTO query must return exactly one row.  If it produces more than one row, you get the ORA-01422 error.
    If you need to read more (or less) than one row, you can use a cursor instead.
    What are you trying to do in Part 2?  Do you just want to test the function Generar_correo1?
    You don't need a PL/SQL for that; just write a query:select      Generar_correo1 ( F.IdFuncionario
              , C.IdCargo
                   , U.NombreUnidad
                   , F.Fechanacimiento
    from      Funcionario      F
    ,      Cargo           C
    ,      Unidad           U
    where      F.IdCargo     = C.IdCargo
    and      F.IdUnidad     = U.IdUnidad;
    Notice that this is just what you posted, without PL/SQL and INTO.  Which do you think is easier to read and unerstand?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Getting Error ORA-01422&ORA-06512 while clicking distributions of invoice

    Hi,
    I am Getting Error ORA-01422&ORA-06512 when i query the invoice and click on the All distributions.
    However i am getting this error only for some invoices and not for all.
    Any suggestion on this is highly appreciated.
    Regards,
    Shreyans

    Hi,
    What is the application release? If you are on R12, please refer to these documents.
    Note: 580014.1 - R12 Invoices FAQs - (16. Why do the Errors ORA-01422 and ORA-06512 Show when Clicking on the [All Distributions] Button?)
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=580014.1
    Note: 559199.1 - Error ORA-01422 ORA-06512 Raises when Click On [All Distributions] Button
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=559199.1
    Regards,
    Hussein

Maybe you are looking for

  • "Save As" in created PDF

    Hello everyone, I am fairly new to using LiveCycle Designer. I've got about a week of experience under my belt here, and I've made a few different PDF forms. One in particular, is a 2 page form that will be used by my co-workers as a general work for

  • Elimination of Duplicates in Library?

    I'm a newbie and have managed to copy duplicates of photos into my iPhoto main library. Is there a simple process for mass-identification and elimination of such duplicates for the entire library? Thanks, David

  • PI Sender JMS channel not reading data

    Hello All, Scenario is JMS to Proxy. I have configured the JMS PI sender channel as per the details given by legacy team and they validated and confirmed that the channel configuration is correct. Also PI JMS Sender channel is with green status and n

  • Web Dynpro based Workflow Inbox.

    Hi All. Can someone help me with this post. http://scn.sap.com/community/bpm/business-workflow/blog/2013/11/02/dear-sap-why-are-the-existing-webdynpro-based-workflow-inboxes-not-working-out-of-the-box I have posted my query at the end of this post lo

  • No Sound on iPhoto or Quick Time

    I have moved to OS Yosemite and the following issue has occurred. My video clips on iPhoto run fine , but there is no sound with the video or ant volume slider on the video. I have used going back to Finder and playing the video back on Quick time, b