t1
col1 col2
nishi 5000
lucky 6700
akash 7000
i want that a query that when i insert 7000 it will show me data already present and data will not insert. if data is not present it will insert.

Answer Posted / ravi gali

hi u can use DUP_VAL_ON_INDEX exception


SQL> create table test(id number primary key);



Table created.

SQL> set serverout on

SQL>

begin

insert into test values(1);

exception

when DUP_VAL_ON_INDEX then

raise_application_error('duplicate value entered on the row ');

when others then

dbms_output.put_line('if u entered wrong data');

end;

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I know if oracle client is installed on windows?

494


How to revoke create session privilege from a user in oracle?

552


Explain the use of indexes option in imp command.

562


How to use "out" parameter properly?

626


What is oracle join syntax?

566






What happens if recursive calls get out of control?

542


while i take backup using ibm tsm the following errors occurred: rman-03009 ora-19513 ora-27206 ora-19502 ora-27030 ora-ora19511

3865


How to create id with auto_increment on oracle?

545


Can a parameter be passed to a cursor?

598


What is meant by recursive hints in oracle?

614


What is the minimum client footprint required to connect c# to an oracle database?

562


What is Segment Advisor in Oracle?

665


How to connect to oracle using service name instead of sid?

547


What are the different types of modules in oracle forms?

553


can u send the sql dumps to sivakumarr1987@gmail.com plz help me

2592