ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Collin Peters <cadio...@gmail.com>
Subject Re: Using iBatis to create a Postgres function - fails because of semi-colon
Date Thu, 18 Mar 2010 15:55:36 GMT
You are correct.  I can create the stored proc via iBatis via a unit test,
but when I run it as a deployed webapp on Tomcat (using Java btw) it fails.
So perhaps iBatis isn't to blame here, but hopefully I can be pointed in the
right direction.  The only thing that is really different between the unit
test and the deployed webapp is the datasource.  I'm using Spring so the
unit test uses org.springframework.jdbc.datasource.DriverManagerDataSource
and the webapp uses
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy.

I'm not sure what you mean by the delimiter comment.  The $ isn't the
problem, its the semi-colon.  AFAIK the semi-colon use to end a statement is
not configurable and within a stored proc there could obviously be many
semi-colons.

Collin

On Wed, Mar 17, 2010 at 7:54 PM, Guy Rouillier <guyr-ml1@burntmail.com>wrote:

> I'm not following your situation.  You say it works fine through a unit
> test but fails in Tomcat.  By fine, do you mean that you can create your
> stored proc via iBATIS in your unit test?  If so and it fails on your
> webapp, then I'm guessing your webapp is using $ signs for other purposes.
>  You don't mention what language your webapp is using.
>
> At any rate, if you webapp language uses $ signs for its own purposes,
> PostgreSQL allows you to define whatever character you wish for delimiters.
>
>
> On 3/17/2010 5:13 PM, Collin Peters wrote:
>
>> Hi all,
>>
>> I am trying to accomplish an obscure use-case.  I am trying to
>> implement the generation of a Postgres function (aka stored procedure)
>> via iBatis.  I am using an<insert>  tag and simply have the standard
>> PostgreSQL syntax for creating the funciton within it.  I created all
>> this functionality through unit tests and everything worked great.  As
>> soon as I tried to run the application from within my webapp (Tomcat)
>> however, it bailed with an "unterminated dollar-quoted string at or
>> near..." error.  After some debugging I found out that it was
>> truncating the query after the semi-colon.
>>
>> I guess this makes sense as iBatis uses prepared statements and can
>> therefore only execute one SQL statement at a time.  So in this case I
>> am executing one SQL statement which is a 'CREATE FUNCTION' but within
>> that statement there are multiple SQL statements (i.e. the code within
>> the function).  iBatis doesn't seem to be able to handle this though
>> and simple searches through the generated SQL statement and stops at
>> the first semi-colon.
>>
>> I am wondering if there are any work-arounds to this problem?  The
>> only solution that I can think of is to pass off the generation of my
>> custom function to another postgres function, and simply call that
>> function with the necessary arguments.
>>
>> Regards,
>> Collin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>>
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message