Solved

FRM-40735:KEY-COMMIT trigger raised unhandled exception ORA-01422

Posted on 2016-11-14
7
52 Views
Last Modified: 2016-11-15
hi am having this error when saving this is my block
 BEGIN
        select emp_adress,
               emp_name,
               emp_surname,
        into   ws_address,
               ws_name,
               ws_surname
        from   employee
        where  empid    = :p_empid      and
               (empacc  = :p_accnr or
                idno    = :p_idno);
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
             message('Employee account for this acc No: '||:p_accnr||
                      ' or '||'ID No: '||:p_idno);	
             raise form_trigger_failure;
    END;

Open in new window

0
Comment
Question by:chalie001
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Helena Marková
ID: 41887459
This is the error:
ORA-01422: exact fetch returns more than requested number of rows
Cause: The number specified in exact fetch is less than the rows returned.

Action: Rewrite the query or change number of rows requested

You can change your code:
BEGIN
        select emp_adress,
               emp_name,
               emp_surname,
        into   ws_address,
               ws_name,
               ws_surname
        from   employee
        where  empid    = :p_empid      and
               (empacc  = :p_accnr or
                idno    = :p_idno);
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
             message('Employee account for this acc No: '||:p_accnr||
                      ' or '||'ID No: '||:p_idno);      
             raise form_trigger_failure;
       WHEN TOO_MANY_ROWS THEN
             message('Too many rows for this acc No: '||:p_accnr||
                      ' or '||'ID No: '||:p_idno);      
             raise form_trigger_failure;

    END;

Here are predefined exceptions:
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm#LNPLS00703
0
 

Author Comment

by:chalie001
ID: 41887582
How can I re-write the query
0
 

Author Comment

by:chalie001
ID: 41887650
how can i do this
- collect all the records returned by SELECT in collection (bulk collect)
- open a cursor for select and loop through it
- if you need only one record, add rownum = 1

if data is like this
CREATE TABLE employee 
   (emp_adress VARCHAR2(10 BYTE), 
	emp_name VARCHAR2(13 BYTE), 
	emp_surname VARCHAR2(8 BYTE), 
	empid VARCHAR2(5 BYTE), 
	empacc VARCHAR2(35 BYTE), 
	idno VARCHAR2(2 BYTE)
   ) 
Insert into employee (empacc,idno,empid,emp_surname,emp_name,emp_adress) values ('90415373',null,'PTE','MS','ADAMS',null);
Insert into employee (empacc,idno,empid,emp_surname,emp_name,emp_adress) values ('90415373',null,'PTE','MS','ADAMS',null);

Open in new window

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 22

Expert Comment

by:Helena Marková
ID: 41887654
select emp_adress,
                emp_name,
                emp_surname,
         into   ws_address,
                ws_name,
                ws_surname
         from   employee
         where  empid    = :p_empid      and
                (empacc  = :p_accnr or
                 idno    = :p_idno) AND rownum<2;
0
 

Author Comment

by:chalie001
ID: 41887672
this is the constraint
ALTER TABLE employee ADD PRIMARY KEY (empacc, idno) DISABLE;
 ALTER TABLE employee MODIFY (empid NOT NULL ENABLE);
0
 
LVL 22

Accepted Solution

by:
Helena Marková earned 500 total points
ID: 41887683
What is the problem now ? Doesn't AND rownum<2; in my last post work, does it ?
0
 

Author Closing Comment

by:chalie001
ID: 41887928
Rownum=1
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cassandra Select Query 1 53
Save conflict messages on existing documents 15 50
Determine Who is Runnig my Bash Shell Script 4 61
Unrecognized Database Format 8 91
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now