A simple update raise this error : Inconsistent type inferred for the parameter $1
I basically do this thing :
I have a Datamodule with my uniconnection component created at design time.
I create an object within the Datamodule Oncreate event and sets it's TUniConnection property. This object does have several private method that update SQL Data.
Code: Select all
//Datamodule On create
MyObject:= TMyObject.Create;
MyObject:= MyObject.Connection := Datamodule.UniConnection1;
//MyObject
TMyObject= class(TThread)
private
FConnection: Tuniconnection;
...
public
property Connection: Tuniconnection read FConnection write FConnection;
...
End;
procedure TMyObject.Sauver_PosteEnCours(const Value: Poste);
var
FUniQuery: TuniQuery;
begin
FUniQuery := TuniQuery.Create(nil);
FUniQuery.Connection := FConnection;
try
FUniQuery.SQL.Text := Poste_Update;
FUniQuery.ParamByName('Ligne').AsString := FLigne.Id_ligne;
FUniQuery.ParamByName('Id_Poste').AsInteger := Value.Id_Poste;
FUniQuery.ParamByName('Date_Poste').AsDate := Value.Date_Poste;
if Value.Date_Debut_Poste = 0 then
FUniQuery.ParamByName('Date_Debut_Poste').clear
else
FUniQuery.ParamByName('Date_Debut_Poste').AsDateTime :=
Value.Date_Debut_Poste;
FUniQuery.ParamByName('Id_Pilote_1').AsString := Value.Id_Pilote_1;
FUniQuery.ParamByName('Id_Pilote_2').AsString := Value.Id_Pilote_2;
FUniQuery.ParamByName('Ordre_Fabrication_En_Preparation').AsString :=
Value.Ordre_Fabrication_En_Preparation;
FUniQuery.ParamByName('Ordre_Fabrication_En_Cours').AsString :=
Value.Ordre_Fabrication_En_Cours;
FUniQuery.Prepare; //<------ error occurs here
FUniQuery.Execute;
if FUniQuery.RowsAffected = 0 then
begin
FUniQuery.SQL.Text := Poste_Insert;
FUniQuery.ParamByName('Ligne').AsString := FLigne.Id_ligne;
FUniQuery.ParamByName('Id_Poste').AsInteger := Value.Id_Poste;
FUniQuery.ParamByName('Date_Poste').AsDate := Value.Date_Poste;
FUniQuery.ParamByName('Id_Pilote_1').AsString := Value.Id_Pilote_1;
FUniQuery.ParamByName('Id_Pilote_2').AsString := Value.Id_Pilote_2;
FUniQuery.ParamByName('Ordre_Fabrication_En_Preparation').AsString :=
Value.Ordre_Fabrication_En_Preparation;
FUniQuery.ParamByName('Ordre_Fabrication_En_Cours').AsString :=
Value.Ordre_Fabrication_En_Cours;
if Value.Date_Debut_Poste = 0 then
FUniQuery.ParamByName('Date_Debut_Poste').clear
else
FUniQuery.ParamByName('Date_Debut_Poste').AsDateTime :=
Value.Date_Debut_Poste;
FUniQuery.Prepare;
FUniQuery.Execute;
end;
finally
FUniQuery.Free;
end;
end;
SQL Statement used is really simple :
Code: Select all
Poste_Update =
'Update Productions_Postes set ' +
'Ligne=:Ligne,'+
'date_poste=:date_poste,'+
'date_debut_poste=:date_debut_poste,'+
'Id_Poste=:Id_Poste,'+
'Id_Pilote_1=:Id_Pilote_1,'+
'Id_Pilote_2=:Id_Pilote_2,'+
'Ordre_Fabrication_En_Preparation=:Ordre_Fabrication_En_Preparation,'+ 'Ordre_Fabrication_En_Cours=:Ordre_Fabrication_En_Cours'+
'where Ligne=:Ligne;';
Code: Select all
CREATE TABLE public.productions_postes (
ligne VARCHAR(10) DEFAULT ''::character varying NOT NULL,
date_poste DATE,
date_debut_poste TIMESTAMP WITHOUT TIME ZONE,
id_poste INTEGER,
id_pilote_1 VARCHAR(2) DEFAULT ''::character varying,
id_pilote_2 VARCHAR(2) DEFAULT ''::character varying,
ordre_fabrication_en_preparation VARCHAR(6) DEFAULT ''::character varying,
ordre_fabrication_en_cours VARCHAR(6) DEFAULT ''::character varying,
CONSTRAINT productions_postes_pkey PRIMARY KEY(ligne)
)
WITH (oids = false);
CREATE INDEX productions_postes_ligne ON public.productions_postes
USING btree (ligne COLLATE pg_catalog."default");
This worked well when my provider was SQLite, but doesn't anymore with PostgreSQL provider.