![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I got bit in an interesting way today. I have not seen this documented elsewhere. Just before the following statement, wonbr is defined. Nonetheless, the following statement throws the error "Variable 'WONBR' is not found.". insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,wonbr) The catch is that wonbr is a column in another table. Apparently, while executing the insert, VFP internally changes the work area. This results in wonbr no longer being a valid name, and the error occurs. I replaced the above with local extwonbr extwonbr=wonbr insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,extwonbr) and all was fine. Sincerely, Gene Wirchenko |
#3
| |||
| |||
|
|
I got bit in an interesting way today. I have not seen this documented elsewhere. Just before the following statement, wonbr is defined. Nonetheless, the following statement throws the error "Variable 'WONBR' is not found.". insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,wonbr) The catch is that wonbr is a column in another table. Apparently, while executing the insert, VFP internally changes the work area. This results in wonbr no longer being a valid name, and the error occurs. I replaced the above with local extwonbr extwonbr=wonbr insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,extwonbr) and all was fine. Sincerely, Gene Wirchenko |
#4
| |||
| |||
|
|
Gene, You could also just add the table's alias. e.g. insert into (woxref); (currwonbr,nmwonbr) values (savewonbr, mytable.wonbr) Rick "Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote in message news:r15gv0li69v5n3dnm044uiojoknch1r1n2 (AT) 4ax (DOT) com... I got bit in an interesting way today. I have not seen this documented elsewhere. Just before the following statement, wonbr is defined. Nonetheless, the following statement throws the error "Variable 'WONBR' is not found.". insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,wonbr) The catch is that wonbr is a column in another table. Apparently, while executing the insert, VFP internally changes the work area. This results in wonbr no longer being a valid name, and the error occurs. I replaced the above with local extwonbr extwonbr=wonbr insert into (woxref); (currwonbr,nmwonbr) values (savewonbr,extwonbr) and all was fine. Sincerely, Gene Wirchenko |
#5
| |||
| |||
|
|
I always include the table alias when refering to fields. It makes the code *much* easier to read and work with later. |
|
And it also avoids conflicts like you encountered. |
#6
| |||
| |||
|
|
Or if you wanted to explicitly use the memvar, use the m. prefix. |
|
The catch is that wonbr is a column in another table. |
#7
| |||
| |||
|
|
On Wed, 26 Jan 2005 16:24:32 -0800, "Dan Freeman" <spam (AT) microsoft (DOT) com wrote: Or if you wanted to explicitly use the memvar, use the m. prefix. What memvar? [snip] The catch is that wonbr is a column in another table. [snip] Sincerely, Gene Wirchenko |
#8
| |||
| |||
|
|
On Thu, 27 Jan 2005 16:56:34 GMT, trw7at (AT) ixdot (DOT) netcomdotcom (Tim Witort) wrote: I always include the table alias when refering to fields. It makes the code *much* easier to read and work with later. I avoid aliases where possible for exactly that reason. If the expressions are long, it makes them that much harder to follow. And it also avoids conflicts like you encountered. I would call what I ran into a minor bug. [snip] Sincerely, Gene Wirchenko Actually I would not call this a bug as the docs do state more than once |
#9
| |||
| |||
|
|
Actually I would not call this a bug as the docs do state more than once that nothing can be assumed about the environment when any of the SQL commands are being run. Any time I do something SQL wise that doesn't |
|
imply the alias/table name I put it in there as the work are your in not only isn't guaranteed to be the same as what you thought it would be, it's not really even guaranteed to be the same each time. |
#10
| |||
| |||
|
|
On Thu, 27 Jan 2005 16:56:34 GMT, trw7at (AT) ixdot (DOT) netcomdotcom (Tim Witort) wrote: I always include the table alias when refering to fields. It makes the code *much* easier to read and work with later. I avoid aliases where possible for exactly that reason. If the expressions are long, it makes them that much harder to follow. uhhh, no. code is much easier to follow if the full data names |
|
And it also avoids conflicts like you encountered. I would call what I ran into a minor bug. in YOUR code, not in foxpro. it worked AS DESIGNED and as |
![]() |
| Thread Tools | |
| Display Modes | |
| |