PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Remplir un tableau de structure à partir du résultat d'une requête
Remplir un tableau de structure à partir du résultat d'une requête
Iniciado por dj5f, 12,abr. 2019 22:47 - 7 respuestas
Miembro registrado
163 mensajes
Publicado el 12,abril 2019 - 22:47
Avec le code suivant, j'obtiens l'erreur :

«On ne peut pas affecter à une structure autre chose qu'une structure de même définition.»

STRéponsesPELN est une Structure
sNomClient est une chaîne UNICODE
sPrénomClient est une chaîne UNICODE
nIdClient est un entier sur 4 octets
nIdQuestion est un entier sur 1 octet
sQuestion est une chaîne UNICODE
sRéponseEnTexte est une chaîne UNICODE
sRéponseLettre est une chaîne UNICODE
nRéponseNuméro est un entier sur 2 octets
nQualification est un entier sur 1 octet
dDatePELN est une Date
nMois est un entier sur 1 octet
FIN

ReqPELN est une Requête SQL =
[
SELECT
clients.Nom,
clients.Prenom,
clients_pelns_reponses.idClient,
clients_pelns_reponses.idQuestion,
peln_questions.Question,
peln_questions_choix.ChoixTexte,
clients_pelns_reponses.ReponseLettre,
clients_pelns_reponses.ReponseNo,
peln_questions_choix.Qualification,
clients.DatePELN,
month(clients.DatePELN) AS mois
FROM
clients_pelns_reponses
JOIN
peln_questions
ON clients_pelns_reponses.idQuestion = peln_questions.idQuestion
JOIN
peln_questions_choix
ON clients_pelns_reponses.ReponseNo = peln_questions_choix.ReponseNo
JOIN
clients
ON clients_pelns_reponses.idClient = clients.ID_Client
ORDER BY
clients.Nom ASC,
clients.Prenom ASC,
clients_pelns_reponses.idClient ASC,
clients_pelns_reponses.idQuestion ASC
]

HExécuteRequête(ReqPELN)

stUneLigneRéponse est un STRéponsesPELN
tabRéponses est un tableau de STRéponsesPELN

POUR TOUT ReqPELN
stUneLigneRéponse.sNomClient = ReqPELN.Nom
stUneLigneRéponse.sPrénomClient = ReqPELN.Prenom
stUneLigneRéponse.nIdClient = ReqPELN.idClient
stUneLigneRéponse.nIdQuestion = ReqPELN.idQuestion
stUneLigneRéponse.sQuestion = ReqPELN.Question
stUneLigneRéponse.sRéponseEnTexte = ReqPELN.ChoixTexte
stUneLigneRéponse.sRéponseLettre = ReqPELN.ReponseLettre
stUneLigneRéponse.nRéponseNuméro = ReqPELN.ReponseNo
stUneLigneRéponse.nQualification = ReqPELN.Qualification
stUneLigneRéponse.dDatePELN = ReqPELN.DatePELN
stUneLigneRéponse.nMois = ReqPELN.Mois

TableauAjouteLigne(tabRéponses,
stUneLigneRéponse.sNomClient,
stUneLigneRéponse.sPrénomClient,
stUneLigneRéponse.nIdClient,
stUneLigneRéponse.nIdQuestion,
stUneLigneRéponse.sQuestion,
stUneLigneRéponse.sRéponseEnTexte,
stUneLigneRéponse.sRéponseLettre,
stUneLigneRéponse.nRéponseNuméro,
stUneLigneRéponse.nQualification,
stUneLigneRéponse.dDatePELN,
stUneLigneRéponse.nMois)
FIN

--
__________________
Denis Jobin
Longueuil, Québec
Miembro registrado
163 mensajes
Publicado el 12,abril 2019 - 22:49
J'ai oublié d'indiquer que c'était du code, pour une meilleure lisibilité


ReqPELN est une Requête SQL =
[
SELECT
clients.Nom,
clients.Prenom,
clients_pelns_reponses.idClient,
clients_pelns_reponses.idQuestion,
peln_questions.Question,
peln_questions_choix.ChoixTexte,
clients_pelns_reponses.ReponseLettre,
clients_pelns_reponses.ReponseNo,
peln_questions_choix.Qualification,
clients.DatePELN,
month(clients.DatePELN) AS mois
FROM
clients_pelns_reponses
JOIN
peln_questions
ON clients_pelns_reponses.idQuestion = peln_questions.idQuestion
JOIN
peln_questions_choix
ON clients_pelns_reponses.ReponseNo = peln_questions_choix.ReponseNo
JOIN
clients
ON clients_pelns_reponses.idClient = clients.ID_Client
ORDER BY
clients.Nom ASC,
clients.Prenom ASC,
clients_pelns_reponses.idClient ASC,
clients_pelns_reponses.idQuestion ASC
]

HExécuteRequête(ReqPELN)

stUneLigneRéponse est un STRéponsesPELN
tabRéponses est un tableau de STRéponsesPELN

POUR TOUT ReqPELN
stUneLigneRéponse.sNomClient = ReqPELN.Nom
stUneLigneRéponse.sPrénomClient = ReqPELN.Prenom
stUneLigneRéponse.nIdClient = ReqPELN.idClient
stUneLigneRéponse.nIdQuestion = ReqPELN.idQuestion
stUneLigneRéponse.sQuestion = ReqPELN.Question
stUneLigneRéponse.sRéponseEnTexte = ReqPELN.ChoixTexte
stUneLigneRéponse.sRéponseLettre = ReqPELN.ReponseLettre
stUneLigneRéponse.nRéponseNuméro = ReqPELN.ReponseNo
stUneLigneRéponse.nQualification = ReqPELN.Qualification
stUneLigneRéponse.dDatePELN = ReqPELN.DatePELN
stUneLigneRéponse.nMois = ReqPELN.Mois

TableauAjouteLigne(tabRéponses,
stUneLigneRéponse.sNomClient,
stUneLigneRéponse.sPrénomClient,
stUneLigneRéponse.nIdClient,
stUneLigneRéponse.nIdQuestion,
stUneLigneRéponse.sQuestion,
stUneLigneRéponse.sRéponseEnTexte,
stUneLigneRéponse.sRéponseLettre,
stUneLigneRéponse.nRéponseNuméro,
stUneLigneRéponse.nQualification,
stUneLigneRéponse.dDatePELN,
stUneLigneRéponse.nMois)
FIN


--
__________________
Denis Jobin
Longueuil, Québec
Miembro registrado
2.682 mensajes
Publicado el 13,abril 2019 - 11:24
Bonjour,

L'erreur est sur le TableauAjouteLigne. Il faut mettre
TableauAjouteLigne(tabRéponses)


--
Cordialement,

Philippe SAINT-BERTIN
Miembro registrado
163 mensajes
Publicado el 14,abril 2019 - 02:53
Merci!

L'aide en ligne n'est pas très précise à ce sujet.

--
__________________
Denis Jobin
Longueuil, Québec
Miembro registrado
4.361 mensajes
Publicado el 14,abril 2019 - 05:10
Bonjour,
Tu peux aussi regarder du côté de FichierVersTableau https://doc.pcsoft.fr/fr-FR/?1000018833.

--
Il y a peut être plus simple, mais, ça tourne
Miembro registrado
182 mensajes
Publicado el 15,abril 2019 - 08:34
Hello,
En fait, il y a deux possibilités :

01 :

POUR TOUT ReqPELN
VariableRAZ(stUneLigneRéponse)

stUneLigneRéponse.sNomClient = ReqPELN.Nom
stUneLigneRéponse.sPrénomClient = ReqPELN.Prenom
stUneLigneRéponse.nIdClient = ReqPELN.idClient
stUneLigneRéponse.nIdQuestion = ReqPELN.idQuestion
stUneLigneRéponse.sQuestion = ReqPELN.Question
stUneLigneRéponse.sRéponseEnTexte = ReqPELN.ChoixTexte
stUneLigneRéponse.sRéponseLettre = ReqPELN.ReponseLettre
stUneLigneRéponse.nRéponseNuméro = ReqPELN.ReponseNo
stUneLigneRéponse.nQualification = ReqPELN.Qualification
stUneLigneRéponse.dDatePELN = ReqPELN.DatePELN
stUneLigneRéponse.nMois = ReqPELN.Mois

TableauAjoute(tabRéponses, stUneLigneRéponse)
FIN


02 :

POUR TOUT ReqPELN
TableauAjoute(tabRéponses, [ReqPELN.Nom, ReqPELN.Prenom, ReqPELN.idClient, ReqPELN.idQuestion, ReqPELN.Question, ReqPELN.ChoixTexte, ReqPELN.ReponseLettre, ReqPELN.ReponseNo, ReqPELN.Qualification, ReqPELN.DatePELN, ReqPELN.Mois])
FIN


En gros, ou tu remplis ta structure et tu l'envoies ensuite dans le tableau, ou tu envoies les données issues de la requête directement dans le tableau (entre crochets dans ce cas).

Dans tous les cas, je te conseille d'initialiser ton tableau par :

tabRéponses est un tableau <Agrandissement=n> de STRéponsesPELN
Mensaje modificado, 15,abril 2019 - 08:38
Publicado el 15,abril 2019 - 09:32
dj5f a exposé le 12/04/2019 :
Avec le code suivant, j'obtiens l'erreur :

«On ne peut pas affecter à une structure autre chose qu'une structure de même
définition.»

STRéponsesPELN est une Structure
sNomClient est une chaîne UNICODE
sPrénomClient est une chaîne UNICODE
nIdClient est un entier sur 4 octets
nIdQuestion est un entier sur 1 octet
sQuestion est une chaîne UNICODE
sRéponseEnTexte est une chaîne UNICODE
sRéponseLettre est une chaîne UNICODE
nRéponseNuméro est un entier sur 2 octets
nQualification est un entier sur 1 octet
dDatePELN est une Date
nMois est un entier sur 1 octet
FIN

ReqPELN est une Requête SQL = [
SELECT
clients.Nom,
clients.Prenom,
clients_pelns_reponses.idClient,
clients_pelns_reponses.idQuestion,
peln_questions.Question,
peln_questions_choix.ChoixTexte,
clients_pelns_reponses.ReponseLettre,
clients_pelns_reponses.ReponseNo,
peln_questions_choix.Qualification,
clients.DatePELN,
month(clients.DatePELN) AS mois
FROM
clients_pelns_reponses
JOIN
peln_questions
ON clients_pelns_reponses.idQuestion = peln_questions.idQuestion
JOIN
peln_questions_choix
ON clients_pelns_reponses.ReponseNo = peln_questions_choix.ReponseNo
JOIN
clients
ON clients_pelns_reponses.idClient = clients.ID_Client
ORDER BY
clients.Nom ASC,
clients.Prenom ASC,
clients_pelns_reponses.idClient ASC,
clients_pelns_reponses.idQuestion ASC
]

HExécuteRequête(ReqPELN)

stUneLigneRéponse est un STRéponsesPELN
tabRéponses est un tableau de STRéponsesPELN

POUR TOUT ReqPELN stUneLigneRéponse.sNomClient = ReqPELN.Nom
stUneLigneRéponse.sPrénomClient = ReqPELN.Prenom
stUneLigneRéponse.nIdClient = ReqPELN.idClient
stUneLigneRéponse.nIdQuestion = ReqPELN.idQuestion
stUneLigneRéponse.sQuestion = ReqPELN.Question
stUneLigneRéponse.sRéponseEnTexte = ReqPELN.ChoixTexte
stUneLigneRéponse.sRéponseLettre = ReqPELN.ReponseLettre
stUneLigneRéponse.nRéponseNuméro = ReqPELN.ReponseNo
stUneLigneRéponse.nQualification = ReqPELN.Qualification
stUneLigneRéponse.dDatePELN = ReqPELN.DatePELN
stUneLigneRéponse.nMois = ReqPELN.Mois

TableauAjouteLigne(tabRéponses,
stUneLigneRéponse.sNomClient,
stUneLigneRéponse.sPrénomClient,
stUneLigneRéponse.nIdClient,
stUneLigneRéponse.nIdQuestion,
stUneLigneRéponse.sQuestion,
stUneLigneRéponse.sRéponseEnTexte,
stUneLigneRéponse.sRéponseLettre,
stUneLigneRéponse.nRéponseNuméro,
stUneLigneRéponse.nQualification,
stUneLigneRéponse.dDatePELN,
stUneLigneRéponse.nMois)
FIN


bonjour,

il faut faire :
TableauAjouteLigne(tabRéponses,stUneLigneRéponse)


--
Cordialement JeAn-PhI
Publicado el 29,agosto 2019 - 19:40
Bonjour à tous,

Je déterre ce sujet car j'aimerai remplir un tableau de structure avec une requête mais avec un fichier FIC externe.
J'ai lu vos recommandations et ajouter la déclaration Externe de cette table externe mais j'ai une erreur "Fichier IMPORT Inconnu".
Auriez-vous une idée ?
Merci