You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Lukas Eder (Created) (JIRA)" <ji...@apache.org> on 2012/02/03 17:03:54 UTC

[jira] [Created] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Add support for a SQL REPLACE(in, search, replace) function
-----------------------------------------------------------

                 Key: DERBY-5597
                 URL: https://issues.apache.org/jira/browse/DERBY-5597
             Project: Derby
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 10.8.2.2
            Reporter: Lukas Eder


I don't know any other database that lacks this type of function (even SQLite has it):

REPLACE(in, search)
REPLACE(in, search, replace)

But according to the Derby docs, this doesn't exist in Derby:

http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html

It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
http://msdn.microsoft.com/de-de/library/ms186862.aspx
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200063#comment-13200063 ] 

Dag H. Wanvik commented on DERBY-5597:
--------------------------------------

Thanks for the pointer to the TRANSLATE and TRANSLATE_REGEX functions, Lukas. I see them in my copy of the standard draft, too. Looks powerful enough - any volunteers? :)

                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Lukas Eder (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200368#comment-13200368 ] 

Lukas Eder commented on DERBY-5597:
-----------------------------------

Not me :-)
                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Lukas Eder (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200368#comment-13200368 ] 

Lukas Eder edited comment on DERBY-5597 at 2/4/12 9:15 AM:
-----------------------------------------------------------

Not me :-)

Nice finding. I didn't know the JDBC specs also mention such functions
                
      was (Author: lukas.eder):
    Not me :-)
                  
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Lukas Eder (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199894#comment-13199894 ] 

Lukas Eder commented on DERBY-5597:
-----------------------------------

I understand. REPLACE is probably something like a de-facto standard among various databases. The SQL:2008 standard (I only have a draft version) states:

----------------------------------------------------------------
6.29 <string value function>

Format
<string value function> ::=
<character value function>
| <binary value function>
<character value function> ::=
<character substring function>
| <regular expression substring function>
| <regex substring function>
| <fold>
| <transcoding>
| <character transliteration>
| <regex transliteration>
| <trim function>
| <character overlay function>
| <normalize function>
| <specific type method>
----------------------------------------------------------------

Interesting functions that would work "like" REPLACE are:

----------------------------------------------------------------
<character transliteration> ::=
TRANSLATE <left paren> <character value expression>
USING <transliteration name> <right paren>

<regex transliteration> ::=
TRANSLATE_REGEX <left paren>
<XQuery pattern> [ FLAG <XQuery option flag> ]
IN <regex subject string>
[ WITH <XQuery replacement string> ]
[ FROM <start position> ]
[ USING <char length units> ]
[ OCCURRENCE <regex transliteration occurrence> ]
<left paren>
----------------------------------------------------------------

This might be a bit of overkill though, if the full syntax was supported. Besides, you might be breaking new grounds among common databases.
                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Rick Hillegas (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199863#comment-13199863 ] 

Rick Hillegas commented on DERBY-5597:
--------------------------------------

+1 to adding this function. I agree that it should be easy. The workaround is to code your own user-written function--I had to do this a couple days ago for one of my own applications.
                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199871#comment-13199871 ] 

Dag H. Wanvik commented on DERBY-5597:
--------------------------------------

Note that this function is not a part of the SQL standard. We are normally cautious about adding non-standard features. If we did, I'd want it to have regexp functionality..
                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mamta A. Satoor updated DERBY-5597:
-----------------------------------

    Labels: derby_triage10_10 function sql string  (was: function sql string)
    
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: derby_triage10_10, function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DERBY-5597) Add support for a SQL REPLACE(in, search, replace) function

Posted by "Rick Hillegas (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199943#comment-13199943 ] 

Rick Hillegas commented on DERBY-5597:
--------------------------------------

Compare the JDBC escape function (from Appendix D2 of the 4.1 JDBC spec):

"REPLACE(string1, string2, string3)   Replaces all occurrences of string2 in string1 with string3"

Derby supports a number of builtin functions, including trig functions, which I find in appendix D1 of the JDBC spec, but not in the SQL Standard. This precedent makes me comfortable about adding this function.
                
> Add support for a SQL REPLACE(in, search, replace) function
> -----------------------------------------------------------
>
>                 Key: DERBY-5597
>                 URL: https://issues.apache.org/jira/browse/DERBY-5597
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.2.2
>            Reporter: Lukas Eder
>              Labels: function, sql, string
>
> I don't know any other database that lacks this type of function (even SQLite has it):
> REPLACE(in, search)
> REPLACE(in, search, replace)
> But according to the Derby docs, this doesn't exist in Derby:
> http://db.apache.org/derby/docs/10.8/ref/rrefsqlj29026.html
> It would be quite simple to implement, I guess. Yet really useful for many people. Some documentation examples from other databases:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm
> http://msdn.microsoft.com/de-de/library/ms186862.aspx
> http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.sqlref%2Ffrepl.htm
> http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
> http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#N135A7

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira