ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Monteiro dos Santos <csan...@polimed.com.br>
Subject RES: Appending strings to query
Date Mon, 19 Jun 2006 20:46:46 GMT
Hi, Ted!

Thanks for your tip. How do you deal with the $dbName$ variable? You
substitude by yourself this string for another thing? How do you do this? I
was cheking the link you sent me, and it has something to do with it, as I
see on that page the same kind of usage. How do I pass the value of that
variable to iBATIS?

Thanks, man!

-----Mensagem original-----
De: Ted Schrader [mailto:tschrader@gmail.com]
Enviada em: segunda-feira, 19 de junho de 2006 17:38
Para: user-java@ibatis.apache.org
Assunto: Re: Appending strings to query

Hi Cristiano,

No, it's not too much to expect.  I've had to do something similar,
although probably not as complicated as your situation.

Here's an example:

  FROM $dbName$.ITEMS

My application spans multiple databases (actually, multiple iSeries
libraries) and this has worked out okay, since all of our ITEMS tables
have identical definitions (not my schema!).

Note that we have to use the $ symbol, not #.  Also, when using $, be
sure your values are SQL-escaped to avoid injection attacks.  In my
case, the dbName variable is managed internally by the application.

Also, I recommend you get familiar with the remapResults="true"
setting in case it applies to your situation:



On 19/06/06, Cristiano Monteiro dos Santos <csantos@polimed.com.br> wrote:
> Hi again, guys.
> I have another question: is it possible to append string snippets to the
> iBATIS's xml queries? I mean, I have several databases, each of then
> containing the same set of tables, following the schema
> #databasename#:tb#customerid#user (not telling if it's right or wrong,
> fact), and I want to execute the queries sometimes in one database,
> sometimes in the other. Like this:
> select f1, f2, f3
> #databasename#:tb#customerid#user
> Resulting in the following query:
> select f1, f2, f3
> custname:tb123user
> Where #databasename# and #customerid# are both attributes of the
> parameterClass. Am I expecting too much?
> Thanks!
> Cristiano

View raw message