Kozure Ohashi
5th March 2007, 12:59
Dear baanboard,
strange situation:
Using a tablealias in a select statement.
My knowledge up to now. The table pointer is not moved because of the alias.
I debugged a session -> the record pointer is moved.
Only solution: Map the tablefield to a customized var -> the record pointer is not moved.
Example:
tdsls045.orno = 123456
orno.f = 234567
Record pointer moved:
select tdsls045_1.orno
from tdsls045 tdsls045_01
where tdsls045_01._index1 = {:orno.f}
selectdo
endselect
-> tdsls045.orno is 234567
Record pointer not moved:
select tdsls045_1.orno:my.orno
from tdsls045 tdsls045_01
where tdsls045_01._index1 = {:orno.f}
selectdo
endselect
-> tdsls045.orno is 123456 // my.orno = 234567
Can somebody please explain me this behaviour (esspecially why the aliasing is not preventing the movement of the recordpointer).
This results in an error in printing sales invoices in connection with instalments.
Regards,
Kozure
mr_suleyman
5th March 2007, 13:40
This is a good fix. But I couldn't use second one.I can only use alies with third one coding.In second one ,AFAIK In selectdo the debugger doesn't recognize tdsls045_1.orno.You must use extra variables. I wonder that do you use second statement in your programming and How ?
I don't have any comment about your fix .
G.Luck !
Kozure Ohashi
5th March 2007, 14:16
Dear Baanboard,
just a sample script, you can run it in the debugger and understand my problem. Please modify the ordernumbers to existing ones on your system.
My problem is to understand, why the table alias is not preventing the move of the record pointer. Up to now this was my understanding of the usage of the table alias.
3 GL Script Sample Script:
function main()
{
table ttdsls045
table ttdsls048
extern domain tcorno sls048.orno, sls045.orno, my.orno
sls048.orno = 200000 | Modify to an existing order number
sls045.orno = 100000 | Modify to an existing order number
set.record.pointer.sls045() | 1. set the tdsls045 pointer
table.alias.without.var.mapping() | 2. record pointer moved (-> WHY?????)
set.record.pointer.sls045() | 3. reset the tdsls045 pointer
table.alias.with.var.mapping() | 4. record pointer NOT moved
set.record.pointer.sls045() | 5. reset the tdsls045 pointer
no.table.alias.with.var.mapping() | 6. record pointer NOT moved (-> best solution)
}
function domain tcbool table.alias.without.var.mapping()
{
| WHY is this not working, why is the record pointer tdsls045.orno moved ???
select tdsls045_1.orno
from tdsls045 tdsls045_1
where tdsls045_1._index1 = {:sls048.orno}
as set with 1 rows
selectdo
return(false)
endselect
return(true)
| tdsls045.orno is now 20000 but why.
| My estimation: tdsls045.orno = 100000 // tdsls045_1.orno = 20000 ???
}
function domain tcbool table.alias.with.var.mapping()
{
| Var mapping is enough, table alias is not necessary
select tdsls045_1.orno:my.orno
from tdsls045 tdsls045_1
where tdsls045_1._index1 = {:sls048.orno}
as set with 1 rows
selectdo
return(false)
endselect
return(true)
|tdsls045.orno is still 100000
|my.orno is now 200000
}
function domain tcbool no.table.alias.with.var.mapping()
{
select tdsls045.orno:my.orno
from tdsls045
where tdsls045._index1 = {:sls048.orno}
as set with 1 rows
selectdo
return(false)
endselect
return(true)
| tdsls045.orno is still 100000
| my.orno is 200000
}
function domain tcbool set.record.pointer.sls045()
{
select tdsls045.orno
from tdsls045
where tdsls045._index1 = {:sls045.orno}
as set with 1 rows
selectdo
return(false)
endselect
return(true)
}
Regards,
Kozure
mark_h
5th March 2007, 16:28
Because this "select tdsls045_1.orno" does not have script variable it goes back to the tdsls045.orno variable - which is what it is tied to in this case. I never really thought about this until this post - I checked my scripts and I never use an alias unless I tie it to a script variable. I think I ran into this once before in the same type situation.