Home » SQL & PL/SQL » SQL & PL/SQL » About ORA-01410: invalid ROWID error
About ORA-01410: invalid ROWID error [message #200000] Fri, 27 October 2006 06:20 Go to next message
romi
Messages: 67
Registered: October 2006
Member

Hello all,

I am trying to execute this code but it's giving ORA-01410: invalid ROWID error and not updating table.

declare
cursor cur_t is select * from a4
for update of a4.y_n;
rec_t a4%rowtype;
rec a4%rowtype;
begin
open cur_t;
loop
fetch cur_t into rec_t;
if rec_t.hgb is not null and rec_t.hgb>=14 then
rec:=rec_t;
else
if rec_t.id=rec.id and rec_t.epo<=rec.epo then
update a4 set y_n='Y' where current of cur_t;
else
update a4 set y_n='N' where current of cur_t;
end if;
end if;
exit when cur_t%notfound;
end loop;
end;

Can anyone tell me that what is wrong in it?
Re: About ORA-01410: invalid ROWID error [message #200004 is a reply to message #200000] Fri, 27 October 2006 06:34 Go to previous messageGo to next message
Alien
Messages: 245
Registered: June 1999
Senior Member
exit when cur_t%notfound;

You try to process a record, before checking if it exists.
Either your select doesn't return any records, or you reach the end of the selection.

Re: About ORA-01410: invalid ROWID error [message #200007 is a reply to message #200000] Fri, 27 October 2006 06:45 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member

What should i do in my pl-sql code to currectly run and update table.

Plz clear it more.
Re: About ORA-01410: invalid ROWID error [message #200008 is a reply to message #200007] Fri, 27 October 2006 06:51 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Alien mean to say the following.

Your code:
loop
  fetch cur_t into rec_t;
  if rec_t.hgb is not null and rec_t.hgb>=14 then
    rec:=rec_t;
  else
    if rec_t.id=rec.id and rec_t.epo<=rec.epo then
      update a4 set y_n='Y' where current of cur_t;
    else
      update a4 set y_n='N' where current of cur_t;
    end if;
  end if;
  exit when cur_t%notfound;  /* you are checking here whether cursor fetches something or not 
but before itself you are using rec_t*/
end loop;


So, you should exit loop statement should be the first statement after the fetch.

loop
   fetch cur_t into rec_t;
   exit when cur_t%notfound;  
/*the your other stuff like if and update*/
end loop;

[Updated on: Fri, 27 October 2006 06:52]

Report message to a moderator

Re: About ORA-01410: invalid ROWID error [message #200011 is a reply to message #200008] Fri, 27 October 2006 07:07 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
you also forgot to close your cursor.
Take a look at cursor-for loops. They do all this for you. Explicit cursor handling s#cks.
Previous Topic: Hi I am fresh to this ..plz help me
Next Topic: How do I extract last element of a string?
Goto Forum:
  


Current Time: Wed Dec 07 14:41:26 CST 2016

Total time taken to generate the page: 0.12947 seconds