I think a union is only a good solution when the data from both queries can be combined into one column.  I think a simple join between the two table should solve your problem.

does this not work?

<select id ="getEmpDetails" parameterClass = "com.abc.Input" resultClass = "com.abc.Output">
select A.emp_name as eName, A.emp_sal as eSal, B.dept_no as eDeptNo from emp A, dept B where A.emp_id = #emp_id# and A.loc_code=#loc_code# and A.emp_id = B.emp_id
</select>

Nathan
On Aug 3, 2005, at 3:28 PM, Larry Meadors wrote:

Not that I am aware of....why not just use a union?

Larry


On 3 Aug 2005 21:25:24 -0000, sreenivas <[EMAIL PROTECTED]> wrote:

Hi,

I would like to know whether or not below approach is possible with iBATIS.

<select id ="getEmpDetails" parameterClass = "com.abc.Input" resultClass = "com.abc.Output">
select emp_name as eName, emp_sal as eSal from emp where emp_id = #emp_id# and loc_code=#loc_code#

select dept_no as eDeptNo from dept where emp_id = #emp_id# and loc_code=#loc_code#
</select>

As in the above code, both queries take inputs from same parameter class, and trying to map results too in the same result class.

I know there are other ways to do that, but would like to know possibility of executing multiple select statements in 1 <select> mapping, and populating results of both the queries into same result object.

Thanks and regards,
Sreeni





Reply via email to