You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2009/03/04 19:46:50 UTC

Possible to return ibatis query in xml file?

Good morning,

I have a question based on ibatis + struts. Would it be possible that in 
java code, I could get the query in ibatis.

For example, in ibatis_query.xml
<select id="test">
select * from a
</select>


In java,
===============
    public ActionForward execute(
       ActionMapping mapping,
       ActionForm aform,
       HttpServletRequest request,
       HttpServletResponse response)
    throws Exception
    {
       String ibatis_sql = ***(something need to know).getQuery("test", 
null);
     ... ...
    }


Thanks a lot!
Lu Ying






---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Possible to return ibatis query in xml file?

Posted by Martin Gainty <mg...@hotmail.com>.
--you can with oracle so instead of coding this simple statement in ibatis_query.xml
<select id="test">
 select * from a
</select>

--put in this PL/SQL in ibatis_query.xml:

<select id="test">
DECLARE
 ctx    dbms_xmlgen.ctxHandle;
 xml    CLOB;  --Character Large Object (>64k of character string)
 i      PLS_INTEGER;
BEGIN
  ctx := dbms_xmlgen.newContext('SELECT * FROM A);
  xml := dbms_xmlgen.getXML(ctx);
  DBMS_OUTPUT.PUT_LINE(xml);
  i := dbms_xmlgen.getNumRowsProcessed(ctx);
  dbms_output.put_line(TO_CHAR(i));
END;
</select>

Martin
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 




> Date: Wed, 4 Mar 2009 23:14:16 -0200
> Subject: Re: Possible to return ibatis query in xml file?
> From: hgonzalez@gmail.com
> To: user@struts.apache.org
> 
> If I understand right, the answer is no (and the question is not
> related to struts, but only to ibatis).
> You can't get (AFAIK) the sql generated/executed by ibatis, and there
> are good reasons for that.
> If you are debugging some sql problem, your database should allow you
> to turn on full logging
> of your sql queries.
> 
> Hernán J. González
> http://hjg.com.ar/
> 
> On Wed, Mar 4, 2009 at 4:46 PM, Emi Lu <em...@encs.concordia.ca> wrote:
> > Good morning,
> >
> > I have a question based on ibatis + struts. Would it be possible that in
> > java code, I could get the query in ibatis.
> >
> > For example, in ibatis_query.xml
> > <select id="test">
> > select * from a
> > </select>
> >
> >
> > In java,
> > ===============
> >   public ActionForward execute(
> >      ActionMapping mapping,
> >      ActionForm aform,
> >      HttpServletRequest request,
> >      HttpServletResponse response)
> >   throws Exception
> >   {
> >      String ibatis_sql = ***(something need to know).getQuery("test", null);
> >    ... ...
> >   }
> >
> >
> > Thanks a lot!
> > Lu Ying
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> 
> --
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Windows Live™ Contacts: Organize your contact list. 
http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009

Re: Possible to return ibatis query in xml file?

Posted by hernan gonzalez <hg...@gmail.com>.
If I understand right, the answer is no (and the question is not
related to struts, but only to ibatis).
You can't get (AFAIK) the sql generated/executed by ibatis, and there
are good reasons for that.
If you are debugging some sql problem, your database should allow you
to turn on full logging
of your sql queries.

Hernán J. González
http://hjg.com.ar/

On Wed, Mar 4, 2009 at 4:46 PM, Emi Lu <em...@encs.concordia.ca> wrote:
> Good morning,
>
> I have a question based on ibatis + struts. Would it be possible that in
> java code, I could get the query in ibatis.
>
> For example, in ibatis_query.xml
> <select id="test">
> select * from a
> </select>
>
>
> In java,
> ===============
>   public ActionForward execute(
>      ActionMapping mapping,
>      ActionForm aform,
>      HttpServletRequest request,
>      HttpServletResponse response)
>   throws Exception
>   {
>      String ibatis_sql = ***(something need to know).getQuery("test", null);
>    ... ...
>   }
>
>
> Thanks a lot!
> Lu Ying
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



--

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org