Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a limit for selexec()?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01317869
Message ID:
01317879
Views:
10
Quick note here. 1st what Sergey said is how we do it and it works great. 2nd: replace the
text TO lcSql noshow
with
TEXT TO sqltxt noshow pretext 15 TEXTMERGE
and you won't have to use the
sqltxt = CHRTRAN(lcSql, CHR(13), CHR(10), '')
the PRETEXT 15 parameter does it for you.
John.

>Hi Koen,
>
>A string literal in VFP is limited to 255 characters. It's better to build only SQL command with text-merge. The macro substitution will go away as well.
>Also you should check return value after SQLEXEC() to make sure that it completed successfully.
>
>lcSql = ""
>text TO lcSql noshow
>select myPrimaryId, mySecondayId,cDtTitle,
>	cEnTitle, cDtMaterial, cEgMaterial,ceDtFormat, ceEgFormat,
>	coalesce(DtPrtcopy,'') as DtPrtcopy,
>	coalesce(EgPrtcopy,'') as EgPrtcopy,
>	coalesce(DtSPrice,'') as DtSPrice
>  from HORSART_WORKS
>endtext
>sqltxt = CHRTRAN(lcSql, CHR(13), CHR(10), '')
>lcResult = sqlexec(lnRet, lcSql,"curHorsart_Works")
>IF lcResult < 0
>  * Error
>ENDIF
>
>>
>>Working with remote MySql database and local VFP.DBC
>>
>>Following code works alright:
>>
>>sqltxt=''
>>text TO sqltxt noshow
>>	sqlexec(lnRet,"select myPrimaryId, mySecondayId,cDtTitle,
>>			cEnTitle, cDtMaterial, cEgMaterial,ceDtFormat, ceEgFormat,
>>			coalesce(DtPrtcopy,'') as DtPrtcopy,
>>			coalesce(EgPrtcopy,'') as EgPrtcopy,
>>			coalesce(DtSPrice,'') as DtSPrice
>>			from HORSART_WORKS","curHorsart_Works")
>>endtext
>>sqltxt = strtran(sqltxt,chr(10), '')
>>sqltxt = strtran(sqltxt,chr(13), '')
>>&sqltxt
>>
>>cursor gets loaded.
>>However adding just one more field to this scenario viz:
>>
>>sqltxt=''
>>text TO sqltxt noshow
>>	sqlexec(lnRet,"select myPrimaryId, mySecondayId,cDtTitle,
>>			cEnTitle, cDtMaterial, cEgMaterial,ceDtFormat, ceEgFormat,
>>			coalesce(DtPrtcopy,'') as DtPrtcopy,
>>			coalesce(EgPrtcopy,'') as EgPrtcopy,
>>			coalesce(DtSPrice,'') as DtSPrice,
>>			coalesce(EgSPrice,'') as EgSPrice
>>			from HORSART_WORKS","curHorsart_Works")
>>endtext
>>sqltxt = strtran(sqltxt,chr(10), '')
>>sqltxt = strtran(sqltxt,chr(13), '')
>>&sqltxt
>>
>>will result in Error : "Command contains unrecognized phrase/keyword"
>>
>>If I launch Sqlyog the 2ndquery is executed as it should be.
>>
>>It seems to be there is a limit to the maxnmbr of characters, when I delete any column in the 2nd Select statement it results a correct cursor.
>>
>>I am at lost what is going on, and would like to know how to solve this one.
>>Regards,
>>
>>Koen
Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform