VirtualQuery DataMaping Unidac 10.0
Hi,
I use the code below :
try
//---- Création
TableP_MESURES := TUniQuery.Create(Self);
try
//---- Création
WQ := TVirtualQuery.Create(Self);
//---- Source de données
TableP_MESURES.Connection := FicheModuleDonnees.Connection;
WQ.SourceDataSets.Add(P_VLC, '', 'P_VLC');
WQ.SourceDataSets.Add(P_EVENEMENT, '', 'P_EVENEMENT');
WQ.SourceDataSets.Add(TableP_MESURES, '', 'P_MESURES_STEP');
//---- Sql : Date
TableP_MESURES.Sql.Text := 'SELECT DATE_MESURE,USER_ID FROM P_MESURES_STEP WHERE (USER_ID = :USER_ID)';
TableP_MESURES.Params[0].DataType := ftInteger; //---- USER_ID
TableP_MESURES.Params[0].AsInteger := _User_ID; //---- USER_ID
try
//---- Ouverture de la table
TableP_MESURES.Open;
//---- Sql : Récupération des dates Min et Max
WQ.Sql.Text := 'SELECT MIN(A.DATE_MESURE) AS MIN_DATE,MAX(A.DATE_MESURE) AS MAX_DATE FROM ';
WQ.Sql.Text := WQ.Sql.Text + '(SELECT DISTINCT DATE_EV AS DATE_MESURE FROM P_EVENEMENT WHERE (USER_ID = :USER_ID1)';
WQ.Sql.Text := WQ.Sql.Text + ' UNION ';
WQ.Sql.Text := WQ.Sql.Text + 'SELECT DISTINCT DATE_MESURE FROM P_MESURES_STEP WHERE (USER_ID = :USER_ID2)';
WQ.Sql.Text := WQ.Sql.Text + ' UNION ';
WQ.Sql.Text := WQ.Sql.Text + 'SELECT DISTINCT DATE_DEBUT AS DATE_MESURE FROM P_VLC WHERE (USER_ID = :USER_ID3)) A';
WQ.DataTypeMap.AddFieldNameRule('MIN_DATE', ftDateTime);
WQ.DataTypeMap.AddFieldNameRule('MAX_DATE', ftDateTime);
//---- Types
WQ.Params[0].DataType := ftInteger; //---- USER_ID (USER_ID1)
WQ.Params[1].DataType := ftInteger; //---- USER_ID (USER_ID2)
WQ.Params[2].DataType := ftInteger; //---- USER_ID (USER_ID3)
//---- Valeurs
WQ.Params[0].AsInteger := _User_ID; //---- USER_ID (USER_ID1)
WQ.Params[1].AsInteger := _User_ID; //---- USER_ID (USER_ID2)
WQ.Params[2].AsInteger := _User_ID; //---- USER_ID (USER_ID3)
try
//---- Ouverture de la requête
WQ.ReadOnly := True;
WQ.Open;
//---- Récupération min et max
if WQ.FieldByName('MIN_DATE').AsDateTime <> 0.0 then
begin
DateMinG := WQ.FieldByName('MIN_DATE').AsDateTime;
DateMaxG := WQ.FieldByName('MAX_DATE').AsDateTime;
end
When I access WQ.FieldByName('MIN_DATE').AsDateTime it fire exception "Field : MIN_DATE 2023-07-01 00:00:00 is an invalid date or time value"
Works fine with version 9.4 doesn't work with version 10.0
I Use Delphi XE8
Can you help please ?
Thanks