cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r321210 - /cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java
Date Fri, 14 Oct 2005 20:32:06 GMT
Author: vgritsenko
Date: Fri Oct 14 13:32:02 2005
New Revision: 321210

URL: http://svn.apache.org/viewcvs?rev=321210&view=rev
Log:
    <action dev="VG" type="fix" fixes-bug="30894">
      Databases block: Support stored procedures returning result set in SQLTransformer.
    </action>


Modified:
    cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java

Modified: cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java?rev=321210&r1=321209&r2=321210&view=diff
==============================================================================
--- cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java
(original)
+++ cocoon/blocks/databases/trunk/java/org/apache/cocoon/transformation/SQLTransformer.java
Fri Oct 14 13:32:02 2005
@@ -1182,17 +1182,19 @@
                     }
                     start(this.rowsetElement, attr);
 
+                    // Serialize stored procedure output parameters
                     if (isStoredProcedure) {
                         serializeStoredProcedure();
-                    } else {
-                        while (next()) {
-                            start(this.rowElement, EMPTY_ATTRIBUTES);
-                            serializeRow();
-                            for (Iterator i = this.nested.iterator(); i.hasNext();) {
-                                ((Query) i.next()).executeQuery();
-                            }
-                            end(this.rowElement);
+                    }
+
+                    // Serialize result set
+                    while (next()) {
+                        start(this.rowElement, EMPTY_ATTRIBUTES);
+                        serializeRow();
+                        for (Iterator i = this.nested.iterator(); i.hasNext();) {
+                            ((Query) i.next()).executeQuery();
                         }
+                        end(this.rowElement);
                     }
 
                     end(this.rowsetElement);
@@ -1444,17 +1446,17 @@
             // make sure output follows order as parameter order in stored procedure
             Iterator itOutKeys = new TreeMap(outParameters).keySet().iterator();
             while (itOutKeys.hasNext()) {
-                Integer counter = (Integer) itOutKeys.next();
+                final Integer counter = (Integer) itOutKeys.next();
                 try {
-                    Object obj = cst.getObject(counter.intValue());
+                    final Object obj = cst.getObject(counter.intValue());
+                    final String name = (String) outParametersNames.get(counter);
+                    start(name, EMPTY_ATTRIBUTES);
+
                     if (!(obj instanceof ResultSet)) {
-                        start((String) outParametersNames.get(counter), EMPTY_ATTRIBUTES);
                         serializeData(getStringValue(obj));
-                        end((String) outParametersNames.get(counter));
                     } else {
-                        ResultSet rs = (ResultSet) obj;
+                        final ResultSet rs = (ResultSet) obj;
                         try {
-                            start((String) outParametersNames.get(counter), EMPTY_ATTRIBUTES);
                             ResultSetMetaData md = rs.getMetaData();
                             while (rs.next()) {
                                 start(this.rowElement, EMPTY_ATTRIBUTES);
@@ -1477,8 +1479,9 @@
                                 /* ignored */
                             }
                         }
-                        end((String) outParametersNames.get(counter));
                     }
+
+                    end(name);
                 } catch (SQLException e) {
                     getLogger().error("Caught a SQLException", e);
                     throw e;



Mime
View raw message