Re: Stored procedures

Поиск
Список
Период
Сортировка
От Franco Bruno Borghesi
Тема Re: Stored procedures
Дата
Msg-id 200303291805.21844.franco@akyasociados.com.ar
обсуждение исходный текст
Ответ на Re: Stored procedures  ("Zodiac" <bishop@nm.ru>)
Список pgsql-sql
As far as I know, you always work with a ResultSet.
If you know your stored procedures will always return an Integer and you don't
wanna deal with the executeQuery and stuff every time, you could create a
class with methods explicitly for accesing your stored procedures, for
example:

assuming you have a pg function returning an INT, called countPeople(), you
could do

public class MyStoredProcs {  private static int executeAnyProc(Connection conn, String procName) throws
SQLException{     Statement stmt=conn.createStatement();     ResultSet rs=stmt.executeQuery("SELECT * FROM
"+procName+"()");    rs.next();     return rs.getInt(1);           } 
  public static int countPeople() throws SQLException{     return executeAnyProc("countPeople");  }
};

You could add methods to access every stored procedure in your database (even
returning other data types), and you would use it like this in your code:

...  int count=MyStoredProcs.countPeople();  // do something with the value  if (count>100) {
...


hope this is what you were looking for.

On Saturday 29 March 2003 17:35, Zodiac wrote:
> Thank you for help.
> Just one more question. Have i direct access to stored procedure?
> For example, i have procedure which returns Integer and i wanna to have
> ability to write such code " int var = ANY_CALL". Where ANY_CALL is a my
> procedure call.
> I meant must i do "executeQuery" only and after then parse Statement
> variable?
>
> Thank you.

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Zodiac"
Дата:
Сообщение: Re: Stored procedures
Следующее
От: "Alain Gougeon"
Дата:
Сообщение: Re: Off topic : world database