0

I need to read the contents(text inside a stored procedure) of a stored procedure of a particular schema from a Java program.

Example. suppose I have a sp in oracle named mySp.

I need to read the text inside the sp.

How i can achieve this from a java program.

Abdul
  • 1,130
  • 4
  • 29
  • 65

1 Answers1

-1

I think you can use something like this..Better refer JDBC MetaData API..Hope this helps

http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html

DatabaseMetaData dbMetaData = conn.getMetaData();
ResultSet rs = dbMetaData.getProcedureColumns(conn.getCatalog(),
                      null,
                      "mySp",
                      "");

while(rs.next()) {
  /
}
Porkko M
  • 307
  • 2
  • 10
  • I think the above will return only stored procedure column names. Right? – Abdul Mar 31 '17 at 12:29
  • Just for example i have given getProcedureCOlumns..there are other methods too..just verify the above link..or else you can use one more query and pass this SP as parameter and get the text..that option is also available.. i found the below in google.. SELECT a.OBJECT_NAME,p.PROCEDURE_NAME FROM SYS.ALL_OBJECTS a, SYS.ALL_PROCEDURES p WHERE a.OBJECT_NAME = p.OBJECT_NAME AND a.OBJECT_TYPE = 'PACKAGE' AND a.OWNER = '" + ownerName + "' AND p.PROCEDURE_NAME IS NOT NULL" – Porkko M Mar 31 '17 at 13:12