Can anybody create a new employee record with name and address on existing table "Employee" ; other non-primary fields remaining same as employee with id '1'.
Use buffer-create() and Buffer-copy() method.
não for possível, eu estou muito ocupado !!
i didn't get it.
i only know english.
please help ,
urgent.
If Question can't be understood then please read this.
1. define temtable first.
2. buffer copy of DB table to temptable.
3. then assign the new name and address on the field.
4. buffer copy of temptable to the DB table.
5. then display the result(DB table).
hope u will understand this.
Solution:
/* Create a new employee record with your name and address; other non-primary fields remaining same as
employee with id '1'.(use buffer-copy method) */
define variable tt-table as handle no-undo.
define variable bf-cust as handle no-undo.
define variable bf-tttable as handle no-undo.
define variable v-empn as integer no-undo.
/* Get database table handles */
bf-cust = buffer Employee:handle.
/* Create an empty, undefined TEMP-TABLE */
create temp-table tt-table.
/* Give it employee table’s fields & indexes */
tt-table:create-like (bf-cust).
/* Add field like employee.firstname employee.address */
/* tt-table:add-like-field("firstname","Employee.firstname").
tt-table:add-like-field("lastname","Employee.lastname"). */
tt-table:temp-table-prepare("emps").
/* Get the buffer handle for the temp-table */
bf-tttable = tt-table:default-buffer-handle.
find last Employee no-lock no-error.
if avail Employee then
assign v-empn = Employee.EmpNum + 1 .
for each Employee where Employee.EmpNum = 1 exclusive-lock:
bf-tttable:buffer-create.
bf-tttable:buffer-copy(bf-cust).
bf-tttable:buffer-field('firstname'):buffer-value="utsav".
bf-tttable:buffer-field('lastname'):buffer-value="pokhrel".
bf-tttable:buffer-field('empnum'):buffer-value=v-empn.
end.
do transaction:
bf-cust:buffer-create.
bf-cust:buffer-copy(bf-tttable).
end.
for each Employee no-lock:
display Employee.FirstName Employee.LastName Employee.EmpNum.
end.