>hi, i want to add a column to a table during program run time. the name of the column will be input by user into a text box and be used as the name of the column. so the name is a variable and dynamic depending on what is being keyed in. how can i tell the system that the column name is a variable. i tried the following command but a syntax error message popup:
>
>ALTER TABLE ADD COLUMN varname C(20)
>
>thanks
You can use a name expression (parentheses):
myvar = "Column1"
alter table abc add column (MyVar) N(2)
Or a macro substitution:
myvar = "Column1"
alter table abc add column &MyVar N(2)
The first alternative is faster in most cases, so it should be preferred. The second offers you access to some features that are not available if you use only name expressions - you can substitute entire commands.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)