error: ora-01422 exact fetch returns
Hai AllI have created a slider and used to extract multiple lines and I used select in the statement, there is an error.
How do I replace select in the statement in the cursor and where I need to replace
This is my encoding
declare
bar_code varchar2 (25);
date of bar_date;
in_time varchar2 (25);
out_time varchar2 (25);
intr_in varchar2 (25);
intr_out varchar2 (25);
add_in varchar2 (25);
add_out varchar2 (25);
Cursor c1 is
Select the barcode, BARDATE, BARTIME
Of temp_attendance
Group of barcodes, bardate, bartime
ORDER BY barcode, bartime.
cursor c2 is
Select * from dail_att;
Start
To r1 c1 loop
If r1.bartime between 0630 and 0930 and in_time is null or r1.bartime between 1100 and 1300 and in_time is null then
-or r1.bartime between 1615 and 1815 or in_time is null then
insert into dail_att (barcode, respondent, attend_date) values
(r1.barcode, r1.bartime, r1.bardate);
on the other
Select the barcode, attend_date, intimate, intrtimein, introuttime, addin, addout, outtime in bar_code, bar_date, in_time, intr_in, intr_out, add_in, add_out, dail_att out_time;
If intr_in is null then
Update dail_att set intrtimein is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate;.
elsif intr_in is not null and intr_out is null then
Update dail_att set introuttime is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate;.
elsif intr_in is not null and intr_out is not null and add_in is null then
Update dail_att set addin is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate;.
elsif intr_in is not null and intr_out is not null and add_in is not null and add_out is null then
Update dail_att set addout is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate;.
elsif intr_in is not null and intr_out is not null and add_in is not null and add_out is not null and out_time is null then
Update dail_att set outtime is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate;.
end if;
end if;
end loop;
commit;
exception
while others then
message (SQLERRM);
message (SQLCODE);
end;
His work for single record what I need and how can I replace to retrieve multiple records.
Give me some steps to solve this problem
Thanks and greetings
Srikkanth.M
Replace the following text:
select barcode,attend_date,intime,intrtimein,introuttime,addin,addout,outtime into bar_code,bar_date,in_time,intr_in,intr_out,add_in,add_out,out_time from dail_att ;
if intr_in is null then
update dail_att set intrtimein=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif intr_in is not null and intr_out is null then
update dail_att set introuttime=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif intr_in is not null and intr_out is not null and add_in is null then
update dail_att set addin=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif intr_in is not null and intr_out is not null and add_in is not null and add_out is null then
update dail_att set addout=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif intr_in is not null and intr_out is not null and add_in is not null and add_out is not null and out_time is null then
update dail_att set outtime=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
end if;
by the following:
for r in (select barcode,attend_date,intime,intrtimein,introuttime,addin,addout,outtime from dail_att) loop
if r.intr_in is null then
update dail_att set intrtimein=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif r.intr_in is not null and r.intr_out is null then
update dail_att set introuttime=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif r.intr_in is not null and r.intr_out is not null and r.add_in is null then
update dail_att set addin=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif r.intr_in is not null and r.intr_out is not null and r.add_in is not null and r.add_out is null then
update dail_att set addout=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
elsif r.intr_in is not null and r.intr_out is not null and r.add_in is not null and r.add_out is not null and r.out_time is null then
update dail_att set outtime=r1.bartime where barcode=r1.barcode and attend_date=r1.bardate;
end if;
end loop;
Max
http://oracleitalia.WordPress.com
Tags: Database
Similar Questions
-
Error - ORA-01422: exact fetch returns more than number of lines
Hello
I get the error when running script below. Please help me.
/****************** ERROR ******************/
Error report:
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at line 71
01422 00000 - "exact fetch returns more than number of lines."
* Cause: Exact extraction specified number is less than the returned rows.
* Action: Rewrite the query or change the number of rows requested
/****************** SCRIPT ******************/
DECLARE
l_xml XMLTYPE: = XMLTYPE ("< LoggingInformation >
< commandeEmplacement >
< name > ServiceCall1 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
< status > completed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< ServiceLoggingEntries >
< item >
< foo > 1 < / foo >
< / ServiceInformation >
< item >
< foo > 2 < / foo >
< / ServiceInformation >
< / ServiceLoggingEntries >
< InformationLoggingEntries >
< ProcessInformation >
< bar > 1 < / >
< / ProcessInformation >
< ProcessInformation >
< bar > 2 < / >
< / ProcessInformation >
< / InformationLoggingEntries >
< / commandeEmplacement >
< commandeEmplacement >
< name > ServiceCall2 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
< status > completed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< ServiceLoggingEntries >
< item >
< foo > 3 < / foo >
< / ServiceInformation >
< item >
< foo > 4 < / foo >
< / ServiceInformation >
< / ServiceLoggingEntries >
< InformationLoggingEntries >
< ProcessInformation >
< bar > 3 < / >
< / ProcessInformation >
< ProcessInformation >
< bar > < / > 4
< / ProcessInformation >
< / InformationLoggingEntries >
< / commandeEmplacement >
< commandeEmplacement >
< name > ServiceCall3 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
status of <>failed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< / commandeEmplacement >
(< / LoggingInformation > ');
v_txt VARCHAR2 (2000);
BEGIN
SELECT XMLTYPE. Extract (value (TT),'/ CommandInformation/Name/Text () '). GETSTRINGVAL()
IN v_txt
TABLE (XMLSEQUENCE (l_xml. Extract('/LoggingInformation/CommandInformation'))) tt;
DBMS_OUTPUT. Put_line (v_txt);
END;Select...
means only 1 row can be returned.
Your select returns more than one line.
Change v_txt in a collection, define a cursor and the extraction of it or change the statement, i.e. it returns a single line.---------
Sybrand Bakker
Senior Oracle DBA -
ERRO ORA-01422: exact fetch returns more than number of lines
SET SERVEROUTPUT ON
create or replace procedure copy
AS
cursor c2 IS
Select t.country_code
transactions t;
v_lc_details_current_hist c2% rowtype;
v_country_code transactions.country_code% TYPE;
Start
Open c2;
loop
extract the c2 in v_lc_details_current_hist;
OUTPUT WHEN c2% NOTFOUND;
Select the country_code in v_country_code of transactions;
DBMS_OUTPUT. Put_line (v_country_code);
end loop;
Close c2;
end;
/
I'm gettintha error ORA-01422: exact fetch returns more than number of lines
Please help me[email protected] wrote:
Select the country_code in v_country_code of transactions;
-It's to return several rows, and the SELECT INTO statement expects that one line.A SELECT INTO statement can be used if you want a query to return only one row. Otherwise use bulk collect and a variable of class to contain the result lines multiples.
-
Hi all
We try to add new proposal for a salary of some employees from form August 1, 2015 (the Date of the beginning of employee)
There is no existing salary proposal doesn't exist for these employees.
We get below error.
ORA-01422: exact fetch returns more than the requested number of rows in the hr_maintain_proposal_swi procedure insert_salary_proposal package
Help, please.
Thank you
Tarun
Hi John,.
If it helps, take a look at the following note:
ORA-01422 exact Fetch returns more than number of lines requested in Hr_maintain_proposal_swi (Doc ID 1673527.1)
Kind regards
Rajen
-
ORA-01422: exact fetch returns more than number of lines
Hello world
I want to create a procedure only allows me to perform selection et Update in my database, I have already create the procedure and compiled without problems but when I want to run this procedure, I have this error
ORA-01422: exact fetch returns more than number of lines
This syntax of my procedure
create or replace procedure app is
i nombre := 100 ;
o_username employees.first_name% TYPE ;
o_lastn employees. Last_name %TYPE
o_sal. employees % of SALARY TYPE ;
Start
loop
/ * display * /.
Select first_name, LAST_NAME, SALARY
in o_username, o_lastn, o_sal
of admin.employees where employee_id = i;
DBMS_OUTPUT. Put_line (' name: ' | o_username);
DBMS_OUTPUT. Put_line (' first name: ' | o_lastn);
DBMS_OUTPUT. Put_line (' salary: ' | o_sal)
/ * put a days * /.
Update employees
put salary = salary + salary *0.25 where employee_id = i;
commit;
/ * dbms_put.put_line (' new salary is: ' | ') sell2_tab (i)); * /
i := i + 1 ;
/ * list the data * /
/ * dbms_put.put_line (' new salary is: ' ") ;*/
output when i = 200;
end loop;
end app;
thnx
create or replace procedure APP is
Constant START_ID EMPLOYEES. EMPLOYEE_ID % TYPE: = 100;
Constant END_ID EMPLOYEES. EMPLOYEE_ID % TYPE: = 200;
O_USERNAME EMPLOYEES. Type % name;
O_LASTN EMPLOYEES. Last_name type %;
O_SAL EMPLOYEES. Kind of % of SALARY;
Start
for rec (select FIRST_NAME, LAST_NAME, salary
the admin. EMPLOYEES
where EMPLOYEE_ID between START_ID and END_ID)
loop
DBMS_OUTPUT. Put_line (' name: ' | rec. NAME);
DBMS_OUTPUT. Put_line ("first name:" | ") Rec. LAST_NAME);
DBMS_OUTPUT. Put_line (' salary: ' | rec. SALARY) / * setting days * /.
end loop;
Update EMPLOYEES
Set SALARY = SALARY + SALARY * 0.25
where EMPLOYEE_ID between START_ID and END_ID;
commit;
end app;
-
ORA-01422 exactly fetch returned more rows than expected
Hi all
Some1 can you please suggest what is the difference between "ORA-01422 exactly fetch returned more rows than expected" and too many errors of lines.
Concerning
ArpitTOO_MANY_ROWS is a predefined exception that allows to capture the ORA-01422. It simply means that we don't need to declare our own exception to cope.
SQL> DECLARE 2 3 lv_Dummy dual.dummy%TYPE; 4 5 BEGIN 6 7 SELECT 8 dummy 9 INTO 10 lv_Dummy 11 FROM 12 ( SELECT dummy FROM DUAL UNION ALL 13 SELECT dummy FROM DUAL 14 ); 15 END; 16 / DECLARE * ERROR at line 1: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 7 SQL> set serveroutput on SQL> DECLARE 2 3 lv_Dummy dual.dummy%TYPE; 4 5 BEGIN 6 7 SELECT 8 dummy 9 INTO 10 lv_Dummy 11 FROM 12 ( SELECT dummy FROM DUAL UNION ALL 13 SELECT dummy FROM DUAL 14 ); 15 EXCEPTION 16 WHEN TOO_MANY_ROWS THEN 17 dbms_output.put_line('TOO_MANY_ROWS is built in exception to allow us to capture ORA-01422'); 18 19 END; 20 / TOO_MANY_ROWS is built in exception to allow us to capture ORA-01422 PL/SQL procedure successfully completed. SQL> DECLARE 2 3 lv_Dummy dual.dummy%TYPE; 4 lex_TooManyRows EXCEPTION; 5 6 PRAGMA EXCEPTION_INIT(lex_TooManyRows, -1422); 7 BEGIN 8 9 SELECT 10 dummy 11 INTO 12 lv_Dummy 13 FROM 14 ( SELECT dummy FROM DUAL UNION ALL 15 SELECT dummy FROM DUAL 16 ); 17 EXCEPTION 18 WHEN lex_TooManyRows THEN 19 dbms_output.put_line('lex_TooManyRows is our exception to allow us to capture ORA-01422'); 20 21 END; 22 / lex_TooManyRows is our exception to allow us to capture ORA-01422 PL/SQL procedure successfully completed.
HTH
David
-
ORA-01422: exact fetch returns more than number of rows - FIX?
Dear experts of PL/SQL,
I encounter this problem when running under procedure, how this can be exceeded? Procedure was running well for the last few weeks and we have this problem all of a sudden:
ORA-01422: exact fetch returns more than number of lines
CREATE OR REPLACE PROCEDURE DBA_MAINT. () SQL_EXEC_DRILLDOWN
beginsnapid in numbers
endsnapid in numbers
)
AS
begin_date varchar2 (30);
End_date varchar2 (30);
statName VARCHAR2 (64);
err_msg VARCHAR2 (100);
The CNT number;
cursor c1
is
Select stat_name,
Sum in the NTC
de)
Select instance_number,
stat_name,
((VALUE) max - min (VALUE)) COUNTY
of dba_hist_sysstat
where stat_name in ("run the County", 'parse count (total)', "parse count (hard)")
and snap_id between beginsnapid
and endsnapid
Instance_number group, stat_name)
Stat_name group
Union of all the
Select stat_name,
Sum in the NTC
de)
Select instance_number,
stat_name,
Round (((value) - (VALUE) min Max) / 1000000) COUNTY
of DBA_HIST_SYS_TIME_MODEL
where stat_name in ("DB CPU", "background time cpu", 'sql execute elapsed time', 'analysis elapsed time', ' parse hard time elapsed ")
and snap_id between beginsnapid
and endsnapid
Instance_number group, stat_name)
Stat_name Union group all the
Select stat_name,
MySQL as cnt
de)
Select a.stat_name stat_name,
(b.value - a.value) VALUE
dba_hist_sysstat a, dba_hist_sysstat b
where a.dbid = b.dbid
and a.instance_number = b.instance_number
and a.stat_id = b.stat_id
and a.snap_id = beginsnapid
and b.snap_id = endsnapid
and a.stat_name in ('physical reads',
"physical Scriptures."
"physical read IO total number of applications."
"physical write IO requests total."
"Physics read total multi block requests."
"total multi block request writing for the physical box,.
("reading session logic")
and a.instance_number = b.instance_number)
Stat_name group;
Start
Start
Select distinct TO_CHAR (END_INTERVAL_TIME, "MM/DD/YYYY HH24 '")
in begin_date
of dba_hist_snapshot
where snap_id = beginsnapid;
Select distinct TO_CHAR (END_INTERVAL_TIME, "MM/DD/YYYY HH24 '")
in end_date
of dba_hist_snapshot
where snap_id = endsnapid;
-DBMS_OUTPUT. Put_line (begin_date);
-DBMS_OUTPUT. Put_line (end_date);
exception
When no_data_found
then
null;
end;
C1_rec IN C1
LOOP
Start
Insert
in DBA_MAINT. Values (DB_SQL_EXEC_DETAILS)
beginsnapid,
endsnapid,
begin_date,
End_date,
c1_rec.stat_name,
c1_rec. CNT
);
-DBMS_OUTPUT. Put_line (c1_rec.stat_name |) » '|| c1_rec. CNT);
exception
When no_data_found
then
null;
end;
end loop;
commit;
end;
/
Reasons to explain above, but I think it would be more appropriate select latest END_INTERVAL_TIME as follows
Select TO_CHAR ((max (END_INTERVAL_TIME)), "MM/DD/YYYY HH24")
in begin_date
of dba_hist_snapshot
where snap_id = beginsnapid;
Select TO_CHAR ((max (END_INTERVAL_TIME)), "MM/DD/YYYY HH24")
in end_date
of dba_hist_snapshot
where snap_id = endsnapid;
-
error report: ORA-01422: exact fetch returns more than number of lines
I get this error in table form that should be filled by selecting a week called item description in this page by a dynamic action.
In the main table, I have two primary keys and so two foreign keys in the secondary table even if it is not a type of form master detail.
When I select the week description point and the related records in the form of sound. But it gives the above error.
In the main table, there are two records of same, in this user name folders is different which defines the unique character of the file.
It is really basic and happens if you have something like this in your code - the SQL code is supposed to return exactly ONE value and it returns two or more:
Denes Kubicek
-
Error ORA-01422 apex: exact fetch returns more than the required number of line
Hi people,
Apex 4.1
I have a page that works like a charm.
Based on my application I need I have to perform the same operation for the different regions. As a quick and better method, I copied the page and branched, it inspires tab for this region.
The problem is that the original page works fine.
I haven't changed anything except the parent set to this copied page tab and works that I find with the above error.
It allows me to make the first entry on this page, but when I try to access the page again it gives me this error.
The error in detail is as below:
is_internal_error: false
ora_sqlcode:-1422
ora_sqlerrm: ORA-01422: exact fetch returns more than number of lines
Component.type: APEX_APPLICATION_PAGE_PROCESS
Component.ID: 214936714355373108
Component.Name: EMP_LEAVE_INFO line
error_backtrace:
ORA-06512: at line 1
ORA-06512: at "SYS." DBMS_SYS_SQL", line 1926
ORA-06512: at "SYS." WWV_DBMS_SQL', line 973
ORA-06512: at "SYS." WWV_DBMS_SQL', line 999
ORA-06512: at "APEX_040200.WWV_FLOW_DYNAMIC_EXEC", line 806
ORA-06512: at "APEX_040200.WWV_FLOW_DML", line 336
ORA-06512: at "APEX_040200.WWV_FLOW_PROCESS", line 332>
As a quick and better method, I copied the page and branched, it inspires tab for this region.
>Copy paste is never advisable. It can be fast in some cases, there is an anti-pattern.
Be aware that the automatic extraction of the APEX line is based on a component of demand.
It is possible that your automatic rowfetch is based on the element of your previous page. If you for example to change the name of the table, but do not change the reference is the primary key value, then you can pass a value to your table that was not unique. This would result in ORA-01422.
Find the value of the session element and run your query.
Concerning
Nico
-
"Getting the error 'exact fetch returns more than number of lines.
Hi try to run a query of Iam
but when I run what it it gives an error
Error report:
here's my querey
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at line 9 level
01422 00000 - "exact fetch returns more than number of lines."
* Cause: Exact extraction specified number is less than the returned rows.
* Action: Rewrite the query or change the number of rows requested
SET SERVEROUTPUT ON
DECLARE
Emp_table_type TYPE IS an ARRAY OF
hr_api_transactions % ROWTYPE INDEX BY PLS_INTEGER;
my_emp_table emp_table_type;
BEGIN
I'm in 1.53
LOOP
SELECT * INTO my_emp_table (i) FROM hr_api_transactions
WHERE transaction_ref_table = 'PER_ALL_VACANCIES ';
END LOOP;
BECAUSE me IN my_emp_table. FIRST... my_emp_table. LAST
LOOP
DBMS_OUTPUT. Put_line (my_emp_table (i) .transaction_document);
END LOOP;
END;Hello
'Re missing you the bulk of the Collections. Ask that you well want to have a glance on manual of oracle collections.
Replace your code...DECLARE TYPE emp_table_type IS TABLE OF hr_api_transactions%ROWTYPE INDEX BY PLS_INTEGER; my_emp_table emp_table_type; BEGIN SELECT * BULK COLLCT INTO my_emp_table FROM hr_api_transactions WHERE transaction_ref_table = 'PER_ALL_VACANCIES'; FOR i IN my_emp_table.FIRST..my_emp_table.LAST LOOP DBMS_OUTPUT.PUT_LINE(my_emp_table(i).transaction_document); END LOOP; END;
Before you run the above script, don't forget to run the
set serveroutput on
I hope this helps.
PS-> mark as Complete/useful, if the apporoach above meets the expected result
Kind regards
Claudy -
ERROR "ora-01422" during insertion in the table?
Hello
I have created the dynamic action of PL/SQL to insert data but founded by page_item
declare x_found_pages number; x_auth_id number; x_user_id number; begin x_user_id := :P41_USR_ID; -- this is my page_item _____ successful run When change it to number value .. ! select count(V_APP_PAGES.PAGE_ID) into x_found_pages from V_AUTH_DTL V_AUTH_DTL,V_APP_PAGES V_APP_PAGES where V_AUTH_DTL.PAGE_ID!=V_APP_PAGES.PAGE_ID and V_AUTH_DTL.USR_ID = x_user_id; select T_AUTH.ID into x_auth_id from T_AUTH_DTL T_AUTH_DTL,T_AUTH T_AUTH where T_AUTH_DTL.AUTH_ID=T_AUTH.ID and T_AUTH.USR_ID = x_user_id; -- Checking...? if x_found_pages > 0 then for i in (select V_APP_PAGES.PAGE_ID from V_AUTH_DTL V_AUTH_DTL,V_APP_PAGES V_APP_PAGES where V_AUTH_DTL.PAGE_ID!=V_APP_PAGES.PAGE_ID and V_AUTH_DTL.USR_ID = x_user_id) loop insert into T_AUTH_DTL (AUTH_ID,PAGE_ID) values (x_auth_id,i.PAGE_ID); end loop; end if; end;
Please help me to avoid the ERROR "ora-01422" when running code in the dynamic action...
Thank you...
AMR Abdeen wrote:
I have created the dynamic action of PL/SQL to insert data but founded by page_item
- declare
- number of x_found_pages;
- number of x_auth_id;
- number of x_user_id;
- Start
- x_user_id: =: P41_USR_ID; -It is my page_item _ successfully performed when change to value the number...!
- SELECT count (V_APP_PAGES. Page_id) in x_found_pages
- of V_AUTH_DTL V_AUTH_DTL, V_APP_PAGES V_APP_PAGES
- where V_AUTH_DTL. PAGE_ID! = V_APP_PAGES. PAGE_ID
- and V_AUTH_DTL. USR_ID = x_user_id;
- Select T_AUTH.ID from x_auth_id
- of T_AUTH_DTL T_AUTH_DTL, T_AUTH T_AUTH
- where T_AUTH_DTL. AUTH_ID = T_AUTH.ID
- and T_AUTH. USR_ID = x_user_id;
- -Checking...?
- If x_found_pages > 0 then
- I'm in (select V_APP_PAGES. PAGE_ID
- of V_AUTH_DTL V_AUTH_DTL, V_APP_PAGES V_APP_PAGES
- where V_AUTH_DTL. PAGE_ID! = V_APP_PAGES. PAGE_ID
- and V_AUTH_DTL. USR_ID = x_user_id)
- loop
- insert into T_AUTH_DTL (AUTH_ID, PAGE_ID) values (x_auth_id, i.PAGE_ID);
- end loop;
- end if;
- end;
Please help me to avoid the ERROR "ora-01422" when running code in the dynamic action...
The error is explicit:
ORA-01422: exact fetch returns more than number of lines
Cause: The exact extraction specified number is less than the rows returned.
Action: Rewrite the query or change the number of rows requested
This would imply the query in line 16 as County dissociated in the previous one will always return only one row.
Run
select T_AUTH.ID into x_auth_id from T_AUTH_DTL T_AUTH_DTL,T_AUTH T_AUTH where T_AUTH_DTL.AUTH_ID=T_AUTH.ID and T_AUTH.USR_ID = :x_user_id
in the workshop of SQL by using the P41_USR_ID value in the variable link to find out how many rows it returns.
It is likely that the entire block can be replaced by a single INSERT statement. If you provide instructions CREATE TABLE, INSERT statements to create sample data and a clear definition of the requirements that we try to do.
What is the point of the inclusion of tables aliases that are exactly the same as the names of the tables?
-
exact fetch returns more than number of lines
Hello
I have here is the procedure to kill session from blocking. It works fine if a row is returned to select it.
How can I change to operate multiple lines?CREATE OR REPLACE PROCEDURE kill_blocking IS
l_sid NUMBER (10);
l_serial NUMBER (10);
l_wait NUMBER (10);
l_username VARCHAR2 (20);
sqlstmt VARCHAR2 (1000);
BEGIN
SELECT s1. SID, s1.serial #, s2.seconds_in_wait, s2.username
IN l_sid, l_serial, l_wait, l_username
V $ lock l1.
v$ session s1,.
v$ lock l2,.
v$ session s2,.
v$ sql sqlt1.
v$ sql sqlt2
WHERE s1. SID = l1. SID
AND s2. SID = l2. SID
AND sqlt1.sql_id = s2.sql_id
AND sqlt2.sql_id = s1.prev_sql_id
AND l1. BLOCK = 1
AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2;
IF l_username = "APP" AND l_wait > 100
THEN
sqlstmt: =.
"ALTER SYSTEM KILL SESSION"'.
|| To_char (l_sid)
|| ','
|| To_char (l_serial)
|| '''';
Dbms_output.put_line (sqlstmt);
EXECUTE IMMEDIATE sqlstmt;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
Dbms_output.put_line ('no data found');
END;
/
SQL > exec kill_blocking;
BEGIN kill_blocking; END;*
ERROR on line 1:
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at TK. "KILL_BLOCKING", line 8
ORA-06512: at line 1Hello
You can use the procedure below
create or replace
PROCEDURE kill_blocking_mig
IS
l_sid NUMBER (10);
l_serial NUMBER (10);
l_wait NUMBER (10);
l_username VARCHAR2 (20);
sqlstmt VARCHAR2 (1000);
CURSOR status_cus IS
SELECT s1. SID, S1. Serial #, s2.seconds_in_wait, s2.username
V $ lock l1.
v$ session s1,.
v$ lock l2,.
v$ session s2,.
v$ sql sqlt1.
v$ sql sqlt2
WHERE s1. SID = l1. SID
AND s2. SID = l2. SID
AND sqlt1.sql_id = s2.sql_id
AND sqlt2.sql_id = s1.prev_sql_id
AND l1. BLOCK = 1
AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2;
BEGIN
OPEN status_cus.
loop
extract the status_cus IN l_sid, l_serial, l_wait, l_username;
When the output status_cus % notfound;
IF l_username = "APP" AND l_wait > 100 THEN
sqlstmt: = ' EDIT the SYSTEM KILL SESSION "' | To_char (l_sid) | ',' || To_char (l_serial) | '''';
Dbms_output.put_line (sqlstmt);
EXECUTE IMMEDIATE sqlstmt;
END IF;
end loop;
EXCEPTION
WHEN NO_DATA_FOUND THEN
Dbms_output.put_line ('no data found');
END;
-
Get the error ORA-01422 in stored procedure
ORA-01422: exact fetch returns more than number of lines
This page explains the error:
http://www.techonthenet.com/Oracle/errors/ora01422.php
This is my procedure:
In the clause select is causing the error. I understand the nature of the error, but the strange thing is that when I run the sql code, remove the "in."
part of my test settings, I just receive a single line. Always when I execute my procedure with the same settings I get the error. What could be wrong?
create or replace
PROCEDURE COUNTER_GETACTIVE
(
METERPOINTID IN MeterPointCounters.MeterPointId%Type,
METERPOINTCOUNTERNR IN METERPOINTCOUNTERS. Type of METERPOINTCOUNTERNR %,
p_cursor on REFCURSOR_PKG.counter_cursor
)
IS
l_counterNr CounterBridgeTable.CounterNr%type;
l_meterId CounterBridgeTable.MeterId%type;
BEGIN
Select counternr, meterid in 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 actually run this query
select counternr, meterid from CounterBridgeTable where meterpointid = METERPOINTID and meterpointcounternr = METERPOINTCOUNTERNR and datetom is null;
param name is identical to the column, he's ignoring your param and pretty much do 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;
Published by: tanging on June 8, 2010 10:37
-
exact fetch returns more than requested number: retrieve first row
I have this statement:
I got this error:FOR l IN C1 LOOP select amount,customer_id INTO F_AMT,I_custid from zerorize where doc_id = l.doc_id and trans_type = C_py; END LOOP;
I want to change my sql statement in such a way, it gets the first line. How am I suppose to add my where clause condition?ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 172
If you don't have a way to restrict your query to return only 1 row according to the data, you can use the line number...
for exampleselect data, data2, ..... from ( select data, data2, ....., rownum rn from table ) where rn = 1
-
Get the error ora-01422 returned no more exact fetch lines...
create or replace procedure studd is
ID number;
BookName varchar2 (40);
RDATE date;
Start
Select books.bid, booksdate.btake, books.bname in bookid, rdate, books bookname, booksdate where books.bid = booksdate.bid;
dbms_output.put_line(BookName||) e was bought ' | Count (BookID) | (' Times');
end;
/
This the code required. .plz make the necessary changes so that it executesHello
It is useful for you to see below...
SQL> select * From test; EMPNO EMPTYPE SALARY ---------- -------------------- ---------- 6 backoffice 345 1 HR 1725 2 Admin 1725 3 MARKETING 2070 4 FACILITY 2415 8 IT 2070 5 ADMIN 1917 9 Finance 1725 10 "100HR" 1553 9 rows selected. SQL> select * From test_1; EMPNO EMPTYPE SALARY ---------- -------------------- ---------- 6 backoffice 345 1 HR 1725 2 Admin 1725 3 MARKETING 2070 4 FACILITY 2415 8 IT 2070 5 ADMIN 1917 9 Finance 1725 10 "100HR" 1553 9 rows selected. SQL> SQL> declare 2 cursor cur is select count(a.empno),a.emptype emptype,a.salary from test a,test_1 b 3 where a.empno=b.empno group by a.emptype,a.salary; 4 begin 5 for rec in cur 6 loop 7 dbms_output.put_line(rec.emptype || ' has '||rec.salary ||'salary.'); 8 end loop; 9 end; 10 / ADMIN has 1917salary. backoffice has 345salary. FACILITY has 2415salary. MARKETING has 2070salary. IT has 2070salary. "100HR" has 1553salary. Admin has 1725salary. HR has 1725salary. Finance has 1725salary. PL/SQL procedure successfully completed.
Maybe you are looking for
-
HP Pavilion dv6 - 2134ee Enterta: laptop HP Pavilion dv6-2134ee (UNKNOWN DEVICE)
PC Expert, please help me, I reformat my laptop and this is one missing. Please help me. Thank you.
-
Hello. I bought HP desktop a6345.sc about half a year ago and I noticed the lack of performance of the demanding graphics applications (video games, etc.) That's why I decided it's time for an upgrade. Performance index gives me "5.4" with the CPU an
-
Recovery of old e-mail account
My computer crashed and I had to get another. I'm unable to access my old email address, * address email is removed from the privacy *. I really need retrieve information from it. I had to get a new e-mail address of Suddenlink, * address email is
-
my "speaker" icon disappeared suddenly from the toolbar, and I have no sound. Any ideas?
-
I can't print coupons from Coupons.com wireless from my MacBook Pro to my HP Officejet 6500 has more. I installed, removed and reinstalled the Coupons.com download several times but nothing helped. I am Mac OS 10.6.6. I tried all browsers I use, that