Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour Cher tous j'ai créé une datawindow Crosstab, avec 3 arguments de type : number, date, date.
Au passage de paramêtres du retrieve, j'ai l'erreur suivant provenant de SQL Server :
SQL error : SQLSTATE : 22008
[Microsoft][ODBC SQL Server Driver][SQL Server]La conversion d'un type de données CHAR et type DATETIME a donné une valeur hors limite de date et d'heure.
Et pourtant les variable que je passe en argument à la méthode retrieve(...) sont de type date
id_inf = date(annee,mois,21) if mois < 12 then id_sup = date(annee, mois + 1, 20) else id_sup = date(annee+1, 1, 20) end if
Voici la requête SQL de ma datawindow :
select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif, a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hspnight_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = :arg_equipe) and (a.djm BETWEEN :arg_inf AND :arg_sup ) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif, a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hspweekend_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = :arg_equipe) and (a.djm BETWEEN :arg_inf AND :arg_sup ) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif, a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hsp_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = :arg_equipe) and (a.djm BETWEEN :arg_inf AND :arg_sup ) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif, a.djm, a.nmotifin nmotif, CASE nmotifin WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_noworkdaily_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = :arg_equipe) and (a.djm BETWEEN :arg_inf AND :arg_sup ) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, 'Travail' lnewmotif, a.djm, a.nmotifin as nmotif, CASE a.nmotifin WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(sum(totaltime) over ( partition by a.nmatricule, djm ) * 24, 0) ELSE NULL END AS valeur, b.day, DATEPART(dd, djm) as dayofmonth, case dbo.F_ISO_WEEKDAY(djm) when 1 then 'D' when 2 then 'L' when 3 then 'M' when 4 then 'M' when 5 then 'J' when 6 then 'V' when 7 then 'S' end as dayofweek from dbo.pointage_deltatime_sum_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON DATEPART(dd, djm) = b.day where nmotifin in ( 1, 2, 14, 16, 19,20 ) and (nentity = :arg_equipe) and (a.djm BETWEEN :arg_inf AND :arg_sup ) group by a.nmatricule, djm ,b.day, a.nmotifin, totaltime, idorder, dbo.Agent.lnom,dbo.Agent.lpostnom
Et voici le script qui provoque mon retrieve
dw_report.retrieve( il_equipe, date(id_inf), date(id_sup))
Hors ligne
Bonjour, je pense que c'est un problème de format de date dans MSSQL (genre mdy / ydm / dmy)
est-ce que ça fonctionne si tu passes les dates en string de la forme 'YYYYMMDD'
dans a.djm BETWEEN :arg_inf AND :arg_sup
?
Hors ligne
Je vient d'essayer ça me donne la même erreur.
Voici et pourtant je construit bien selon ta proposition '20090121' et '20090220' et j'ai changer le type des arguments de type Date en String, parce que "Unexpected type of arguments"
Hors ligne
Penses également à vérifier le paramétrage de ta connexion à la base.
Dans le Database Profil Painter si tu édites ton profil, il y a surement des paramètres liés à la gestion des dates (c'est le cas pour Oracle par exemple). Après les avoir correctement renseigné, tu peux jeter un oeil au résultat dans l'onglet preview pour voir comment modifier les paramètres de ton objet transaction (ajout de valeurs dans le dbparm très certainement).
Ce n'est qu'une piste. Je suis pas convaincu que ce soit cela. Mais procédons par élimination...
Hors ligne
Ok, voici le preview de Database Profile :
// Profile SISP SQLCA.DBMS = "ODBC" SQLCA.AutoCommit = False SQLCA.DBParm = "ConnectString='DSN=SISP;UID=sa;PWD=monmotdepasse;DelimitIdentifier='No',MsgTerse='Yes',CallEscape=''"
Hors ligne
b2oba a écrit:
Ok, voici le preview de Database Profile :
Code: pb
// Profile SISP SQLCA.DBMS = "ODBC" SQLCA.AutoCommit = False SQLCA.DBParm = "ConnectString='DSN=SISP;UID=sa;PWD=monmotdepasse;DelimitIdentifier='No',MsgTerse='Yes',CallEscape=''"
Je n'ai pas SQL Server ici. Donc je ne connais pas tous les paramètres possibles. Mais normalement sur les différents onglets du profil tu dois pouvoir voir s'il est fait référence à des formats de dates. Après avoir modifié le ou les paramètres concernés tu peux revenir sur l'onglet preview pour voir la ligne de commande à reporter dans ton script de connexion.
Hors ligne
Bonjour,
un truc m'étonne :
Dans ton premier morceau de code, tu codes :
id_inf = date(annee,mois,21)
id_inf est donc une date.
Mais au moment du retrieve, tu castes en date une (2) variable(s) de type date :
dw_report.retrieve( il_equipe, date(id_inf), date(id_sup))
ton problème ne viendrait pas de là ?
Cordialement,
GPF
Hors ligne
je ne pense pas, date d'une date donne la même date
Hors ligne
Actuellement j'ai la situation suivante :
Mes deux derniers arguments sont de datetime et lors du retrieve je passe directement mes variables qui type datetime,
Pour l'instant j'ai le même type (datetime) partout, donc une simple passation des valeurs
Hors ligne
tu peux faire une trace pour savoir exactement ce qui est passé en base ?
Hors ligne
J'ai essayer de tracer ce que tu m'as demandé toujours. Finalement j'ai pensé à avoir une procédure stockée côté SQL Server qui va provisionner ma Crosstab, dont le select et celui de la datawindow que j'ai présenté en début. La procédure stockée a 3 arguments comme pour ma crosstab précitée, Mais lors de la création j'ai le message d'erreur suivant, je pense qu'il veux peux être faire un mapping des arguments de la procédure stocké pour la datawindow à créer.
Voici le message :
Cannot create DataWindow
'SQLSTATE = 37000 [Microsoft][ODBC Server Driver][SQL Server]Erreur de conversion du type de données varchar en datetime.
1 execute dbo.getsummaryteam;1 @anentity = :anentity, @adstart = :@adstart, @adend = :adend'
dbo.getsummaryteam est ma procédure stockée.
Et pourtant dans ma procédure stockée les deux derniers arguments sont de type datetime
Hors ligne
quels sont les valeurs des arguments ?
quand tu excecute ta requete execute dbo.getsummaryteam @anentity = :anentity, @adstart = :@adstart, @adend = :adend
en remplacant tes variables tu as le meme resultat ???
Hors ligne
Voici ma procédure stockée :
create procedure GetSummaryTeam ( @anentity as numeric(15), @adstart as datetime, @adend as datetime) as select idorder,dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe,a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif,a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hspnight_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif,a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur,b.day,dayofmonth,dayofweek from pointage_hspweekend_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend) union select idorder, dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe, a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif, a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur,b.day,dayofmonth,dayofweek from pointage_hsp_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend) union select idorder,dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe,a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif,a.djm, a.nmotifin nmotif, CASE nmotifin WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur,b.day,dayofmonth,dayofweek from pointage_noworkdaily_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend) union select idorder,dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe,a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, 'Travail' lnewmotif,a.djm, a.nmotifin as nmotif, CASE a.nmotifin WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(sum(totaltime) over ( partition by a.nmatricule, djm ) * 24, 0) ELSE NULL END AS valeur,b.day,DATEPART(dd, djm) as dayofmonth,case dbo.F_ISO_WEEKDAY(djm) when 1 then 'D' when 2 then 'L' when 3 then 'M' when 4 then 'M' when 5 then 'J' when 6 then 'V' when 7 then 'S' end as dayofweek from dbo.pointage_deltatime_sum_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON DATEPART(dd, djm) = b.day where nmotifin in ( 1, 2, 14, 16, 19,20 ) and (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend) group by a.nmatricule, djm ,b.day, a.nmotifin, totaltime, idorder, dbo.Agent.lnom,dbo.Agent.lpostnom
et lorsque je crée la datawindow à partir la procédure stockée, j'ai le message suivant :
Cannot create DataWindow
'SQLSTATE = 37000 [Microsoft][ODBC Server Driver][SQL Server]Erreur de conversion du type de données varchar en datetime.
1 execute dbo.getsummaryteam;1 @anentity = :anentity, @adstart = :@adstart, @adend = :adend'
Hors ligne
prends chaque ordre
Par exemple
select idorder,dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe,a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif,a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hspnight_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = @anentity) and (a.djm BETWEEN @adstart AND @adend)
Remplace les variables
Par exemple
select idorder,dbo.GetEquipe(cast(a.nmatricule as varchar)) as Equipe,a.nmatricule, cast(a.nmatricule as varchar)+ ' / ' + dbo.Agent.lnom + ' ' + dbo.Agent.lpostnom as Agent, lnewmotif,a.djm, a.nmotif, CASE nmotif WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 13 THEN 1 WHEN 12 THEN round(a.dailytime * 24, 0) ELSE NULL END AS valeur, b.day, dayofmonth, dayofweek from pointage_hspnight_v AS a INNER JOIN dbo.Agent ON a.nmatricule = dbo.Agent.nmatricule RIGHT OUTER JOIN dbo.dayofmonth AS b ON dayofmonth = b.day where (nentity = 123 ) and (convert(char(8),a.djm ,112) BETWEEN convert(char(8),'20090101',112) AND convert(char(8),'20090301',112) )
Par le dans SQL Server Management Studio par exemple
Si tu as le message essaie de voir d'ou provient le probleme en mettant chaque champs ( et/ ou restriction ) en commentaire
Hors ligne
Merci, pour votre assistance,
J'ai fait un constat : si je prend une partie de ma requête complexe, c'est à dire le Script avant le premier "UNION", ça passe sans problème, il suffit que j'ajoute une requête. Il m'affiche l'erreur de date, comment expliquer cela et comme résoudre cela. En rappelant que c'est l'union des toutes ces requêtes là qui fera ma datawindow Crosstab.
D'avance je vous dit merci.
Hors ligne
As tu isolé la requete qui pose probleme ? ( prends les select et passe les ! )
connais tu le champs qui pose probleme ? ( mets les chemps 1 par 1 en commentaire et execute ! )
Hors ligne
Ha, les dates entre PB et les bases de données !
Bon, essaye celà :
-Soit du cast un datetime dans ton retrieve, c'est à dire tu fais : dw.retrieve(arg1, datetime(date(d1), Time('00:00:00')), datetime(date(d2), Time('23:59:59'))) ou d1 et d2 sont du type string.
-Soit tu passe des strings à ta procédure, c'est à dire :
Create Myproc ( @arg1 int, @d1 varchar(8), @d2 varchar(8))
As
Begin
Set dateformat dmy
Declare @DT1 datetime, @DT2 datetime
Set @DT1 = convert(datetime, @d1 + ' 00:00:00')
Set @DT2 = convert(datetime, @d2 + ' 23:59:59')
....
End
Et tu essayes de faire : dw.retrieve(1, '01/01/09', '31/12/09')
Bon courage
Dernière modification par cposervices (26-02-2009 09:21:43)
Hors ligne