pitfloner
2nd June 2003, 17:03
When I try to compile the following function, the compiler shows me the error "<variable> not declared" for each field declared in the previous select which uses an alias in its declaration.

Does anyone know the reason?

select torigen.*
from tisfc961 torigen
where torigen._index1 = {:etiqueta.origen}
and torigen.stat=1
selectdo
db.retry.point()
select tisfc961.*
from tisfc961 for update
where tisfc961._index1 = {:etiqueta.destino}
selectempty
tisfc961.stat=torigen.stat
tisfc961.expo=torigen.expo
tisfc961.expd=torigen.expd
tisfc961.npre=torigen.npre
db.insert(ttisfc961,db.retry)
commit.transaction()
endselect
endselect

richard
2nd June 2003, 18:20
I don't know if it's absolutely necessary, but we use this kind of programming with intermediate variables:

example:

select tibom010.*,
bomlus.sitm:lu.sitm,
from tibom010,tibom010 bomlus
where ...

In the following code, we use lu.sitm ...


regards

dorleta
2nd June 2003, 18:59
the right way to do this is:


select torigen..stat:var.stat, torigen.expo:var.expo.....
from tisfc961 torigen
where torigen._index1 = {:etiqueta.origen}
and torigen.stat=1
selectdo
db.retry.point()
select tisfc961.*
from tisfc961 for update
where tisfc961._index1 = {:etiqueta.destino}
selectempty
tisfc961.stat=var.stat
tisfc961.expo=var.expo
tisfc961.expd=var.expd
tisfc961.npre=var.npre
db.insert(ttisfc961,db.retry)
endselect
commit.transaction()
| to close the transaction in other way you can get a transaction | is on
endselect

Dikkie Dik
3rd June 2003, 09:58
Each table (field) is a global variable. The alias table can only be used inside the query and not outside. To use alias tablefields outside the query each field must be bind as dorleta wrote.

Hope this helps,
Dick