I am trying to insert data into an oracle database through a form I am creating. The questions I have are as follows:
- at what level should I put the trigger that does the insert. At the moment I created an insert at the button level with the "when-button-pressed" trigger, but it does not work. It freezes up when I press the insert when I run it.
- The "ID" column which is my primary key as only the basic constraints like NOT NULL. How can I icrement it upon insert? I am supposed to have a pre-insert trigger? at what level?
- I have a primary key that is to be incremented and therefore I created a sequence. I am ommitingthe primary key in the insert. Am I supposed to have another trigger somewhere to increment the ID value??
If you have a base table item, Oracle (or Forms) generates SQL at runtime to insert, update, delete and query rows in the base table, based upon user's actions. You don't need to write code for the insert.
With a PRE-INSERT trigger you can assign IDs based on sequences. Set INSERT ALLOWED and NAVIGABLE on FALSE for the item, to prevent entering IDs manually.
First, why donít you create a sequence and a pre IUD trigger on the tables on the database side, I think itís more efficient and easier to maintain.
Thanks for your help guys.... I used the latter suggestion and created a pre inset trigger onthe databse table. I will look into the other suggestion. Thanks once again.
Click Here to Expand Forum to Full Width