#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    58
    Rep Power
    11

    plpgsql Function calls from jdbc


    I know that i can call plpgsql functions from jdbc programs using a select statement which returns only one row.

    I see that this is not efficient when I include write statements such as insert, delete, update.

    I don't know if exists a way to call functions as stored prodedures, I don't think that CallableStatement objects can be useful.

    I appreciate some help

    Best Regards.
  2. #2
  3. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62

    Re: plpgsql Function calls from jdbc


    Originally posted by daniel_baylon
    I know that i can call plpgsql functions from jdbc programs using a select statement which returns only one row.

    I see that this is not efficient when I include write statements such as insert, delete, update.
    I don't understand what is so inefficient about this. If your procedure has write statements inside it, this doesn't in any way affect the speed of calling the query, as in SELECT my_function('myinsertvalue1','myinsertvalue2');

    Just because a SELECT query normally returns a row, this doesn't mean you have to do anything with the row. And in this case, the query can return only what you define the function as returning. So, for example if your function returns TRUE for a successful insert or FALSE for a failed insert, then the only data returned is a boolean value, which is about as efficient as possible.


    I don't know if exists a way to call functions as stored prodedures, I don't think that CallableStatement objects can be useful.

    I appreciate some help

    Best Regards.
    I have not had too much experience with JDBC, but I would assume that CallableStatement refers to a method to "directly" call a stored procedure, instead of using a SELECT query on the procedure. Really, this is just syntactic sugar, because it essentially does the same thing in the end.

    Maybe I am not completely understanding your problem here, though. If you still are having difficulties, please post examples of code and explain what is happening, and what you want to happen.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    373
    Rep Power
    12

    Smile


    there may be other options in procedural languages that would work better for what you're trying to do, or outside connections using other languages like Python that support cursor datatypes. Are there really not cursor or rowtype datatypes in JDBC libraries??

IMN logo majestic logo threadwatch logo seochat tools logo