فهرست منبع

+ Added support for empty parameters to TPQConnection
+ Added errormessage for unsupported parameters

git-svn-id: trunk@3688 -

joost 19 سال پیش
والد
کامیت
68a8f531fe
3فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 1 0
      fcl/db/dbconst.pp
  2. 1 1
      fcl/db/sqldb/interbase/ibconnection.pp
  3. 7 4
      fcl/db/sqldb/postgres/pqconnection.pp

+ 1 - 0
fcl/db/dbconst.pp

@@ -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';

+ 1 - 1
fcl/db/sqldb/interbase/ibconnection.pp

@@ -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;

+ 7 - 4
fcl/db/sqldb/postgres/pqconnection.pp

@@ -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]);