ken bohnenkamp
27th April 2007, 17:32
Is there a way to update an alias table

I currently am trying the following without much success:

select alias004.elim:a.elim
from arcom004 alias004 for update
where alias004._index1 = {:arcom004.stnl}

selectdo
a.elim = tcyesno.yes
db.update(tarcom004, db.retry)
endselect

Any help would be appreciated

mr_suleyman
27th April 2007, 17:45
Hi
your alias usage is wrong. It should be like

select alias004.elim:a.elim
from arcom004 alias004 for update
where alias004._index1 = {:arcom004.stnl}
selectdo
arcom004.elim = tcyesno.yes
db.update(tarcom004, db.retry)
endselect

AFAIK , Alias doesn't work in selectdo statement. YOu should use real table name. Alias can be used for different aims
G.Luck !

en@frrom
2nd May 2007, 13:42
What I do in such cases: I store the current record to buffer, then read from the same table again, INSTEAD OF USING ALIAS, update the table, and restore the buffer...

ken bohnenkamp
2nd May 2007, 14:52
Can you post an example of what your code looks like? Thanks.

en@frrom
2nd May 2007, 14:59
Here is an example for table tdsls401


string record.buf(1) based
domain tcmcs.long record.len

if not record.len then
db.row.length(ttdsls401, record.len)
alloc.mem(record.buf, record.len)
endif
record.buf = rcd.ttdsls401

select tdsls401.*
from tdsls401 for update
where ....
selectdo
......
db.update(ttdsls401, db.retry)
endselect

rcd.ttdsls401 = record.buf


Hope this helps..

Regards,
Eli Nager