Christian Haul wrote:

> On 02.Jul.2002 -- 11:36 AM, Bobby Mitchell wrote:
> 
>>>>While using Sybase I had to remove the <esql:parameter> begin and end 
>>>>tags in order to actually edit the entry, otherwise I get an sql error 
>>>>stating that "SELECT name, department_id FROM employee WHERE id = ? " is 
>>>>an error. The id is being passed as a ? so it causes an error. When 
>>>>using Hsqldb I made no changes to the code.
>>>>
>>>>
>>This behaviour is the same as before. Here is the error message:
>>
>>
>>org.apache.cocoon.ProcessingException: Exception in 
>>ServerPagesGenerator.generate(): java.lang.RuntimeException: Error 
>>executing statement: SELECT name, department_id FROM employee WHERE id = 
>>? : com.sybase.jdbc2.jdbc.SybSQLException: Implicit conversion from 
>>datatype 'CHAR' to 'INT' is not allowed. Use the CONVERT function to run 
>>this query.
>>
> 
> Yep, error message says it all. The example is attempting to use a
> String to set an int column. It looks like HSQLDB is more forgiving in
> this. Change it to
> 
>             <esql:query>
>               SELECT name, department_id FROM employee
>               WHERE id = <esql:parameter 
>type="int"><xsp:expr>Integer.parseInt(<xsp-request:get-parameter name="id" 
>default="0"/>)</xsp:expr></esql:parameter>
>             </esql:query>
> 
> and convert the string explicitly to an integer. I've set a default of
> "0" in case the parameter is non-existent to prevent a NPE or
> NumberFormatException. 
> 
> It would be great if you could go through the tutorial and look for
> other, similar changes, that would be required to run it e.g. on
> sybase and file a bug in bugzilla with patches.
> 
>       Chris.


I applied the changes and everything works fine. I am including a patch 
file and I will also file a report on bugzilla. Thanks for the help.

patch file for the directory cocoon/tutorial/docs:
**************************************************************************
diff -Naur tutorial/docs/edit-dept.xsp tutorial/docs.sybase/edit-dept.xsp
--- tutorial/docs/edit-dept.xsp  Tue Jul  9 09:50:57 2002
+++ tutorial/docs.sybase/edit-dept.xsp Tue Jul  9 09:47:56 2002
@@ -24,7 +24,7 @@
              <esql:execute-query>
                <esql:query>
                  SELECT name FROM department
-                WHERE id = <esql:parameter><xsp-request:get-parameter 
name="id"/></esql:parameter>
+               WHERE id = <esql:parameter 
type="int"><xsp:expr>Integer.parseInt(<xsp-request:get-parameter 
name="id" default="0"/>)</xsp:expr></esql:parameter>
                </esql:query>
                <esql:results>
                  <esql:row-results>
diff -Naur tutorial/docs/edit-empl.xsp tutorial/docs.sybase/edit-empl.xsp
--- tutorial/docs/edit-empl.xsp  Tue Jul  9 09:50:57 2002
+++ tutorial/docs.sybase/edit-empl.xsp Tue Jul  9 09:54:39 2002
@@ -23,7 +23,7 @@
            <esql:execute-query>
              <esql:query>
                SELECT name, department_id FROM employee
-              WHERE id = <esql:parameter><xsp-request:get-parameter 
name="id"/></esql:parameter>
+             WHERE id = <esql:parameter 
type="int"><xsp:expr>Integer.parseInt(<xsp-request:get-parameter 
name="id" default="0"/>)</xsp:expr></esql:parameter>
              </esql:query>
              <esql:results>
                <esql:row-results>
***************************************************************************


> 
> Please follow up summarizing your problem and which suggested solution
> / information worked for you when you consider your problem
> solved. Add "SUMMARY: " to the subject line. This will make FAQ
> generation and searching the list easier. In addition, it makes
> helping you more fun. Thank you.
> 
> 


-- 
Robert J. (Bobby) Mitchell
Systems Administrator
NASA Institute for Advanced Concepts
555A 14th St Atlanta, Ga. 30318
Phone: (404)347-9633 Fax: (404)347-9638



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to