+ 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.';
SIndexNotFound = 'Index ''%s'' not found';
SParameterCountIncorrect = 'The number of parameters is incorrect.';
SUnsupportedParameter = 'Parameters of the type ''%s'' are not (yet) supported.';
SFieldValueError = 'Invalid value for field ''%s''';
SInvalidCalcType = 'Field ''%s'' cannot be a calculated or lookup field';
SDuplicateName = 'Duplicate name ''%s'' in %s';

View File

@ -656,7 +656,7 @@ begin
{$R+}
end;
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;
end;

View File

@ -401,8 +401,9 @@ begin
if Assigned(AParams) and (AParams.count > 0) then
begin
s := s + '(';
for i := 0 to AParams.count-1 do
s := s + TypeStrings[AParams[i].DataType] + ',';
for i := 0 to AParams.count-1 do if TypeStrings[AParams[i].DataType] <> 'Unknown' then
s := s + TypeStrings[AParams[i].DataType] + ','
else DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[i].DataType]],self);
s[length(s)] := ')';
buf := AParams.ParseSQL(buf,false,psPostgreSQL);
end;
@ -456,7 +457,7 @@ begin
if Assigned(AParams) and (AParams.count > 0) then
begin
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
case AParams[i].DataType of
ftdatetime : s := formatdatetime('YYYY-MM-DD',AParams[i].AsDateTime);
@ -465,7 +466,9 @@ begin
end; {case}
GetMem(ar[i],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);
for i := 0 to AParams.count -1 do
FreeMem(ar[i]);