|
| Inicio → WINDEV 2024 → [WB19] - Help with SQL Statement - unexpected word "," |
| [WB19] - Help with SQL Statement - unexpected word "," |
| Iniciado por guest, 18,ago. 2015 12:03 - 3 respuestas |
| |
| | | |
|
| |
| Publicado el 18,agosto 2015 - 12:03 |
Hi - Can't figure this out -
sSQL is string = [ Select gpoDB:m_sdContactList_ActiveOrEnrolled.GUIDHFContact, gpsdContact.sFirstName, gpsdContact.sLastName, gpsdContact.nContactSimpleID FROM gpoDB:m_sdContactList_ActiveOrEnrolled, gpsdContact WHERE gpsdContact.GUIDHFContact = gpoDB:m_sdContactList_ActiveOrEnrolled.GUIDHFContact ORDER BY gpsdContact.sLastName, gpsdContact.sFirstName ]
IF NOT HExecuteSQLQuery(gpoDB:m_sdReportSource,sSQL) THEN gpoError:CaptureError(HErrorInfo()) // Error while declaring the file, display the error END
I keep getting the error - Unexpected Word ","
gpoDB:m_sdContactList_ActiveOrEnrolled is a Data Source initialized earlier. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,agosto 2015 - 12:40 |
Hi Joel
1. if you use the query editor, you won't have this kind of problems, as the syntax will ALWAYS be correct
2. I'm guessing that your problem comes from the parameter gpoDB:m_sdContactList_ActiveOrEnrolled.GUIDHFContact. - It probably needs to be between quotes - and it should be replaced by the value before doing the hexecutesqlquery. hexecutesqlquery just uses the string AS IS (and I'm pretty sure that it doen't know "gpoDB:m_sdContactList_ActiveOrEnrolled.GUIDHFContact"
So my advise: use the query editor, declare a parameter in it for your condition, and set the parameter before doing a simple hexecuteQuery
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,agosto 2015 - 14:14 |
Hi Fabrice and thank you. Can't use the Query Editor because there is no analysis in the Project. Analysis is in only 1 project module - the Login Module. Physical Data Files are made each time that Project is opened if they don't yet exist. All other projects use HDeclareExternal to connect to the datafiles. This is a little embarrassing, but at the moment, I can't remember why I did that. It was to solve some problem, but I can't remember why I didn't just share the Analysis in each project. I broke the one massive Project into about 15+ smaller one - makes changes and updates much easier. Anyway, I've had to learn SQL to create Data Sources as a result.
I was kinda thinking that the SQL couldn't understand the "gpoDB: m_sdContactList_ActiveOrEnrolled.GUIDHFContact" parameter, but was hoping that wasn't it. Ugh! |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,agosto 2015 - 17:19 |
Hi Joel,
With text sql queries you need to use stringbuild to insert parameters into the query: gpsdContact.GUIDHFContact = '%1' ORDER BY gpsdContact.sLastName, gpsdContact.sFirstName ] IF NOT HExecuteSQLQuery(gpoDB:m_sdReportSource,StringBuild(sSQL,gpoDB:m_sdContactList_ActiveOrEnrolled.GUIDHFContact)) THEN Regards, Piet |
| |
| |
| | | |
|
| | | | |
| | |
|