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.
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.