Reputation:
I want to create a temp-table for generalized code maintenance(code_mstr) such that the input I give in GCM does not hit the database but instead is stored in a temporary table from where I can update or delete the records. which has the fields
code_fldname
code_value
code_cmmt
code_group
I am very new to progress and this task is a little daunting as I am not understanding how to begin, I have been going through examples and syntax of temp-table, the only thing I managed to write so far is this code which Im not sure is correct or not
define temp-table tt_gcm no-undo
field tt_fldname like code_fldname
field tt_value like code_value
field tt_cmmt like code_cmmt
field tt_group like code_group
field tt_domain like global_domain
index tt_idx
tt_domain
tt_fldname
tt_value.
and after this I defined a form for the same
form
code_fldname
code_value
code_cmmt
code_group
with frame a side-labels
now suppose if I enter a particular record in code_mstr, I want only that one particular record to be visible in the temp-table rather than all the records that are in code_mstr, any help on how to proceed with that would be appreciated.
Upvotes: 0
Views: 685
Reputation: 3379
If you can keep your temp-table field names the same as your database field names, you can use the buffer-copy
statement. It will copy all matching fields from one to the other.
define temp-table tt_gcm no-undo
field global_domain like code_mstr.global_domain
field code_fldname like code_mstr.code_fldname
field code_value like code_mstr.code_value
field code_cmmt like code_mstr.code_cmmt
field code_group like code_mstr.code_group
index tt_idx // add is unique?
global_domain
code_fldname
code_value
.
for each code_mstr no-lock:
create tt_gcm.
buffer-copy code_mstr to tt_gcm.
end.
Upvotes: 0
Reputation: 14020
Something along these lines will fill your temp-table:
for each code_mstr no-lock:
create tt_gcm.
assign
tt_gcm.tt_fldname = code_mstr.code_fldname
tt_gcm.tt_value = code_mstr.code_value
tt_gcm.tt_cmmt = code_mstr.code_cmmt
tt_gcm.tt_group = code_mstr.code_group
tt_gcm.tt_domain = code_mstr.global_domain
.
end.
and this will display the data in the form that you created:
for each tt_gcm:
display tt_gcm with frame a.
end.
Upvotes: 0