Originally posted by debasisdas
Date as primary key?
Collapse
X
-
-
Originally posted by debasisdashave you tried using count() ?
now it checks the id,but have to check the date also....Comment
-
What's the problem with error trapping method?
I mean, what message are you getting when using this? I don't find any problem using this method. If you are not using Oracle, then you can have error number for the db (you are using) that is thrown when a unique constraint is violated.
This has always worked for me without any fault.
Tell me in detail so I can help you out.Comment
-
Originally posted by vikas000000aWhat's the problem with error trapping method?
I mean, what message are you getting when using this? I don't find any problem using this method. If you are not using Oracle, then you can have error number for the db (you are using) that is thrown when a unique constraint is violated.
This has always worked for me without any fault.
Tell me in detail so I can help you out.
I am confused...each time it needs to check id and date,but when id is there,n other date can be saved,rite???t. ,Comment
-
Originally posted by Vbbeginner07but my questn. is that once an id is saved with one particular date,how can we add another date with the same id???
I am confused...each time it needs to check id and date,but when id is there,n other date can be saved,rite???t. ,
check using
[CODE=oracle]select count(*) from table_name where user_id='id' and user_date = 'date'[/CODE]
before inserting values
insert only if this returns 0
also takecare not to use DATE as field name in any table.Comment
-
Originally posted by debasisdashow can the same employee have the same date entered twice ?
check using
[CODE=oracle]select count(*) from table_name where id='id' and date = 'date'[/CODE]
before inserting values
insert only if this returns 0
As in above replies:
MII/101 added to database as 02/01/08 with 10 hours
the same emp.id should be enetered with 8 hours in 03/01/08
Did u understand???Oe r else explanation needed?Comment
-
Originally posted by Vbbeginner07see to that,one can work for different hours for different dates right???
As in above replies:
MII/101 added to database as 02/01/08 with 10 hours
the same emp.id should be enetered with 8 hours in 03/01/08
Did u understand???Oe r else explanation needed?
and you are having composit key on id and date , right ?Comment
-
Originally posted by debasisdasso what , your date is different or not
and you are having composit key on id and date , right ?Comment
-
Comment
-
Originally posted by debasisdasi hope you got that right now .Comment
-
Originally posted by Vbbeginner07yes,but not getting it in prper way.......ny way thanksComment
-
If the primary key is made up of the ID and date fields, then any attempt to store a record which duplicates both of these fields must produce some sort of error (unless your database allows duplicate primary keys, which seems rather odd). Why can't you trap that error and deal with it accordingly?Comment
-
Originally posted by Killer42If the primary key is made up of the ID and date fields, then any attempt to store a record which duplicates both of these fields must produce some sort of error (unless your database allows duplicate primary keys, which seems rather odd). Why can't you trap that error and deal with it accordingly?
but the code count isnt working out,because im selecting date from a datepicker
and store date as 12/18/2007
anyone please guide me through?Comment
-
-
Originally posted by Vbbeginner07killer,now im keeeping only date as a primary key...would it help??? sugeest if its not a good idea?
Um... in this case, using the date alone as the PK is probably not a good idea. Since the PK must be unique, it means you can only store one record per date. And I don't think this is what you want.Comment
Comment