Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a button to append records to a table

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
Can somebody point me in the right direction. I want to give the user a button on a 6i form. This button should append rows to a table. The form will have two text boxes. One of these is the beginning number and the other is the ending number. The numbers will always be consecutive but might be any set of numbers. The user enters the numbers they want generated and the system appends one row for each of those numbers and plugs in the number in the number_ID column. For example, the user would enter 100 in the begin and 200 in the end box. The code then appends 100 rows to the table.. so you end up with 100 rows and the first column in each row is the number that was generated

number_id
-------------
100
101
102
103
..
..
..
200

If somebody can point me in the right direction Id appreciate it.

 
Code:
FOR i IN :block.start TO :block.end
LOOP
  INSERT INTO table (
    number_column )
  VALUES (
   i );
END LOOP;
 
Thanks, I had made my loop different but finally got it working.. but... it works in sqlplus, why wont it work when i put it in the when-button-pressed event of a button on a 6i form? The form doesnt give me any errors, its just that NOTHING happens.. no records are appended and no errors produced.. I cant figure out what Im doing wrong.

declare
count_begin number(9);
count_end number(9);
sonu varchar2(8);
emp_name varchar2(50);
division varchar2(15);
issuedate date;

begin
count_begin := 999996 ; --:m_first_number;
count_end := 999998 ; --:m_last_number;
sonu := 'testso' ; --:m_sonu;
emp_name := 'testname' ; --:m_name;
division := 'ADMIN' ; --:m_division;
issuedate := sysdate;

loop
insert into mytable values (count_begin, issuedate, null ,null , sonu, emp_name, division,null ,null ,null );
count_begin := count_begin + 1;
exit when count_begin = count_end;
end loop;
end;


 
I dont understand what was wrong with my code, but its your call.....

You have no COMMIT so the data you enter as part of the INSERT will not be visible. You may need to switch off messages so that you dont get unwanted 'no changes to save' when you commit.
 
thanks, I got my loop to work in sqlplus with some default values but when i moved it to the when-button-pressed event on my 6i form, nothing happens.. i dont get any error messages or anything, just nothing happens...any idea what else if have to do in the form button to make it work?


 
sorry about the multiple posts, but something glitched on this end when i was posting..

actually Im going to change my loop to your code, I had already cludged up my version before i saw yours..<G>

I'm going to add a commit now and see if that fixes it.
 
Hi to all...
make three text field
1, :start_no
2, :end_no
3, :result (it is multipul field like tabular).

create post_text_item trigger of :end_no field...


DECLARE
A NUMBER;
BEGIN
A := :)end_no) - :)start_no);
:result := :start_no;
NEXT_RECORD;
FOR i IN 1..A LOOP
:result := :result + 1 ;
NEXT_RECORD;
END LOOP;
NEXT_RECORD;
END;


if this give error then replay ...
bye...
 
Thanks again to everybody for the help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top