Home » Developer & Programmer » Forms » unique constraint with duplicate entry (10g,developer 6i,window XP)
icon1.gif  unique constraint with duplicate entry [message #379087] Sun, 04 January 2009 12:11 Go to next message
shahzaib_4vip@hotmail.com
Messages: 410
Registered: December 2008
Location: karachi
Senior Member
Hellow Memeber's


I have one issue in Developer Form i create 2 table one is job and other is Style

job table have 2 column Job_no and Job_name both column have primary key which foreign key on style table

and style have 3 column style_no,job_no,Job_name

now i want to enter style wise job entry and don't want to enter duplicate job_no and job_name in style table

for example

i have 2 job

Job A and Job B

And i have one style

Style AAA
now i want to enter job on style AAA

job A
and Job B
and Job B Again

Now i want when ever i enter a Duplicate job its give me Error in form


Thanks


Shahzaib ismail
Re: unique constraint with duplicate entry [message #379089 is a reply to message #379087] Sun, 04 January 2009 13:03 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
don't want to enter duplicate job_no and job_name in style table

Forms shouldn't take care about it - database, on the other hand, should. Therefore, create unique index on these columns.
Re: unique constraint with duplicate entry [message #379091 is a reply to message #379087] Sun, 04 January 2009 13:39 Go to previous messageGo to next message
shahzaib_4vip@hotmail.com
Messages: 410
Registered: December 2008
Location: karachi
Senior Member
For example if i create a Unique Constraint on Job_no and Job_name


Style no AAA

Job A and Job B


Style no ABC

(Job A and Job B)

it will give me error no duplicate allow due to unique constraint


so i need style AAA (many jobs but not duplicate)

Style ABC (many jobs not not Duplicate)

Hope you understand

Re: unique constraint with duplicate entry [message #379093 is a reply to message #379091] Sun, 04 January 2009 15:39 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
Hope you understand

Sorry, I don't.

Whichever your "unique combination" is (style, job, no matter how you call it), it should be done by creating an unique constraint on a database level.

I re-read your messages a few times, but couldn't get the idea (is it because it is quite late here or I'm to stupid to get it, I wouldn't know). Though, if you manage to illustrate it in a form of a spreadsheet (do NOT attach an Excel file, please!) which means: use [code] or [pre] tags to preserve formatting so that we could see form of a spreadsheet table, perhaps I'll be able to understand it.

Hopefully, you might get the answer by someone else!
Re: unique constraint with duplicate entry [message #379096 is a reply to message #379087] Sun, 04 January 2009 16:06 Go to previous messageGo to next message
shahzaib_4vip@hotmail.com
Messages: 410
Registered: December 2008
Location: karachi
Senior Member
ok lets me explain you once again because your reply is very help full for me


i create one table which structure is

create table job
(job_no number(10),
job_name varchar2(20),
constraint pk_job_job primary key(job_no,job_name))

and create one other table which is style

create table style
(Style_no number(20),
style_job_no number(10),
style_job_name varchar2(20),
constraint fk_style foreign key(style_job_no,style_job_name)
references job(job_no,job_name))

Now i insert 3 records in job

insert into job
values
('1','cutting');

insert into job
values
('2','Stitching');

insert into job
values
('3','Packing');

in style table
i insert

insert into style
values
('9645','2','Stitching');


insert into style
values
('9645','2','Stitching');

Now My Question is simple in style '9645' i don't want to enter job no 2 multiple time

so i need a trigger where when i enter duplicate job no in one particular style its give me error


Hope this time you will understand


Any way Thanks A lot for your reply
Re: unique constraint with duplicate entry [message #379150 is a reply to message #379096] Mon, 05 January 2009 03:00 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So it appears that (style_no, style_job_no) combination should be unique. Doesn't it?

Though, you might find it interesting to read this Francois Degrelle's article.
Re: unique constraint with duplicate entry [message #379172 is a reply to message #379087] Mon, 05 January 2009 04:11 Go to previous message
shahzaib_4vip@hotmail.com
Messages: 410
Registered: December 2008
Location: karachi
Senior Member
As i told you your Advice really help full for me

It solve my problem


Thanks A lot


Shahzaib Ismail
Previous Topic: Runtime poplist Gneration?
Next Topic: Open new Form and Exit this Form
Goto Forum:
  


Current Time: Mon Feb 10 02:42:19 CST 2025