#2 will on most platforms, because the statement will be
parameterized: #pk# vs $pk$

Other than that, they should be identical...with the exception that #1
will be vulnerable to SQL injection.

Larry


On Nov 26, 2007 9:22 AM, Chema <[EMAIL PROTECTED]> wrote:
>
> Hello:
>
> I'm trying to make a simple query on two different tables.
> This query has same fields but different table name. The query selector is
> the PK field
>
> My question is:
>
> what is, in performance terms, the best solution: passing to query the table
> name as parameter or make two queries with different table name each one ?
>
> For example:
>
> 1)
>
> <select id="getF" resultClass="java.sql.Timestamp"
> parameterClass="java.util.HashMap">
>      SELECT  FIELD
>      FROM     $table$
>      WHERE  PK= $pk$
>    </select>
>
> or
>
> 2)
>
>
> <select id="getF_1" resultClass="java.sql.Timestamp"
> parameterClass="java.lang.String">
>     SELECT  FIELD
>     FROM     A
>     WHERE  PK= #pk#
>   </select>
>
>     <select id="getF_2" resultClass="java.sql.Timestamp"
> parameterClass="java.lang.String">
>      SELECT  FIELD
>      FROM     B
>      WHERE  PK= #pk#
>   </select>
>
>
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Reply via email to