Buffer-create() and Buffer-copy() method.

Posted by Admin on 21-Jun-2011 04:26

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.

All Replies

Posted by rohit.ramak on 21-Jun-2011 04:31

não for possível, eu estou muito ocupado !!   

Posted by Admin on 21-Jun-2011 04:42

i didn't get it.

i only know english.

please help ,

urgent.

Posted by Admin on 21-Jun-2011 06:23

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.

Posted by Admin on 21-Jun-2011 06:42

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.

This thread is closed