Solved

Get trigger list from database

Posted on 1999-01-21
11
226 Views
Last Modified: 2012-05-04
Hi all :-)

Small problem... I need to know list of tables, stored procedures, triggers and generators... Tables and stored procedures're ok with RX components, but what with triggers and generators ??? Exist some component for it ??? (I need in any SQL server - MSSQL/ORACLE/Borland)....

Thanx
0
Comment
Question by:rayofunreal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362662
hi rayofunreal,

All information you want, you can get from the resultset of this query

select * from user_objects

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362663
hi rayofunreal,

tested in oracle only

meikl

0
 
LVL 1

Author Comment

by:rayofunreal
ID: 1362664
Sorry,m this doesn't work with standard BDE :-(

Thanx....

R.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:rayofunreal
ID: 1362665
I mean Interbase....
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362666
Hi rayofunreal,

a SQL Statement (Interbase)

Show Triggers

meikl
0
 
LVL 1

Author Comment

by:rayofunreal
ID: 1362667
I need to do it RUNTIME... Here're some BDE API calls, but I haven't doc about them :-(

Show Triggers ??? I'll try it...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362668
Hi rayofunreal,

you can do it at runtime!
use a tquery-component!

meikl
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1362669
There's no consistent way to determine the number of system objects in all available DBMS. This is the reason why you cannot retrive them with the BDE. At least for Interbase you can do it so:

procedure ListItemNames(ItemType: TItemType; Info: PConnectionInfo; List: TStrings; SysInclude: Boolean);

begin
  if AquireConnectionSet(Info) then
    with Info.Connection do
    begin
      with TIB_Cursor.Create(nil) do
      try
        IB_Connection:=Info.Connection;
        case ItemType of
          itDomain     : SQL.Add('select rdb$field_name from rdb$fields');
          itException  : SQL.Add('select rdb$exception_name from rdb$exceptions');
          itFilter     : SQL.Add('select rdb$function_name from rdb$filters');
          itGenerator  : SQL.Add('select rdb$generator_name from rdb$generators');
          itStoredProc : SQL.Add('select rdb$procedure_name from rdb$procedures');
          itTable      : SQL.Add('select rdb$relation_name from rdb$relations');
          itTrigger    : SQL.Add('select rdb$trigger_name from rdb$triggers');
          itUDF        : SQL.Add('select rdb$function_name from rdb$functions');
          itView       : SQL.Add('select rdb$relation_name from rdb$relations');
        end;
        if not SysInclude then SQL.Add('where ((RDB$SYSTEM_FLAG <> 1) or (RDB$SYSTEM_FLAG IS NULL))');
        if ItemType = itView then SQL.Add('and (rdb$view_source is not null)');
        SQL.Add('order by 1');
        Prepare;
        First;
        while not EOF do
        begin
          List.Add(Trim(Fields[0].AsString));
          Next;
        end;
      finally
        Free;
      end;
    end;
end;

I used IB Objects for this code but you can very easy adapt it to your needs. Info.Connection/IB_Connection can be replaced by a TDatabase component and TIB_Cursor by a TQuery component.

Ciao, Mike
0
 
LVL 1

Author Comment

by:rayofunreal
ID: 1362670
Lischke - come from your points :-)
0
 
LVL 1

Author Comment

by:rayofunreal
ID: 1362671
Btw. what for other ? will work it ?
0
 
LVL 10

Accepted Solution

by:
Lischke earned 80 total points
ID: 1362672
Usually all info about a databases structure is stored in system tables (that's what they are for). Of course these tables aren't the same in all DBMS, so you have to find the way to retrieve the information you need for each database system separately.

Ciao, Mike
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question