Method to get only procedures from an oracle database using Java
Asked Answered
S

1

5

I need to get only the procedures using java DatabaseMetaData but this method returns also the functions' names.

DatabaseMetaData dbmd=con.getMetaData();
ResultSet result = dbmd.getProcedures(null, Ousername, null); 
Selden answered 14/5, 2015 at 16:31 Comment(5)
I have the same question.Optimize
This may behave differently depending on the specific DBMS driver. Which one are you using, @Selden and @SteveL?Switzerland
@Switzerland ,we are both using oracle but the same happens in postgresql too.Optimize
@Selden Two questions: 2) Do you only need this on an Oracle Database? 2) Do you have to use DatabaseMetaData ?Kacey
@StefanFerstl Yes only using Database metadataSelden
B
7

That happens because procedures and functions are basically the same in Oracle.

There is a column PROCEDURE_TYPE of the type short that will show the kind of procedure:

  • 1 means there is no result, so it is a procedure.
  • 2 means it returns a result, so it is a function.

You can access that column as usual from the ResultSet:

result.getShort("PROCEDURE_TYPE")
Belter answered 17/5, 2015 at 14:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.