PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WINDEV
WINDEV
Iniciado por Vinit Sawant, 23,nov. 2017 08:52 - 5 respuestas
Publicado el 23,noviembre 2017 - 08:52
Hi,
We have WINDEV application. In that we are having one button.
But when we click on the button we are getting following error:

Le champ 'Table_sousComposantsPossibles' n'a pas pu s'initialiser, car il a rencontré l'erreur Hyper File suivante :
=============================
Erreur dans le code SQL de la requête . Initialisation de la requête impossible.
Mot %% inattendu
=============================

Informations techniques

Projet : Adage

Dump de l'erreur du module <12.00Pyn>.

- Niveau : erreur fatale (EL_FATAL)

SQL code is:
SELECT C1.Code_Composant AS Code_Composant,
C1.Nom_Site AS Nom_Site,
C1.Base AS Base,
C1.description AS description,
C1.Reference_Plan AS Reference_Plan,
C1.Indice_Plan AS Indice_Plan,
C1.Id_Contrainte AS Id_Contrainte,
C1.Cfig AS Cfig,
C1.Unite_Quantite AS Unite_Quantite,
C1.type AS type,
C1.ApS AS ApS
FROM
ADAGE_S_Composants C1
WHERE
C1.Nom_Site = {p_Site}

AND C1.Code_Composant <> {p_CodeComposantPere}
AND C1.Code_Composant LIKE %{pComposant}%
AND C1.description LIKE %{pDescription}%

-- on n'autorise pas l'insertion d'un frère
AND C1.Code_Composant NOT IN
(SELECT COR.Nom_Composant_Fils
FROM ADAGE_S_Correspondance_Operations_CompFils COR
WHERE COR.Nom_Composant_Operation_Mere={p_CodeComposantPere}
AND COR.Nom_Site_Operation_Mere = {p_Site}
AND COR.Nom_Site_Composant_Fils = {p_Site}
AND COR.Numero_Ordre_Operation_Mere = {p_OrdreOperation})
AND

-- on n'autorise pas l'insertion d'un ancêtre (vérif sur 1 génération, on ne vérifie pas plus loin)
C1.Code_Composant NOT IN
(SELECT COR2.Nom_Composant_Operation_Mere
FROM ADAGE_S_Correspondance_Operations_CompFils COR2
WHERE COR2.Nom_Composant_Fils={p_CodeComposantPere}
AND COR2.Nom_Site_Operation_Mere = {p_Site}
AND COR2.Nom_Site_Composant_Fils = {p_Site})

UNION ALL


According to the error, % is unexpected.
I removed % but still code is not working.
Does anyone have any idea about this?
How to fix this issue?
Thanks in advance
Publicado el 23,noviembre 2017 - 09:04
Hi,
just copy the statement, insert it in the hfsql control center, replace the variables by valid values and execute the statement. This way it is much easier to see where the error comes from.
Publicado el 23,noviembre 2017 - 11:25
Hi

the error message says that you have an unexpected '%%' in your query

The only way I see that you can have that is if you forget to fill one of the parameters that is between 2 %.

However, as you are not showing us the code that is calling the query, there is no way to verify that

Best regards
Publicado el 23,noviembre 2017 - 21:09
I'm seeing the same message when I leave a report filter blank (deliberately). In other reports of mine, when the filter is empty (null?) the entire clause is ignored, but possibly this doesn't happen when using the LIKE operator.
Publicado el 23,noviembre 2017 - 22:28
I think it is a syntax error in LIKE, you may have
LIKE '%my description%'
or
LIKE '%' + "myDescription" + '%'
or

sDescription is string = "myDesc"

LIKE '%' + sDescription + '%'

ie single quote is needed for beginning and end and watch out if you have
single to inside sDescription also.

HTH

King
Publicado el 23,noviembre 2017 - 23:00
Kingdr: when using Reports & Queries (query editor), the query does not require quotes around parameters. That's to say, when the report is run, if quotes have been added, an error will occur.

However, if you want to test the query in query editor, the quotes are required. So I end up putting them in, testing the query, then removing them to test/develop the report.