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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limited select statement when inside the qoutation

Status
Not open for further replies.

creedprg

MIS
Aug 31, 2005
18
PH
Hello everyone,

im having problem with this select statement, whenever i put my select statement inside the quotation i encounter problem it says unrecognized command. is there any limitation in select statement when i put it inside the quotation mark?

here is my example of code. i always received error when my select statement become more longer inside the quotation.

SQLExec(1,"select vouchers.voucherno,vouchers.original,vouchers.source,vouchers.flowcardno,;
vouchers.qty,vouchers.actualqty,vouchers.accepterd,vouchers.good,vouchers.nogood,;
vouchers.inc_no1,vouchers.inc_no2,vouchers.inc_no3,incident.* ;
from vouchers inner join incident ON vouchers.voucherno=incident.voucherno ;
where vouchers.year_cov=?varyear_cov and vouchers.month_cov=?varmonth_cov","ese1")


but if i put it outside the quotation i don't have error.

select vouchers.voucherno,vouchers.original,vouchers.source,vouchers.flowcardno,;
vouchers.qty,vouchers.actualqty,vouchers.accepterd,vouchers.good,vouchers.nogood,;
vouchers.inc_no1,vouchers.inc_no2,vouchers.inc_no3,incident.* ;
from vouchers inner join incident ON vouchers.voucherno=incident.voucherno ;
where vouchers.year_cov=?varyear_cov and vouchers.month_cov=?varmonth_co

Thanks in advance.
 
This has got nothing to do with SELECT statements. You have simply come up against the limit of 255 charactes in a string literal. Any string that is within quotation marks must be 255 characters or less.

The best way to deal with this is to use a TEXT/ENDTEXT construct. Something like this:

Code:
TEXT TO lcCommand NOSHOW
select vouchers.voucherno,vouchers.original,vouchers.source,vouchers.flowcardno,
vouchers.qty,vouchers.actualqty,vouchers.accepterd,vouchers.good,vouchers.nogood,
vouchers.inc_no1,vouchers.inc_no2,vouchers.inc_no3,incident.* 
from vouchers inner join incident ON vouchers.voucherno=incident.voucherno 
where vouchers.year_cov=?varyear_cov and vouchers.month_cov=?varmonth_cov
ENDTEXT

SQLExec(1, lcCommand, "ese1")

Note that you do not put semi-colons at the ends of lines when you use this construct.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 

Note, this limit is not a string variable limit, strings can be up to 16MB long, even longer than that, just some functions won't handle longer strings.

The 255 char limit is only a limit of the compiler for string literals in source code. The limit can also be overcome by ending a part of the string and using + to concat the next 255 chars,
eg stringvar = "...255 chars..."+"...another 255 chars..." is possible, yet the best solution for queries is to use TEXT..ENDTEXT anyway.

Bye, Olaf.
 
[bigears]
thank you so much guys... this is a big help


Highly appreciated problem solved.


thanks mike and olaf :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top