Home » Developer & Programmer » Forms » When Validate Item Trigger problem.................
When Validate Item Trigger problem................. [message #263955] Fri, 31 August 2007 06:14 Go to next message
imtiazmasud
Messages: 49
Registered: May 2005
Location: Bangladesh
Member

Hi all,
I Have a form where I am keeping "Measuring Unit Information". The fields are like this (Unit_id,Unit_Name,Description) etc..Here I have tabular data view in the forms...I want to protect entrying duplicate records(Unit_Name)in the database through forms...

I have written some code in when validate item trigger like this..

DECLARE
V_TEST VARCHAR2(100);
V_TOTAL NUMBER(10);
V_COUNT NUMBER(10);
V_CURRENT VARCHAR2(100);

BEGIN

--INITIALIZING THE COUNTER
V_COUNT:= 1;

--STORES THE COMPEARABLE VALUE OF THE CURSOR
V_TEST:= :SYSTEM.CURSOR_VALUE;
MESSAGE(V_TEST);

--STORES THE TOTAL NUMBER OF RECORDS IN THE GRID
V_TOTAL:= :SYSTEM.CURSOR_RECORD;

--GOING AT THE TOP OF THE GRID/RECORD
GO_BLOCK('UNIT_INFO');
FIRST_RECORD;
V_CURRENT:= :SYSTEM.CURSOR_VALUE;
MESSAGE(V_CURRENT);

WHILE(V_COUNT < V_TOTAL) LOOP

IF V_TEST = V_CURRENT THEN
MESSAGE('EXISTS');
END IF;

V_COUNT:=V_COUNT+1;
NEXT_RECORD;
V_CURRENT:= :SYSTEM.CURSOR_VALUE;
MESSAGE(V_CURRENT);

END LOOP;

exception
when others then
null;

END;


NB: Here no compilation error is here..but the code is not working plz help....I am also attaching a picture of my form..

with regards....imtiazmasdud

  • Attachment: 123.bmp
    (Size: 1.34MB, Downloaded 848 times)
Re: When Validate Item Trigger problem................. [message #263958 is a reply to message #263955] Fri, 31 August 2007 06:28 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Please, take some time and read OraFAQ Forum Guide to learn how to properly ask a question (especially how to format your message and what kind of attachments are acceptable).

Back to your problem: actually, it is YOU who produces a problem here. It is called "reinventing the wheel". There's a PRIMARY (or UNIQUE) key constraint which should be used to disable existence of duplicate records in a table. Such a constraint is set on a database level. Applying such a rule through form is ... well, not the way one should do it.

So, this is what you should do: in SQL*Plus, issue
ALTER TABLE unit_information
ADD CONSTRAINT pk_unit_name
PRIMARY KEY (unit_name);

Re: When Validate Item Trigger problem................. [message #264093 is a reply to message #263955] Fri, 31 August 2007 13:55 Go to previous messageGo to next message
imtiazmasud
Messages: 49
Registered: May 2005
Location: Bangladesh
Member

Thanks,
Actually I am sorry for that mistake..I will take care of that in future.

Now come to the point, ya what you have thats a solution..Actually I am not thinkig of my form in that way..

I am just trying to check the names that wheather I have entered it before or not programmatically scanning all the records..

....imtiazmasud

[Updated on: Fri, 31 August 2007 14:11]

Report message to a moderator

Re: When Validate Item Trigger problem................. [message #264346 is a reply to message #263955] Mon, 03 September 2007 01:34 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Look at:
Unique key during data entry
http://www.orafaq.com/forum/m/201107/67467/?srch=create+record+group#msg_201107
also
http://www.orafaq.com/forum/m/147107/67467/?srch=validate+master+detail+record+group#msg_147107

David
Previous Topic: How To Store Special Characters in oracle database 8.1.5 from forms
Next Topic: how do i issue a lp command from forms.
Goto Forum:
  


Current Time: Mon Mar 10 12:29:33 CDT 2025