How can i insert data into table through forms. [message #425884] |
Mon, 12 October 2009 19:37 |
consultant19
Messages: 23 Registered: September 2009 Location: India
|
Junior Member |
|
|
Hi
I have developed a custom form based on custom table.
the only way to insert data into database table is through form.
there are two tables: one table is to store all contract details & second table is to maintain history forthis.
one condition(col1,col2,col3,col4) are unique combination,we are not creating any PK or FK at database level.evrythng is captured at form level.
if all 4 columns combination exist thn e should not insert that record.
if 4 columns combination doesnot exist then insert into table.
I have used just pre insert,pre update triggers.
I think its a basic form functionality ,by itself it inserts ,update record.now it is doing the same thng.
But I have to add the above condition ,how can i do that.
Pl provide me some ex code .
Thank you.
Hope any one can help me
|
|
|
|
Re: How can i insert data into table through forms. [message #425907 is a reply to message #425884] |
Tue, 13 October 2009 00:49 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
In my opinion, you *should* let the database take care about uniqueness. It is easy and efficient.
Doing the same thing through the application is, well, a worse solution. If you, however, insist on reinventing a wheel, you might create a WHEN-VALIDATE-RECORD trigger and check whether such a combination already exists in the database. If so, raise an exception.
Omar, how would master-detail design resolve uniqueness problem?
|
|
|
Re: How can i insert data into table through forms. [message #425966 is a reply to message #425907] |
Tue, 13 October 2009 07:45 |
consultant19
Messages: 23 Registered: September 2009 Location: India
|
Junior Member |
|
|
Hi
Thanks for your suggestion.but I am not supposed to do any thng at database level.
can you pl provide me sample code for this case. and do i need to use ON INSERT ,ON UPDATE trigger. If so how can i write code for this situation.pl provide me some example .
|
|
|
Re: How can i insert data into table through forms. [message #426066 is a reply to message #425966] |
Wed, 14 October 2009 00:50 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
consultant19 wrote on Tue, 13 October 2009 14:45I am not supposed to do any thng at database level.
You are not? Why not? That's stupid! Tell them (whoever they are) that forcing someone to spend too much time and energy in order to produce a result that could have been achieved in a matter of a single SQL statement typed within several seconds is, simply, ridiculous.
|
|
|