August 8th, 2003, 06:10 PM
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
August 11th, 2003, 11:45 AM
Re: plpgsql Function calls from jdbc
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 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.
August 11th, 2003, 12:51 PM
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??