Prechádzať zdrojové kódy

* Implemented GetTableNames, systemtables=true, bug #13893, by Ladislav Karrach

git-svn-id: trunk@15498 -
joost 15 rokov pred
rodič
commit
c58e26e25a

+ 6 - 2
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -646,6 +646,9 @@ begin
 end;
 
 procedure TODBCConnection.Execute(cursor: TSQLCursor; ATransaction: TSQLTransaction; AParams: TParams);
+const
+  TABLE_TYPE_USER='TABLE,VIEW,GLOBAL TEMPORARY,LOCAL TEMPORARY'; //no spaces before/after comma
+  TABLE_TYPE_SYSTEM='SYSTEM TABLE';
 var
   ODBCCursor:TODBCCursor;
   Res:SQLRETURN;
@@ -658,7 +661,8 @@ begin
   // execute the statement
   case ODBCCursor.FSchemaType of
     stNoSchema  : Res:=SQLExecute(ODBCCursor.FSTMTHandle); //SQL_NO_DATA returns searched update or delete statement that does not affect any rows
-    stTables    : Res:=SQLTables (ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0, nil, 0 );
+    stTables    : Res:=SQLTables (ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0, TABLE_TYPE_USER, length(TABLE_TYPE_USER) );
+    stSysTables : Res:=SQLTables (ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0, TABLE_TYPE_SYSTEM, length(TABLE_TYPE_SYSTEM) );
     stColumns   : Res:=SQLColumns(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, @ODBCCursor.FQuery[1], length(ODBCCursor.FQuery), nil, 0 );
     stProcedures: Res:=SQLProcedures(ODBCCursor.FSTMTHandle, nil, 0, nil, 0, nil, 0 );
     else          Res:=SQL_NO_DATA;
@@ -1302,7 +1306,7 @@ begin
     Result := SchemaObjectName
   else
     Result := ' ';
-  if not (SchemaType in [stNoSchema, stTables, stColumns, stProcedures]) then
+  if not (SchemaType in [stNoSchema, stTables, stSysTables, stColumns, stProcedures]) then
     DatabaseError(SMetadataUnavailable);
 end;