cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: nested SQL queries
Date Wed, 29 Mar 2000 07:45:33 GMT
On Sat, 25 Mar 2000, Niclas Hedhman wrote:

> Donald Ball wrote:
> 
> > is there any good reason that one would want to do this using some special
> > sql filter/processor/taglib syntax rather than using the xsl:key function?
> >
> > - donald
> 
> I have no clue what you are on about, but something I will need, once I start
> using SQL in Cocoon (yeah, one day...)...
> 
> In Java it looks like this...
> 
> String sql = "SELECT tablename FROM MapIndex WHERE mapname = '" + objectname
> + "' ;";
> st = connection.createStatement();
> ResultSet rs = st.executeQuery( sql );
> rs.first();
> String tablename = rs.getString(1);
> 
> sql = "SELECT * FROM " + tablename + ";";
> :
> :
> :
> 
> I.e. retrieving the tablename from a table to be used in a subsequent query.
> Afaiu, SQL doesn't support this directly, so coding is required. Anything
> that is or will be supported in the SQL taglib???

I'm working on this for the SQLFilter for cocoon2 since it was a bit
easier to work with in SAX. I've got it building the stack of queries and
value relationships now, I just need to write the bit that runs the
queries. Syntax is kinda silly:

<execute-query xmlns="http://xml.apache.org/SQL/1.0">
 <query>select * from department_table</query>
 <execute-query>
  <query>select * from employee_table where department_id = 
   <ancestor name="id" level="1"/>
   order by last_name, first_name
  </query>
 </execute-query>
</execute-query>

I think that would accomodate your needs. Want to help? I hate writing
recursive code... though I love using it. :)

- donald


Mime
View raw message