Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to insert data while NO_DATA_FOUND exception raise

974825Aug 19 2013 — edited Aug 19 2013

create or replace procedure set_update(p_name in varchar2,p_email in varchar2)

is

l_data user_details%rowtype;            

            

begin

select * into l_data

             from user_details ud

             where ud.name = p_name

             and ud.email = p_email;

  if l_data.name = p_name and l_data.email = p_email then

    update user_details

    set last_login_date = sysdate , date_updated = sysdate

    where name = p_name and email=p_email;

  end if;

exception

when no_data_found then

    insert into user_details(user_id,name,last_login_date,date_updated,date_created,email)

    values (l_data.user_id,p_name,l_data.last_login_date,l_data.date_updated,sysdate,p_email);

end set_update;

This is my procedure will pass two parameters if it is available in table it will update other wise insert that data in table.

My problem is while data is not available that data is inserted into table but that not inserted into table.

Can any one help for that problem

My thanks in advance for all your help.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2013
Added on Aug 19 2013
7 comments
362 views