shaboo
13th July 2004, 01:27
We have created a history table for one of our custom table and actually the history table is same as main table but with different index. The records in the main table gets deleted during one of the processes but we want to keep a history of certain kind of records and that is why we have created a history table.

As I did not want to do lot of changes in the session that processes the main table and delete records, I decided to create a separate dll so that before deleteing the records, the program will call this dll and that dll will post that record into this new history table. An easier way to achieve this would have been to pass on all the values to the dll function and then simply that dll function updates the new table. Now I am wondering if it is possible to pass on the record buffer to a dll call and if yes, then could someone look at the code below and tell me if I am doing something wrong.

In the main program script I have

string rec.buffer(1) based
long rec.length
....
if not rec.length then
db.row.length (ttdabc251,rec.length)
alloc.mem (rec.buffer, rec.length)
endif
rec.buffer = rcd.ttdabc251
....
tdabcdll0002.fill.order.history (rec.buffer)


And then in my dll I have



function extern tdabcdll0002.fill.order.history(string record.buffer(1))
{
db.insert(ttdabc500, DB.RETRY)
rcd.ttdabc500 = record.buffer(1)
commit.transaction()
}


The program crashes and I get the message "Error 606 (Reference does not exist) on tdabc500200 in commit_trans"

Any ideas? Is this due to difference in indices of two tables?

Thanks in advance for your help.

malutz
13th July 2004, 08:34
Hej,

I wrote a simular programm just some month ago. First I experienced the same problem as you did. After some debugging I found that some hidden flags changes during my process.

This could be avoided by saving the fields before. Here a copy from the essenctial lines:


dlock_number = tcmcs023._dlock
save_company = tcmcs023._compnr
rcd.ttcmcs023 = buffer
tcmcs023._dlock = dlock_number
tcmcs023._compnr = save_company

I guess that you will not need the company number, since i copied the records between different companies though it was necessary for me.

Hope this helps. :D

dorleta
13th July 2004, 16:13
Maybe some this


function extern archive.table(
string table.name(8),
domain tcncmp comp.org,
domain tcncmp comp.arch)
{
pointer.org = db.bind("t"&table.name,"",comp.org)
pointer.arch = db.bind("t"&table.name,"",comp.arch)

if pointer.org > 0 and pointer.arch > 0 then
db.first(pointer.org) |or another one

db.retry.point()

db.record.to.columns(pointer.arch)
db.insert(pointer.arch, db.retry, db.return.dupl)

commit.transaction()

db.unbind(pointer.org)
db.unbind(pointer.arch)
else
| troubles with company permisions probably
endif
}



good luck

wiggum
14th July 2004, 11:30
Try:


function extern tdabcdll0002.fill.order.history(ref string record.buffer())
{
rcd.ttdabc500 = record.buffer
db.insert(ttdabc500, DB.RETRY)
commit.transaction()
}