Home » Developer & Programmer » Forms » insert records
insert records [message #80143] Thu, 15 August 2002 07:04 Go to next message
walterdude
Messages: 5
Registered: August 2002
Junior Member
How do i insert a record into an excisting table when i push a button on the form?
Re: insert records [message #80147 is a reply to message #80143] Thu, 15 August 2002 14:25 Go to previous message
Tyler
Messages: 123
Registered: January 2002
Senior Member
This should be in a book somewhere no?
...

This all depends on if you are using db items on a form or independant items... If you are using db items, then all you have to do is make sure that the primary key in the table is accounted for with a pre-insert trigger, or when button pushed and then use the command COMMIT_FORM; ... If your text items are independant from the db, then you have to do a WHEN_BUTTON_PRESSED - INSERT INTO TABLE_NAME(...) VALUES(...), but if you do it the ladder of the two ways then you have to make sure that in your code you do a database change, it doesn't matter how, personally I would add a db item from another table onto the form (hidden of course), code a temp variable and code this...

v_temp := :db_item;
:db_item := v_temp;
commit;

This will allow the database to see that there has now been a change and will accept your insert statement and commit, even though there wasn't "actually" a permanent change in the db, just a small temporary change... Hope this helps... (this should all be very easy to resource in a book though, if this doesn't help)

declare
v_temp number;
begin
insert into table_name()
values();

v_temp := :db_item;
:db_item := v_temp;
commit;
end;

Cheers,
~ T ~
Previous Topic: How do i show data from a table in a block
Next Topic: triggers for buttons
Goto Forum:
  


Current Time: Sun Sep 19 12:47:46 CDT 2021