Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent: Select doesn't like variables:

Status
Not open for further replies.

FoxLearner

Programmer
Aug 29, 2002
93
US
Hi all
I got a problem all of a sudden. Select statements in my code doesn't like variables any more. For example:

LOCAL lcCursor, loTable
lcCursor = SUBSTR(SYS(2015), 3, 10)
SELECT * FROM (tcTable) ;
ORDER BY effdtereq DESC, prop_id DESC ;
INTO CURSOR (lcCursor)

It has been working for months, and suddenly it started today. "It says sintax error". No indication what so ever. The app is on production. Any immediate help is appreciated.
Thanks
Foxlearner
 
Did you upgrade to vfp8?

what version are you using?

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
FoxLearner,

I believe the error you got is because the variable contain a numeric value for the first character.

Try something like this:

LOCAL lcCursor, loTable
lcCursor = 'C_' + SUBSTR(SYS(2015), 3, 10)
SELECT * FROM (tcTable) ;
ORDER BY effdtereq DESC, prop_id DESC ;
INTO CURSOR (lcCursor)


-- AirCon --
 
Actually the problem is that your cursor name is starting with a numerical value '001' etc.. etc..

If lcCursor did not start with a numeric value it would be ok. I tested it on VFP7.

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Aircon, I think we typed this at the same time *wink*

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Due to the "timestamp" values that SYS(2015) returns, and your choice to use the SUBSTR(), the value is now starting with 0 (zero) - this is not a legal table/cursor name. There is really no reason to be limited by 8 characters in VFP, why not just use:
Code:
lcCursor = SYS(2015)
The extra two characters (including the leading "_") will ALWAYS work!

Rick
 
TeknoSDS,

Aircon, I think we typed this at the same time *wink*
LOL

Regards


-- AirCon --
 
You have been lucky in the past!
A cursor requires the first letter of its name to be an underscore or an alphabet.Date and time is used to generate this unique 10 character name.
The first letter in your system generated name is numeric thereby causing a syntax error.
 
Ali & Aircon,
I think all three of us figured it out about the same time - I'm just a really slow typist!

Rick
 
Thanks one and all. I don't know, this was working for months and suddenly this Syntax Error Came up. I changed the code to Sys(2015), instead of substring and it works fine. Thanks once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top