Recently I've begun to port some old, but very large desktop application from Borland C++ Builder to Lazarus. I've found the Zeoslib only component library suitable for replacing proprietary SQLDirect. I've ported the code to Delphi (with fantastic Perl script), then made it work, then moved to Lazarus. Everything went ok until I stucked at cross-table query. Doesn't matter if it's using FreeTDS or MS SQL ntwdblib, the cross-table query simply does not work.
I needed this feature badly, so I've managed to fix the Zeos source code by changing the file "ZDbcDbLibMetadata.pas".
I've replaced this:
Code: Select all
with GetStatement.ExecuteQuery(
Format('exec sp_columns %s, %s, %s, %s',
[ComposeObjectString(TableNamePattern),
ComposeObjectString(SchemaPattern),
ComposeObjectString(Catalog),
ComposeObjectString(ColumnNamePattern)])) do
Code: Select all
with GetStatement.ExecuteQuery(
Format('exec %s.%s.sp_columns %s, %s, %s, %s',
[Catalog,
SchemaPattern,
ComposeObjectString(TableNamePattern),
ComposeObjectString(SchemaPattern),
ComposeObjectString(Catalog),
ComposeObjectString(ColumnNamePattern)])) do
Code: Select all
with GetStatement.ExecuteQuery(
Format('exec sp_column_privileges %s, %s, %s, %s',
[ComposeObjectString(Table),
ComposeObjectString(Schema),
ComposeObjectString(Catalog),
ComposeObjectString(ColumnNamePattern)])) do
Code: Select all
with GetStatement.ExecuteQuery(
Format('exec %s.%s.sp_column_privileges %s, %s, %s, %s',
[Catalog,
Schema,
ComposeObjectString(Table),
ComposeObjectString(Schema),
ComposeObjectString(Catalog),
ComposeObjectString(ColumnNamePattern)])) do
I've tested the code od Server 2012 Express and all the following queries run fine:
Code: Select all
exec ..sp_columns ...
exec .dbo.sp_columns ...
exec database.dbo.sp_columns ...