Home » Developer & Programmer » Forms » insert a record into database upon pressing a Button (Oracle Forms 11g)
icon5.gif  insert a record into database upon pressing a Button [message #619233] Sun, 20 July 2014 11:29 Go to next message
Asfakul
Messages: 7
Registered: July 2014
Junior Member
Hi all,
My problem is I am trying to design a form where user will be able to delete or insert a record using a button in the form. Mt problem is like this .
User will be making a list taking items from different orders. I am planning to implement this in this way-

1. User searches using order_no
2. gets a list and selects the items using checkbox ,presses "Apply" ( Push Button) which inserts the selected records into a temp table.
3. Then again searches using another order_no and selects items.
4. Finally pressing "Ok" Button final list gets prepared.

I dont know how to bypass forms default insert processing and implement my own. Please don't tell me to use Forms default toolbar to insert because default toolbar is not there,they have implemented their own.

here is my code so far ..



PROCEDURE P_INSERT_RECORD IS
l_last_record number;
l_list_id number;

BEGIN
	   --- current_record : Specifies the number of the current record in Block's list of records.
     --execute_immediate('truncate table emp_tt');
     l_list_id:=(select emp_seq.nextval from dual);
     go_block('b_detail');
     first_record;
     last_record;
     l_last_record:=:system.cursor_record;
     for i in 1..l_last_record
       loop
       	   go_record(i);
       	   if cb_select='Y' then
       	     -- I am struck here.. how to insert?
       	   
       	 
       	  
     
     
END;








Re: insert a record into database upon pressing a Button [message #619269 is a reply to message #619233] Mon, 21 July 2014 02:45 Go to previous messageGo to next message
cookiemonster
Messages: 10981
Registered: September 2008
Location: Rainy Manchester
Senior Member
If the datablock is a database datablock then the form will automatically insert/update records on the corresponding table when you issue a commit.
If you don't want that to happen then you need to make it a non-database datablock. This will stop execute-query working so you'll need to populate the block with a select statement. You can then insert records into a table with a standard insert statement.
Re: insert a record into database upon pressing a Button [message #619346 is a reply to message #619269] Mon, 21 July 2014 14:28 Go to previous messageGo to next message
Asfakul
Messages: 7
Registered: July 2014
Junior Member
Thanks cookiemaster. I have one more query .

In the Master Detail form i want to insert record in master and detail table at the same time. how can i do that?
Re: insert a record into database upon pressing a Button [message #619350 is a reply to message #619346] Mon, 21 July 2014 14:40 Go to previous message
Littlefoot
Messages: 19648
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Normally, a master record is created first; detail records follow.

Otherwise, "at the same time" can be done with INSERT ALL statement:
SQL> insert all
  2    into dept (deptno, dname)        values (50, 'IT')
  3    into emp (empno, ename, deptno)  values (12, 'Littlefoot', 50)
  4    into emp (empno, ename, deptno)  values (87, 'Bigfoot'   , 10)
  5  select * from dual;

3 rows created.

SQL>
Previous Topic: Message popup
Next Topic: How to remove status changed from DataBlock
Goto Forum:
  


Current Time: Tue Sep 30 19:39:24 CDT 2014

Total time taken to generate the page: 0.13484 seconds