Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INSERT - SQL and macro/name substitution
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00057491
Message ID:
00057583
Views:
33
>>>>I have a button bar class with properties that hold the names of the aliases used for the form and its grid. The method for adding records has some code which uses INSERT - SQL. Since it's a class, the alias names can't be hard-coded, of course. They need to come from the class property, which is filled in the instance of the form. I'm trying various ways to use macro or name substitution, but I can't get the syntax right. My latest attempt goes like this:
>>>>
>>>>cAlias1 = THIS.Parent.Alias1;
>>>> +'('+THIS.Parent.FieldName1;
>>>>+','+THIS.Parent.FieldName2+')'
>>>>INSERT INTO &cAlias1. VALUES(var1,var2)
>>>
>>>Assuming that you reference correctly the properties you are using, this syntax is correct. So, probably, the cAlias1 variable doesn't contain what you think it does.
>>>
>>>Put a SET STEP ON before INSERT and check cAlias1 in the debugger. If it still looks correct, go to the Command window and type the INSERT command with the value of the cAlias1 instead of the macrosubst. If you still have the error, look to see if you really have the alias and the fields. Also, be careful to not have a reserved word as alias.
>>>
>>>>I also tried INSERT INTO (cAlias1) VALUES(var1,var2) and I still get syntax errors.
>>>
>>>This is not correct. After the macrosubst VFP will execute something like:
>>>
>>>INSERT INTO (MyAlias (Field1,Field2)) VALUES(var1,var2)
>>>
>>>Vlad
>>
>>I failed to include a space between the MyAlias and the (Field1,Field2). That was all it was.
>
>I also tried that and it worked without a space. What is the actual MyAlias in your case? Is it a reserved word in VFP?
>
>Vlad

I use vfp3. That might have something to do with it. MyAlias is 'ceska', Field1 is 'hmrfmr_id', and Field2 is 'ska_id'.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform