This version is not working with MSSQL earlier than 2008

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
hoedlmoser
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 24.01.2018, 11:17

This version is not working with MSSQL earlier than 2008

Post by hoedlmoser »

Hi Guys,

there is a problem with the "ZDbcDbLibMetadata.TZMsSqlDatabaseMetadata.UncachedGetColumns" function. This generates a SQL statement like this, eg. for table 'theTablename' (added comments):

Code: Select all

select c.colid, c.name, c.type, c.prec, c.scale, c.colstat, c.status, c.iscomputed  
from syscolumns c 
  inner join sys.sysobjects o on (o.id = c.id) 		    -- use "join sysobjects o" instead
  inner join sys.schemas s on (o.uid = s.schema_id)     -- good for nothing, should be deleted
where c.number=0
  and (o.name like 'theTablename' escape '/'            -- simply replace with: "o.name = 'theTablename'"
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             -- nonsense. Don't know what this is meant to be good for ???
       or ('theTablename' is null))                     
  and (s.name like null escape '/' or (null is null))                     
-- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
order by colid
This does not work on MSSQL versions earlier than 2008, there are no "sys.sysobjects" and "sys.schemas" views. I'd suggest to change this part of the function code, it should work for all servers:

Code: Select all

    ...
    with GetStatement.ExecuteQuery(
      Format('select c.colid, c.name, c.type, c.prec, c.scale, c.colstat, c.status, c.iscomputed '
      + ' from syscolumns c '
      + '  join sysobjects o on o.id = c.id '
      + ' where c.number=0 '
      + '   and o.name = %0:s '
      + ' order by colid ',
      [DeComposeObjectString(TableNamePattern)])) do
      ...
kind regards
hoedlmoser
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: This version is not working with MSSQL earlier than 2008

Post by marsupilami »

Note: This might have been introduced with revision 4064.
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: This version is not working with MSSQL earlier than 2008

Post by Fr0sT »

added comments
Don't forget Zeos allows wildcard metadata querying and your simplifications are for just a single object.
Post Reply