+ Added support for empty parameters to TPQConnection

+ Added errormessage for unsupported parameters

git-svn-id: trunk@3688 -
This commit is contained in:
joost 2006-05-26 22:00:42 +00:00
parent 35c5b75792
commit 68a8f531fe
3 changed files with 9 additions and 5 deletions

View File

@ -69,6 +69,7 @@ Const
SDeletedRecord = 'The record is deleted.'; SDeletedRecord = 'The record is deleted.';
SIndexNotFound = 'Index ''%s'' not found'; SIndexNotFound = 'Index ''%s'' not found';
SParameterCountIncorrect = 'The number of parameters is incorrect.'; SParameterCountIncorrect = 'The number of parameters is incorrect.';
SUnsupportedParameter = 'Parameters of the type ''%s'' are not (yet) supported.';
SFieldValueError = 'Invalid value for field ''%s'''; SFieldValueError = 'Invalid value for field ''%s''';
SInvalidCalcType = 'Field ''%s'' cannot be a calculated or lookup field'; SInvalidCalcType = 'Field ''%s'' cannot be a calculated or lookup field';
SDuplicateName = 'Duplicate name ''%s'' in %s'; SDuplicateName = 'Duplicate name ''%s'' in %s';

View File

@ -656,7 +656,7 @@ begin
{$R+} {$R+}
end; end;
else else
DatabaseError('Parameters of the type '+ Fieldtypenames[AParams[ParNr].DataType] +' are not (yet) supported.',self); DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[ParNr].DataType]],self);
end {case} end {case}
end; end;
end; end;

View File

@ -401,8 +401,9 @@ begin
if Assigned(AParams) and (AParams.count > 0) then if Assigned(AParams) and (AParams.count > 0) then
begin begin
s := s + '('; s := s + '(';
for i := 0 to AParams.count-1 do for i := 0 to AParams.count-1 do if TypeStrings[AParams[i].DataType] <> 'Unknown' then
s := s + TypeStrings[AParams[i].DataType] + ','; s := s + TypeStrings[AParams[i].DataType] + ','
else DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[i].DataType]],self);
s[length(s)] := ')'; s[length(s)] := ')';
buf := AParams.ParseSQL(buf,false,psPostgreSQL); buf := AParams.ParseSQL(buf,false,psPostgreSQL);
end; end;
@ -456,7 +457,7 @@ begin
if Assigned(AParams) and (AParams.count > 0) then if Assigned(AParams) and (AParams.count > 0) then
begin begin
setlength(ar,Aparams.count); setlength(ar,Aparams.count);
for i := 0 to AParams.count -1 do for i := 0 to AParams.count -1 do if not AParams[i].IsNull then
begin begin
case AParams[i].DataType of case AParams[i].DataType of
ftdatetime : s := formatdatetime('YYYY-MM-DD',AParams[i].AsDateTime); ftdatetime : s := formatdatetime('YYYY-MM-DD',AParams[i].AsDateTime);
@ -465,7 +466,9 @@ begin
end; {case} end; {case}
GetMem(ar[i],length(s)+1); GetMem(ar[i],length(s)+1);
StrMove(PChar(ar[i]),Pchar(s),Length(S)+1); StrMove(PChar(ar[i]),Pchar(s),Length(S)+1);
end; end
else
FreeAndNil(ar[i]);
res := PQexecPrepared(tr,pchar('prepst'+nr),Aparams.count,@Ar[0],nil,nil,0); res := PQexecPrepared(tr,pchar('prepst'+nr),Aparams.count,@Ar[0],nil,nil,0);
for i := 0 to AParams.count -1 do for i := 0 to AParams.count -1 do
FreeMem(ar[i]); FreeMem(ar[i]);