Check if view/query exists

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Check if view/query exists

Post by oz8hp » Mon 02 Mar 2015 12:36

I am trying to figure out a method of checking if a view/query exists in my DB using UniScript. But I haven't been able to figure out a way that works on MSSQL, MySQL, SQLite and Access.
Isn't this possible and could someone maybe give a hint as to what to look for.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Check if view/query exists

Post by AlexP » Mon 02 Mar 2015 12:58

Hello,

The easiest way to check whether an object exists is using the TUniMetaData component: http://www.devart.com/unidac/docs/devar ... embers.htm . This will allow avoid writing separate queries for each database.

Code: Select all

  UniMetaData1.MetaDataKind := 'Tables';
  UniMetaData1.Restrictions.Add('TABLE_NAME=T_TABLE');
  ShowMessage(IntToStr(UniMetaData1.RecordCount));

Post Reply