* Better way of handling date/time conversion in params

git-svn-id: trunk@23941 -
This commit is contained in:
michael 2013-03-20 10:15:36 +00:00
parent 228d03248a
commit 0703b2b7c0

View File

@ -976,11 +976,18 @@ var ParNr,SQLVarNr : integer;
{$pop} {$pop}
end; end;
Const
DateF = 'yyyy-mm-dd';
TimeF = 'hh:nn:ss';
DateTimeF = DateF+' '+TimeF;
var var
// This should be a pointer, because the ORIGINAL variables must // This should be a pointer, because the ORIGINAL variables must
// be modified. // be modified.
VSQLVar: ^XSQLVAR; VSQLVar: ^XSQLVAR;
P: TParam;
ft : TFieldType;
D : TDateTime;
begin begin
{$push} {$push}
{$R-} {$R-}
@ -1016,16 +1023,19 @@ begin
SetBlobParam; SetBlobParam;
SQL_VARYING, SQL_TEXT : SQL_VARYING, SQL_TEXT :
begin begin
if AParams[ParNr].DataType=ftDate then begin P:=AParams[ParNr];
s := FormatDateTime('yyyy-mm-dd',AParams[ParNr].AsDate); ft:=P.DataType;
end else if AParams[ParNr].DataType=ftDateTime then begin if Not (ft in [ftDate,ftTime,ftDateTime,ftTimeStamp]) then
s := FormatDateTime('yyyy-mm-dd hh:nn:ss',AParams[ParNr].AsDate); S:=P.AsString
end else if AParams[ParNr].DataType=ftTimeStamp then begin else
s := FormatDateTime('yyyy-mm-dd hh:nn:ss',AParams[ParNr].AsDate); begin
end else if AParams[ParNr].DataType=ftTime then begin Case ft of
s := FormatDateTime('hh:nn:ss',AParams[ParNr].AsDate); ftDate : S:=DateF;
end else begin ftTime : S:=TimeF;
s := AParams[ParNr].AsString; ftDateTime,
ftTimeStamp : S:=DateTimeF;
end;
S:=FormatDateTime(S,P.AsDateTime);
end; end;
w := length(s); // a word is enough, since the max-length of a string in interbase is 32k w := length(s); // a word is enough, since the max-length of a string in interbase is 32k
if ((VSQLVar^.SQLType and not 1) = SQL_VARYING) then if ((VSQLVar^.SQLType and not 1) = SQL_VARYING) then