ORA-01422 error

Hello,
I am very new about oracle and I have a problem. I am using stored procedure like this;
CREATE OR REPLACE PROCEDURE SP_SELECTKISIBYUSERNAME
MY_AD OUT VARCHAR2,
MY_SOYAD OUT VARCHAR2,
MY_KULLANICIADI OUT VARCHAR2,
MY_SCLNO OUT NUMBER,
KullaniciAdi IN VARCHAR2
AS
BEGIN
SELECT IKY_OZLUK.SCLNO, IKY_OZLUK.AD, IKY_OZLUK.SOYAD, IKY_KULLANICI.KULLANICIADI INTO MY_SCLNO,MY_AD,MY_SOYAD,MY_KULLANICIADI
     FROM IKY_KULLANICI , IKY_OZLUK
     WHERE IKY_KULLANICI.SCLNO=IKY_OZLUK.SCLNO
     AND IKY_KULLANICI.KULLANICIADI = KullaniciAdi;
END;
I call the procedure from visual studio .net. the code I used is:
internal DataSet SelectAdSoyad(string KullaniciAdi)
               OracleConnection connection=new OracleConnection(connectionString);
               connection.Open();
               OracleCommand command=new OracleCommand();
               command.Connection=connection;
               command.CommandText="SP_SELECTKISIBYUSERNAME";
               command.CommandType=CommandType.StoredProcedure;
               OracleParameter inputParameter;
               OracleParameter outputParameter;
               outputParameter=command.Parameters.Add("MY_AD",OracleType.VarChar,20);
               outputParameter.Direction=ParameterDirection.Output;
               outputParameter=command.Parameters.Add("MY_SOYAD",OracleType.VarChar,20);
               outputParameter.Direction=ParameterDirection.Output;
               outputParameter=command.Parameters.Add("MY_KULLANICIADI",OracleType.VarChar,8);
               outputParameter.Direction=ParameterDirection.Output;
               outputParameter=command.Parameters.Add("MY_SCLNO",OracleType.Number,5);
               outputParameter.Direction=ParameterDirection.Output;
               inputParameter=command.Parameters.Add("KULLANICIADI",OracleType.VarChar,8);
               inputParameter.Direction=ParameterDirection.Input ;
               inputParameter.Value=KullaniciAdi;
               OracleDataAdapter dataAdapter=new OracleDataAdapter();
               dataAdapter.SelectCommand=command;
               dataAdapter.TableMappings.Add("Table","KULLANICI");
               DataSet dataSet=new DataSet();
               dataAdapter.Fill(dataSet);
               return dataSet;
and on the page_load of default.aspx I used the code;
private void Page_Load(object sender, System.EventArgs e)
               // Put user code to initialize the page here
               string searchString;
               string userName;
               int myPos;
               searchString =Request.ServerVariables["Remote_User"];
               myPos = searchString.IndexOf(@"\");
               myPos = (myPos + 1);
               userName=(searchString.Substring(myPos)).Trim();
               clsMI kisiUserName=new clsMI();
               DataSet dsMaster=kisiUserName.SelectAdSoyad(userName);
               Response.Write(dsMaster.Tables["KULLANICI"].Rows[0]["MY_SCLNO"].ToString());
the code is returning the error;
ORA-01422: exact fetch returns more than requested number of rows ORA-06512: pozition "TUBPER.SP_SELECTKISIBYUSERNAME", line 14 ORA-06512: position line 1
The question I want to ask is this;
I run the query part of the procedure in the sql plus (of course with variable)
SQL> SELECT IKY_OZLUK.SCLNO, IKY_OZLUK.AD, IKY_OZLUK.SOYAD, IKY_KULLANICI.KULLANICIADI
2 FROM IKY_KULLANICI , IKY_OZLUK
3 WHERE IKY_KULLANICI.SCLNO=IKY_OZLUK.SCLNO
4 AND IKY_KULLANICI.KULLANICIADI = 'etufan';
SCLNO AD SOYAD KULLANIC
62066 EMRAH TUFAN etufan
SQL>
as you can see, there is only one row returns.
So what is the problem.

Ok,
The error message 'ORA-01422: exact fetch returns more than requested number of rows ORA-06512: pozition "TUBPER.SP_SELECTKISIBYUSERNAME", line 14 ORA-06512: position line 1' is telling you that the select statement is returning more than one row, when you're doing a SELECT ... INTO. It also tells you where (line 14).
Your later sqlplus example shows that one row should be returned if the IN parameter, KullaniciAdi = etufan. This suggests that whatever you are passing in, it isn't etufan.
If you're using Visual Studio you should be able to debug this section
searchString =Request.ServerVariables["Remote_User"];
myPos = searchString.IndexOf(@"\");
myPos = (myPos + 1);
userName=(searchString.Substring(myPos)).Trim(); and find out what userName actually is. (I would look carefully at @"\" as a backslash is an escape character).
The oracle part I suggested is a standard way to catch these sort of errors. Essentially you wrap up a statement that might fail in a BEGIN...END block, and the EXCEPTION part allows you to do something when the statement fails.
try
BEGIN
SELECT IKY_OZLUK.SCLNO, IKY_OZLUK.AD, IKY_OZLUK.SOYAD, IKY_KULLANICI.KULLANICIADI INTO MY_SCLNO,MY_AD,MY_SOYAD,MY_KULLANICIADI
FROM IKY_KULLANICI , IKY_OZLUK
WHERE IKY_KULLANICI.SCLNO=IKY_OZLUK.SCLNO
AND IKY_KULLANICI.KULLANICIADI = KullaniciAdi;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
insert into error_table (message)
values('parameter = ' || KullaniciAdi);
END
Obviously you need to create error_table with a suitable message column, but it will show you what was being passed into the procedure.
alternatively you have some output parameters where you could put the results to diagnose the problem;
the EXCEPTION clause could be
EXCEPTION
WHEN TOO_MANY_ROWS THEN
MY_AD := KullaniciAdi,
END;
You could extend that to put the result of a
SELECT COUNT(1) FROM
FROM IKY_KULLANICI , IKY_OZLUK
WHERE IKY_KULLANICI.SCLNO=IKY_OZLUK.SCLNO
AND IKY_KULLANICI.KULLANICIADI = KullaniciAdi;
and put the result into MY_SCLNO, so you could work with them in your .NET application.
Hope that's some ore help.

Similar Messages

  • 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).

  • Getting ORA-01422 Error in stored procedure

    ORA-01422: exact fetch returns more than requested number of rows
    This page explains the error:
    http://www.techonthenet.com/oracle/errors/ora01422.php
    This is my procedure:
    The select into clause is what's causing the error. I understand the nature of the error, but the strange thing is that when i execute the sql, removing the 'into'
    part with my test-parameters I just receive a single row. Still when I execute my procedure with the same parameters I get the error. What could be wrong?
    create or replace
    PROCEDURE COUNTER_GETACTIVE
    METERPOINTID IN MeterPointCounters.MeterPointId%Type,
    METERPOINTCOUNTERNR IN METERPOINTCOUNTERS.METERPOINTCOUNTERNR%type,
    p_cursor out REFCURSOR_PKG.counter_cursor
    IS
    l_counterNr CounterBridgeTable.CounterNr%type;
    l_meterId CounterBridgeTable.MeterId%type;
    BEGIN
    select counternr, meterid into l_counterNr, l_meterId from CounterBridgeTable where meterpointid = METERPOINTID and meterpointcounternr = METERPOINTCOUNTERNR and datetom is null;
    open p_cursor for select * from counters where counternr = l_counterNr and meterId = l_meterId;
    END COUNTER_GETACTIVE;

    You are actually running this query
    select counternr, meterid from CounterBridgeTable where meterpointid = METERPOINTID and meterpointcounternr = METERPOINTCOUNTERNR and datetom is null;the param name is the same as the column, it is ignoring your param and pretty much doing a self join
    try this:
    create or replace
    PROCEDURE COUNTER_GETACTIVE
    p_METERPOINTID IN MeterPointCounters.MeterPointId%Type,
    p_METERPOINTCOUNTERNR IN METERPOINTCOUNTERS.METERPOINTCOUNTERNR%type,
    p_cursor out REFCURSOR_PKG.counter_cursor
    IS
    l_counterNr CounterBridgeTable.CounterNr%type;
    l_meterId CounterBridgeTable.MeterId%type;
    BEGIN
    select counternr, meterid into l_counterNr, l_meterId from CounterBridgeTable where meterpointid = p_METERPOINTID and meterpointcounternr = p_METERPOINTCOUNTERNR and datetom is null;
    open p_cursor for select * from counters where counternr = l_counterNr and meterId = l_meterId;
    END COUNTER_GETACTIVE;Edited by: tanging on Jun 8, 2010 10:37 AM

  • ORA-01422 Error While Doing Insert

    Hello,
    I am trying to do a insert using the following code
    declare
    i number;
    ret varchar2(1000);
    ret2 varchar2(1000);
    ret3 varchar2(1000);
    begin
    FOR I IN 1..20 LOOP
    select sl_no ,ename,addr into ret,ret2,ret3
    from
    (select u.sl_no as sl_no,
    (select ename from table where sl=1  and des  = 1 ) as ename ,
    T.addr as addr  from
    tab1 t,tab2  u
    where
    U.cd = T.cd
    and U.code = T.code and U.sl=0+i
    union all
    select u.sl_no as sl_no,
    (select ename from table where sl=1  and des  = 1 ) as ename ,
    T.addr as addr  from
    tab1 t,tab2  u
    where
    U.cd = T.cd
    and U.code = T.code and U.sl=0+i);However I am getting error
    ORA-01422: exact fetch returns more than requested number of rowsHow could I resolve this problem
    Thanks

    @OP,
    Some of the points in your "FULL CODE".
    1.You are selecting in a FOR I 1..20 LOOP... The SELECT statement has INTO clause. With UNION (ALL) may be you are expecting (and getting) more than one row in which case you need to define cursor and fetch from the cursor .
    2. You have a COMMIT within the loop, it may be ok if you want to commit 20 times! In general, Please commit when the logical unit of work (LUW) is completed. In my experience LUW is normally not completed within a loop.
    3. Why even have a LOOP and PL/SQL procedural code?
    Why not do the following...
    insert into my_table(sl_no,ename,addr)
    select sl_no ,ename,addr into ret,ret2,ret3
         from
         (select u.sl_no as sl_no,
         (select ename from table where sl=1  and des  = 1 ) as ename ,
         T.addr as addr  from
         tab1 t,tab2  u
         where
         U.cd = T.cd
         and U.code = T.code and U.sl=0+i
         union all
         select u.sl_no as sl_no,
         (select ename from table where sl=1  and des  = 1 ) as ename ,
         T.addr as addr  from
         tab1 t,tab2  u
         where
         U.cd = T.cd
         and U.code = T.code and U.sl=0+i);4. If you absolutely have to have PL/SQL code try something like folloing...
    declare
    i number;
    ret varchar2(1000);
    ret2 varchar2(1000);
    ret3 varchar2(1000);
    begin
    FOR I IN 1..20 LOOP
      FOR x in (              -- "Added"
         select sl_no ,ename,addr into ret,ret2,ret3
         from
         (select u.sl_no as sl_no,
         (select ename from table where sl=1  and des  = 1 ) as ename ,
         T.addr as addr  from
         tab1 t,tab2  u
         where
         U.cd = T.cd
         and U.code = T.code and U.sl=0+i
         union all
         select u.sl_no as sl_no,
         (select ename from table where sl=1  and des  = 1 ) as ename ,
         T.addr as addr  from
         tab1 t,tab2  u
         where
         U.cd = T.cd
         and U.code = T.code and U.sl=0+i)
       LOOP ;                -- "Added"
       insert into my_table(sl_no,ename,addr)
       values (ret,ret2,ret3);
    end loop;               -- "Added"
    commit;
    end loop;
    end;vr,
    Sudhakar B.

  • Error frm-40735 ora-01422

    Hi,
    I have two tables:
    dept(
    dept_name VARCHAR2(10),
    dept_info VARCHAR2(10),
    CONSTRAINT dept_pk PRIMARY KEY (dept_name)
    location(
    loc_name VARHCHAR2(10),
    loc_info VARCHAR2(10),
    dept_name VARCHAR2(10),
    CONSTRAINT loc_pk PRIMARY KEY (loc_name),
    CONSTRAINT loc_fk FOREIGN KEY (dept_name)
    REFERENCES dept (dept_name)
    dept has the values ('dname1', 'dinfo1'), ('dname2', 'dinfo2'), ('dname3', 'dinfo3')
    location has the values ('locname1', 'dname1', 'linfo1'), ('locname2', 'dname2', 'linfo2'), ('locname3', 'dname2', 'linfo3'), ('locname4', 'dname3', 'linfo4'), ('locname5', 'dname3', 'linfo5'),
    I have a data block based on the location table. I also have a command button with the WHEN-BUTTON-PRESSED trigger:
    BEGIN
    SELECT loc_name, loc_info
    INTO :DATABLOCK.LOC_NAME, :DATABLOCK.LOC_INFO
    FROM location
    WHERE dept_name = :DATABLOCK.DEPT_NAME;
    END;
    If I try to do a search for a dept_name that has only one value in location, the Form will work properly and retreive that row. However, if I do a search for a dept_name that has two or more values in the table, I get the FRM-40735 ORA-01422 ERROR. I can tell that the Form will not allow me to retreive more that one row at a time, but what is a way that I can retreive more than one row at a time? I have set the datablock to Tabular and display 10 records, so it could retrieve the right amount of rows. Please help.

    I have a data block based on the location table.So do you want to show all the locations in that block which match the given DEPT_NAME ?
    If your block is based on the location-table you would just set the WHERE-condition on that block and do a requery, there is no cursor needed for that, so try the following code in your WHEN-.BUTTON-PRESSED-trigger.
    SET_BLOCK_PROPERTY('LOCATION', ONETIME_WHERE, 'dept_name=' || DATABLOCK.DEPT_NAME);
    EXECUTE_QUERY;If you have to use a select to do something other with the result than populating the block, then for a select returning more than one row, you have to use a cursor, something like:
    DECLARE
      CURSOR crDept IS
        SELECT loc_name, loc_info
          FROM location
        WHERE dept_name = :DATABLOCK.DEPT_NAME;
    BEGIN
      FOR rec IN crDept LOOP
        IF :SYSTEM.RECORD_STATUS!='NEW' THEN
          CREATE_RECORD;
        END IF;
        :DATABLOCK.LOC_NAME:=rec.LOC_NAME;
        :DATABLOCK.LOC_INFO:=LOC_INFO;
      END LOOP;
    END;

  • Oracle error - ORA-01422

    I am getting ORA-01422 error while updating my databse from a given user. This error is coming only while an update is done.
    Any suggestions!!!

    I've had a problem like this, ora 1403 on update and Oracle said me than there is a bug, the 892342; I've installed the patch 6a per the dev/2k and the patch 80522 for the database (client site) and now the situation is not bad, but I'm not sure the problem is solved.
    null

  • 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?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • ORA-01422: Exact fetch returns more than requested no of rows

    Hi experts.
    There is on requeter and one Supervisor to approve the request. But if see the errors in Workflow Administration Web Applications,see the above error message. How come this error message, if i have one approver in the notication process.That is: the wf_notification sending multiple notifications from single activity in the loop.
    Any idea?????
    Thx

    It is a problemin workflow Notification.
    Refer to:
    OM QUOTE APPROVAL: WF_NOTIFICATION.SEND ERRORS WITH ORA-01422 [ID 1078855.1]
    ORA-01422 error happens in wf_notification.send when multiple notifications are sent from single activity in loop. The query which returns more than one row is in WF_NOTIFICATION.send
    Mehdi

  • ORA-01422: -LISTAGG function

    HI,
    I'm using listagg function in my query which returns only one row if I run the query butwhich i create a procedure with same query and select into statement,it showing error-exact fetch returns more than.. error...
    Please help me in resolving this
    Regards
    Aswathy

    AswathyJK wrote:
    CREATE OR REPLACE PROCEDURE get_user (
    type_of_email   IN     VARCHAR2,
    user_name          OUT VARCHAR2)
    IS
    user_data   VARCHAR2 (3000) := 0;
    ret         NUMBER (5);
    --type_email constant varchar2(300);
    BEGIN
    SELECT LISTAGG (firstname || ' ' || lastname, ',')
    WITHIN GROUP (ORDER BY firstname)
    INTO user_data
    FROM user_dummy
    WHERE type_of_email = UPPER (type_of_email)
    GROUP BY type_of_email;
    user_name := user_data;
    DBMS_OUTPUT.put_line ('User Name :' || user_name);
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('EXCEPTION:' || SQLERRM);
    ret := SQL%ROWCOUNT;
    DBMS_OUTPUT.put_line ('COUNT:' || ret);
    END get_user;if i execute this plsql,i'm getting the ORA-01422 error but if irun the sql,i'm getting only one row.
    please help
    Edited by: AswathyJK on Apr 15, 2013 2:24 AMSo now you want me to guess what would be in USER_DUMMY, did you try reading the link i posted above? That could save lot of your time.

  • From clause query works ok in form designer,  gets an ORA-01422 ran on web

    I am using forms 6i patch 9 with 10g database.
    I have two ‘FROM clause queries’ fired via a block/key-exeqry trigger in a if/elsif.
    The first/top SET BLOCK PROPERTY works perfect and populates the block.
    But the bottom/second SET BLOCK PROPERTY select (after the elsif)
    Is also based on a user entered field value and generates a ora-01422 error.
    The problem is that both top and bottom set block properties
    work fine when ran in forms designer,
    But when I compile it on the app_server and run the web version
    1. the top all ‘FROM clause query’ works fine
    2. the bottom ‘FROM clause query’ works fine if only one record to return.
    3. the bottom ‘FROM clause query’: gets the ora-01422 if > 1 record to return.
    FRM-40735: KEY–EXEQRY trigger raised unhandled exception ORA-01422
    The ORA-01422: ‘Exact fetch returned more than the exact number of rows’.
    Both set block property selects ‘share’ a block property/where clause of FAC_ID = :FACILITIES.ID
    The entered value in the entry field should populate 1 to many associated records
    in the bottom (elsif) set block property (and does so correctly when ran in forms designer)
    The block’s key-exeqry code:
    –-query all records associated with fac_id only
    if (:emission_stacks.stack_id_num is null) then
         SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID,A.FAC_ID,A.NUM,A.DESCRIPTION,C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL)');
    EXECUTE_QUERY;
    elsif
    (:emission_stacks.stack_id_num is not null) then
    –-(query all records associated with fac_id and the entry field value)
    SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID, A.FAC_ID, A.NUM, A.DESCRIPTION, C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C,
    STACKS S
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.STACK_ID = S.ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL AND
    S.NUM = '''||:emission_stacks.stack_id_num||''')');
    EXECUTE_QUERY;
    ** I have multiple database items in the block.
    Data block properties:
    Database/
    Data Base Block = Yes
    Query Allowed= Yes
    Is there a way to overcome the ora-01422?
    And populate the block with multiple rows(records)?
    Any suggestions appreciated.

    Sorry, false alarm, I made a mistake
    the form is working fine the way it should,
    without error. (No ora-01422 errror is occurring now.)
    I just got a new version of humming bird,
    which I used to compile the form with
    and did not have the binary switch on:
    --long story short, a new fmx was not created
    and I was not seeing the current version of screen
    at runtime.
    Thank you.

  • 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

  • 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

  • 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

Maybe you are looking for

  • Reg:creation of condition records

    hi mm gurus, my doubt is,,,,,, using the transaction code MEK1, what condition types will maintaind in as a record ( generally), and where these records will reflect. i have created one gross price record for a material , vendor combination with plan

  • Tab canvas on a content Canvas

    Hi, I need to put a tab canvas on a content canvas in 10g R2. and have items from the same data block distributed across the canvases. I have set them up with the appropriate viewport for the tab canvas, but at runtime, the tab canvas does not appear

  • Enabling -fstack-protector-strong in makepkg.conf?

    A little more than a year ago Google submitted a patch which added a -fstack-protector-strong option which was intended to strike a balance between -fstack-protector (used in Arch) and -fstack-protector-all which was considered too computationally ex

  • How put a border round a table row?

    I have a simple table, and want to put a border round each row - for some reason nothing I do works.  I would also like a large space between rows than between the individual cells but again can't work out how to do it. Can anyone help?

  • A different quiestion about SATA (length, degree, etc.)

    My SATA cable going into the 'B' (secondary) hard drive is damaged. The pins inside the female connector are mangled and rendered useless. I've contacted Apple to get a replacement cable but they said they can't get one as they don't have a part numb