Solved

Get trigger list from database

Posted on 1999-01-21
11
222 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

821 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