How to add multipule input transactions into a temp table.

vexiteer

New Member
Hello All,

I have a question regarding how to add in multipule input transactions into a temp table.

The approach I have been using is I set a variable to = 0 then I assign this value to one of the fields in the temp table. This works fine for the first record but there is a minor issue where it copies in the first record twice. Is there is an easy way to accomplish this task.
 

mhtan88

Member
define temp-table tempdb
field a as character
field b as integer.


define variable i as int.

do i = 1 to 10:
Create tempdb.
assign a = string(i).
assign b = i.
release tempdb.
end.

then it will create 10 records.
 

vexiteer

New Member
I see how all the records are being put into the temptable at the same time. How do I just input one record at a time.
 

mhtan88

Member
input one record at a time? meaning input different batch of records into one same temp-table in the same time?
 

vexiteer

New Member
I have a user input data into 6 fields. Then I validate the data in the fields. Next step I create a temptable and assign the screen-values of the fields into the the temp table which I am displaying via a browse. My question is how do I just limit one record from being created in the temp table if I am creating a bunch of records at the beginning.
define variable i as int.
do i = 1 TO 10:
CREATE temp_table.
ASSIGN
temp_table.field1 = field1:SCREEN-VALUE NO-ERROR.
temp_table.field2 = field2:SCREEN-VALUE NO-ERROR.
temp_table.field3 = field3:INPUT-VALUE NO-ERROR.
temp_table.field4 = field4:SCREEN-VALUE NO-ERROR.
temp_table.field5 = field5:SCREEN-VALUE NO-ERROR.
temp_table.field6 = field6:SCREEN-VALUE NO-ERROR.
temp_table.field7 = field7:SCREEN-VALUE NO-ERROR.
temp_table.field8 = i NO-ERROR.
release temp_table.
 

mhtan88

Member
/*=================your coding==============*/
define variable i as int.
do i = 1 TO 10:
CREATE temp_table.
ASSIGN
temp_table.field1 = field1:SCREEN-VALUE NO-ERROR.
temp_table.field2 = field2:SCREEN-VALUE NO-ERROR.
temp_table.field3 = field3:INPUT-VALUE NO-ERROR.
temp_table.field4 = field4:SCREEN-VALUE NO-ERROR.
temp_table.field5 = field5:SCREEN-VALUE NO-ERROR.
temp_table.field6 = field6:SCREEN-VALUE NO-ERROR.
temp_table.field7 = field7:SCREEN-VALUE NO-ERROR.
temp_table.field8 = i NO-ERROR.
release temp_table.
/*=================End of your coding==============*/
I'm not really get what you mean. do you mean you just only allowed one record in that temp-table?
if yes, then the following sample might help you.

/* If let say your field1 is the key field */

find first temp_table where field1 = field1:screen-value no-error.
if not available(temp_table) then
do:
CREATE temp_table.
temp_table.field1 = field1:SCREEN-VALUE NO-ERROR.

end.
temp_table.field2 = field2:SCREEN-VALUE NO-ERROR.
temp_table.field3 = field3:INPUT-VALUE NO-ERROR.
temp_table.field4 = field4:SCREEN-VALUE NO-ERROR.
temp_table.field5 = field5:SCREEN-VALUE NO-ERROR.
temp_table.field6 = field6:SCREEN-VALUE NO-ERROR.
temp_table.field7 = field7:SCREEN-VALUE NO-ERROR.
temp_table.field8 = i NO-ERROR. /* this i value depend on you how u want to set */
release temp_table .

in this case. only one record will only added in in the temp-table.
 
Top