>I needed to do a sql query and pick a column based on a variable. By trial and error I discovered the following worked.
>
>select desc, co;
>from lit;
>where lit.afscme="X";
>and lit.&vstate="X";
>and eng="X";
>and mbrpiece="X";
>into cursor test
>
>The use aof the & in front of the variable was pure luck.
>
>Is there any place that describes the syntax for the use and assignment of vairables. It seems as if I am always running into this type of problem in using and declaring variables.
>
>Thanks
Look at & in help
The & is used for macro substitution.
The variable name after the & is replaced with the content of the variable.
If you want to concatinate strings you can use the dot as delimiter.
so:
myvar = 'Hello '
? "&myvar.World"
gives Hello World
If you use it for table names, and want to specify a fieldname too as in:
? tablename.fieldname
has already a dot in it. Then you need a dot for the macro substitution and one for after the tablename.
myvar = 'mytable'
? &myvar..fieldname
gives you the content of the field.
You also can use this with objectnames and so on.