Home » Developer & Programmer » Forms » Chek in table if "number" found show alert - ???
Chek in table if "number" found show alert - ??? [message #166423] Thu, 06 April 2006 04:41 Go to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
i created a table

dono number(4)
sub_dono varchar2(2)
I have inserted record
dono = 1
sub_dono = A

again I am inserting record
DONO=1
SUB_DONO =A

now I want to define in PRE-INSERT
Seek dono and sub_dono
if found
show alert 'alt1'
endif

Please help how I write in Oracle Pre-Insert trigger

I WANT THAT SAID FIELDS COULD NOT BE ENTERED IF ALREADY EXIST.
Re: Chek in table if "number" found show alert - ??? [message #166427 is a reply to message #166423] Thu, 06 April 2006 04:58 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
u try this one
declare
    c number;
begin
    select count(*) into c from table where 
         DONO=:dono and SUB_DONO=:sub_dono;
    if c>0 then
         message('record already exists');
         message(' ');
         raise form_trigger_failure
    end if;
end;

Re: Chek in table if "number" found show alert - ??? [message #166430 is a reply to message #166427] Thu, 06 April 2006 05:02 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Create a unique index on the field(s) and you're done.

@RAS_SANKAR: counting all the records to see whether ONE exists? I'd opt for an OPEN..FETCH..CLOSE solution if a unique index isn't possible.

MHE
Re: Chek in table if "number" found show alert - ??? [message #166440 is a reply to message #166427] Thu, 06 April 2006 05:30 Go to previous message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
Thank You RAS Sankar
Previous Topic: Count Query
Next Topic: all key work such F8 =execute_query
Goto Forum:
  


Current Time: Fri Sep 20 06:31:10 CDT 2024