You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Barnett, Brian W." <br...@pearson.com> on 2005/07/11 22:28:37 UTC
Multiple queries in one call
Anyone know how to make something like this work in MS SQL Server? I have
two select statements, the first selects into a temp table and the second
selects from the temp table. I want to do it in one call to the db. I need
help with the SQL. I can execute both queries in SQL Query Analyzer just
fine, but I can't when I use iBATIS. Is there a different syntax I need to
use?
The SQL is something like this:
SELECT col1, col2 FROM table1 INTO ##mytemptable
JOIN table2 ON blah blah
JOIN table3 ON blah blah
WHERE blah blah
SELECT DISTINCT col1, col2 FROM ##mytemptable
SQL Map snippet:
<select id="getData" resultMap="result_map"
parameterClass="java.util.HashMap">
$sql$
</select>
TIA,
Brian Barnett
****************************************************************************
This email may contain confidential material.
If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.
****************************************************************************
Re: Multiple queries in one call
Posted by Larry Meadors <la...@gmail.com>.
try a ";" between the sql stmts.
On 7/11/05, Barnett, Brian W. <br...@pearson.com> wrote:
> Anyone know how to make something like this work in MS SQL Server? I have
> two select statements, the first selects into a temp table and the second
> selects from the temp table. I want to do it in one call to the db. I need
> help with the SQL. I can execute both queries in SQL Query Analyzer just
> fine, but I can't when I use iBATIS. Is there a different syntax I need to
> use?
>
> The SQL is something like this:
> SELECT col1, col2 FROM table1 INTO ##mytemptable
> JOIN table2 ON blah blah
> JOIN table3 ON blah blah
> WHERE blah blah
>
> SELECT DISTINCT col1, col2 FROM ##mytemptable
>
>
> SQL Map snippet:
> <select id="getData" resultMap="result_map"
> parameterClass="java.util.HashMap">
> $sql$
> </select>
>
> TIA,
> Brian Barnett
>
> ****************************************************************************
> This email may contain confidential material.
> If you were not an intended recipient,
> Please notify the sender and delete all copies.
> We may monitor email to and from our network.
> ****************************************************************************
>