ken bohnenkamp
25th September 2002, 19:52
I have a table called profile and a table called restencil. I have a form that has a field called Car ID and has Profile as the main table. In the after.input procedure for the car id field I would like to set the car id of the restencil table to the car id of the profile table and then write out this new record to the restencil table. Can anyone supply me with the proper syntax to do this logic.
dbinderbr
25th September 2002, 22:28
Well, if I got the idea you have this situation:
Table 1 - Profile
car.id
... (other fields)
Table 2 - Restencil
car.id
... (other fields)
And each record you insert in table 1 you want to have it inserted in table 2, right?
Maybe it would be better to use the following:
main.table.io:
after.write:
insert.record.in.restencil()
functions:
function insert.record.in.restencil()
{
|# ttxxx999 = table restencil
|# ttxxx998 = table profile
|# The select bellow is just used to check if the record already
|# exist then you can update it or do nothing.
|# If you dont want to use the select clause you can use the
|# flag "db.skip.dupl" as the third argument for db.insert and
|# remove the select structure.
select ttxxx999.*
from ttxxx999
where ttxxx999.carid = :ttxxx998.carid
selectdo
break
selectempty
db.set.to.default(tttxxx999)
ttxxx999.carid = ttxxx998.carid
ttxxx999.???? = ttxxx998.???? |#???? = any other field
db.insert(tttxxx999, db.retry)
endselect
}
ulrich.fuchs
26th September 2002, 08:16
The main.table.io - after.write section is ok to do this. But leave out the db.retry.point() and the commit.transaction(). Otherwise you will get an error, since you are already within a transaction - the one of the standard program.
Check out this link concerning this issue:
http://www.baanboard.com/programmers_manual_baanerp_help_4gl_features_flow_of_standard_program
Regards,
Uli
hklett
26th September 2002, 09:20
One Remark:
You dont have to use the 'for update' clause in the query ,
because you do not modify an existing record.
ken bohnenkamp
26th September 2002, 15:28
Thanks to all for the help, your suggestions worked great!