You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Parthasarathy Thandavarayan <Pa...@sos.sungard.com> on 2006/10/03 12:47:06 UTC

escapeText method in DBOracle

Hi all,

I have a question regarding the escapeText method in org.apache.torque.adapter.DBOracle class. Unlike the DBMSSQL, DBSybase class this method in DBOracle returns a false. However, oracle does require escape characters for interpreting certain special characters like "_" literally.

Below is a copy of the source code in DBOracle.
    /**
     * This method is for the SqlExpression.quoteAndEscape rules.  The rule is,
     * any string in a SqlExpression with a BACKSLASH will either be changed to
     * "\\" or left as "\".  SapDB does not need the escape character.
     *
     * @return false.
     */
    public boolean escapeText()
    {
        return false;
    }


The usecase I am trying out is one where a column in the table queried has values 'abc' and    'a_c'. I need to query the record that has the column value as 'a_c'. If I issue a query without escapecharacters (where <column> like 'a_%' ) both the rows are returned. I need to  provide a where clause with the condition as <column> like 'a\_%' to get the correct record (also need to add ESCAPE keyword to the query). However, because escapeText returns false, the criteria value gets built wrongly in the buildLike method of SQLExpression class.. (the method returns 'a\%'). If escapeText returns true this problem will be solved (ESCAPE keyword addition needs to be tackled also).

Thanks,
Sarathy

PS: information regarding escape characters in Oracle http://www.dba-oracle.com/tips_oracle_escape_characters.htm

Re: escapeText method in DBOracle

Posted by Thomas Fischer <tf...@apache.org>.
Would you mind to create a jira issue on that ?

    Thanks,

      Thomas

On Tue, 3 Oct 2006, Parthasarathy Thandavarayan wrote:

> Hi all,
>
> I have a question regarding the escapeText method in org.apache.torque.adapter.DBOracle class. Unlike the DBMSSQL, DBSybase class this method in DBOracle returns a false. However, oracle does require escape characters for interpreting certain special characters like "_" literally.
>
> Below is a copy of the source code in DBOracle.
>    /**
>     * This method is for the SqlExpression.quoteAndEscape rules.  The rule is,
>     * any string in a SqlExpression with a BACKSLASH will either be changed to
>     * "\\" or left as "\".  SapDB does not need the escape character.
>     *
>     * @return false.
>     */
>    public boolean escapeText()
>    {
>        return false;
>    }
>
>
> The usecase I am trying out is one where a column in the table queried has values 'abc' and    'a_c'. I need to query the record that has the column value as 'a_c'. If I issue a query without escapecharacters (where <column> like 'a_%' ) both the rows are returned. I need to  provide a where clause with the condition as <column> like 'a\_%' to get the correct record (also need to add ESCAPE keyword to the query). However, because escapeText returns false, the criteria value gets built wrongly in the buildLike method of SQLExpression class.. (the method returns 'a\%'). If escapeText returns true this problem will be solved (ESCAPE keyword addition needs to be tackled also).
>
> Thanks,
> Sarathy
>
> PS: information regarding escape characters in Oracle http://www.dba-oracle.com/tips_oracle_escape_characters.htm
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org