Hi All, How to get trigger information from the database using JDBC API calls. I need to retrieve the entire trigger and its related information from the database for some reason. Any help will be appreciated Regards, <Mohan/>
Any information available via system catalogs can be retrieved as long as the owner (DB User) through which u are obtaining your connection has the rights to do so. At the end of the day, it is just a database call through a SQL Statement. I cannot see why you cannot do it. If you are having specific problems, please post.. and I might be able to tell something more.. best regards, prasad.
Mohan, I may be misinterpreting your question, but, as far as I know, there are no methods in the JDBC API for retrieving information about the database triggers. Most [O]RDBMS's that support database triggers, store information about the triggers in their data dictionary. Each DBMS has its own proprietary data dictionary, but usually you can access the data dictionary using SQL. So, for example using Oracle, the following query will give you the trigger definition:
So you could "wrap" the above query into an invocation of the "executeQuery()" method in class "java.sql.Statement", for example, and get the informaton that way. However, as I mentioned before, each DBMS data dictionary is different, so the above will only work for Oracle. That's why there is nothing in the JDBC API for returning that information. Good luck, Avi.
All you need is the select role on catalog objects, to retrive the trigger information. For eg. in Oracle you would use the following statement:- select trigger_body from dba_triggers where trigger_name=<your trigger_name> Thanks.