<?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"> <xsp:logic>
String initialsql = "INSERT INTO cmdb (bezeichnung,kategorie,standort,admin) VALUES ('<sql:substitute-value sql:name=\"bezeichnung\"/>','<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"kategorie\"/>', '<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"standort\"/>', '<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"admin\"/>')";
String secondsql = "SELECT id FROM cmdb WHERE bezeichnung='<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"bezeichnung\"/>' AND kategorie='<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"kategorie\"/>' AND standort='<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"standort\"/>' AND admin='<sql:substitute-value xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\" sql:name=\"admin\"/>'";
private String writeOutput() {
StringBuffer sb = new StringBuffer("");
String[] customer = request.getParameterValues("customer");
if(customer!=null) {
for(int i=0;i < customer.length;i++) {
sb.append("<sql:execute-query name=\"customer\" xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\">");
sb.append("<sql:query xmlns:sql=\"http://apache.org/cocoon/SQL/2.0\">");
sb.append("INSERT INTO cmdb2customer (cmdb_id,customer_id) VALUES");
sb.append(" "+ customer[i] + ", <ancestor-value sql:name=\"id\" sql:level=\"1\"/>");
sb.append("</sql:query>");
sb.append("</sql:execute-query>");
}
}
return sb.toString();
}
</xsp:logic>
<content>
<sql:execute-query name="customer" xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query xmlns:sql="http://apache.org/cocoon/SQL/2.0">www
<xsp:expr disable-output-escaping="yes">initialsql</xsp:expr>
</sql:query>
</sql:execute-query>
<sql:execute-query name="customer" xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<xsp:expr disable-output-escaping="yes">secondsql</xsp:expr>
</sql:query>
<xsp:expr disable-output-escaping="yes">writeOutput()</xsp:expr>
</sql:execute-query>
<errormessage message=""/>
<message>
<div class="passive">CI anlegen</div>
</message>
</content>
</xsp:page>--------------------------------------------------------
this is my output for 2 customer-values ('1' and '23'):<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<content xmlns:xsp="http://apache.org/xsp">
<sql:execute-query name="kunde" xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query>INSERT INTO cmdb (bezeichnung,kategorie,standort,admin) VALUES ('<sql:substitute-value sql:name="bezeichnung"/>','<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="kategorie"/>', '<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="standort"/>', '<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="admin"/>')</sql:query>
</sql:execute-query>
<sql:execute-query name="" xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query>SELECT id FROM cmdb WHERE bezeichnung='<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="bezeichnung"/>' AND kategorie='<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="kategorie"/>' AND standort='<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="standort"/>' AND admin='<sql:substitute-value xmlns:sql="http://apache.org/cocoon/SQL/2.0" sql:name="admin"/>'</sql:query><sql:execute-query name="kunde" xmlns:sql="http://apache.org/cocoon/SQL/2.0"><sql:query xmlns:sql="http://apache.org/cocoon/SQL/2.0">INSERT INTO cmdb2kunde (cmdb_id,kunde_id) VALUES 1, <ancestor-value sql:name="id" sql:level="1"/></sql:query></sql:execute-query><sql: execute-query name="kunde" xmlns:sql="http://apache.org/cocoon/SQL/2.0"><sql:query xmlns:sql="http://apache.org/cocoon/SQL/2.0">INSERT INTO cmdb2kunde (cmdb_id,kunde_id) VALUES 23, <ancestor-value sql:name="id" sql:level="1"/></sql:query></sql:execute-query></sql: execute-query>
<errormessage message=""></errormessage>
<message>
<div class=""></div>
</message>
</content>
</html>
------------------------------------------------------
i want to use these generated queries with the sql-transformer....
------------------------------------------------------
thanks again, volker
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
