Re: Problem with RTRIM() Function in DB2 v.5 for MVS/OS-390

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Sep 23 2004 - 17:44:09 EDT

  • Next message: Andrus Adamchik: "Re: Another Problem with DB2 v.5 for MVS/OS-390"

    Actually just recently this topic was raised in an unrelated case
    (http://objectstyle.org/cayenne/lists/cayenne-user/2004/09/0087.html).
    Eventually Cayenne should provide public API to customize this. Right
    now your best bet is to create your own DbAdapter. This is not as hard
    as it sounds:

    public class NoTrimDB2Adapter extends
    org.objectstyle.cayenne.dba.db2.DB2Adapter {
         public QualifierTranslator getQualifierTranslator(QueryAssembler
    queryAssembler) {
             return new NoTrimDB2QualifierTranslator(queryAssembler);
         }
    }

    public class NoTrimDB2QualifierTranslator extends QualifierTranslator {
         NoTrimDB2QualifierTranslator(QueryAssembler queryAssembler) {
             super(queryAssembler);
         }

       // here copy verbatim the implementation of
       // "appendLiteralDirect()" from DB2QualifierTranslator
       // ...
    }

    Andrus

    On Sep 23, 2004, at 5:15 PM, André Luiz do Nascimento Sousa wrote:
    > Hello, Cayenne Users,
    >  
    >  
    >         I'm facing a little trouble with RTrim() function in char()
    > types. I'm using the big shit of DB2 v.5 for MVS/OS-390 and it doesn't
    > have this function.
    >  
    >         I'm using the "org.objectstyle.cayenne.dba.db2.DB2Adapter". Is
    > there another way to avoid the use of RTRIM()?
    >  
    >         See the code:
    >
    > wDtCtx = DataContext.createDataContext();
    > if (wForm.getSiglaUf() != null) {
    >
    > wSQL += " and siglaUf = $pUF ";
    >
    > wHashParams.put("pUF", wForm.getSiglaUf());
    >
    > }
    > wExpr = Expression.fromString(wSQL).expWithParameters(wHashParams);
    > wQuery = new SelectQuery(Extracao.class, wExpr);
    >
    > wForm.setVecResultadoPesquisa(wDtCtx.performQuery(wQuery));
    >
    >  
    >
    > INFO RequestProcessor: Processing a 'POST' for path '/TestarCayenne'
    > INFO QueryLogger: --- will run 1 query.
    > INFO QueryLogger: SELECT t0.COD_BOL_SIMUL, t0.DES_NUMERO_SORT,
    > t0.DTH_EXTRACAO, t0.NOM_LOCAL_EXTRACAO, t0.NUM_EXTRACAO,
    > t0.NUM_INICIAL_DOC, t0.SIGLA_UF, t0.IDE_REGRA_EXTRACAO FROM
    > FDRCAP.FC_EXTRACAO t0 WHERE (? = ?) AND (RTRIM(t0.SIGLA_UF) = ?)
    > [bind: 1, 1, 'DF']
    > INFO QueryLogger: *** error.
    > COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0104N Um
    > token inesperado "RTRIM" foi encontrado após "". Os tokens esperados
    > podem incluir: "AVG, SUBSTR, MAX, HEX, FLOAT, DATE, YEAR, ETC.".
    > SQLSTATE=42601
    >
    > at java.lang.Throwable.<init>(Throwable.java:59)
    > at java.lang.Throwable.<init>(Throwable.java:73)
    >  
    >         Thanks a lot.
    >  
    > André Luiz do Nascimento Sousa
    >     Analista de Sistemas - J2EE
    >         Brasil    <) ><



    This archive was generated by hypermail 2.0.0 : Thu Sep 23 2004 - 17:44:12 EDT