Commit f3fde998 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Augment info on string functions per Jose Soares' suggestions.

parent bda62466
...@@ -65,54 +65,86 @@ available through operators and may be documented as operators only. ...@@ -65,54 +65,86 @@ available through operators and may be documented as operators only.
</Para> </Para>
</sect1> </sect1>
<sect1> <sect1>
<title>String Functions</title> <title>String Functions</title>
<Para> <Para>
SQL92 defines string functions with specific syntax. Some of these SQL92 defines string functions with specific syntax. Some of these
are implemented using other <ProductName>Postgres</ProductName> functions. are implemented using other <ProductName>Postgres</ProductName> functions.
</Para> The supported string types for <acronym>SQL92</acronym> are
<type>char</type>, <type>varchar</type>, and <type>text</type>.
</Para>
<Para> <Para>
<TABLE TOCENTRY="1"> <TABLE TOCENTRY="1">
<TITLE><Acronym>SQL92</Acronym> String Functions</TITLE> <TITLE><Acronym>SQL92</Acronym> String Functions</TITLE>
<TGROUP COLS="4"> <TGROUP COLS="4">
<THEAD> <THEAD>
<ROW> <ROW>
<ENTRY>Function</ENTRY> <ENTRY>Function</ENTRY>
<ENTRY>Returns</ENTRY> <ENTRY>Returns</ENTRY>
<ENTRY>Description</ENTRY> <ENTRY>Description</ENTRY>
<ENTRY>Example</ENTRY> <ENTRY>Example</ENTRY>
</ROW> </ROW>
</THEAD> </THEAD>
<TBODY> <TBODY>
<ROW> <ROW>
<ENTRY> position(text in text) </ENTRY> <ENTRY> char_length(string) </ENTRY>
<ENTRY> int4 </ENTRY> <ENTRY> int4 </ENTRY>
<ENTRY> location of specified substring </ENTRY> <ENTRY> length of string </ENTRY>
<ENTRY> position('o' in 'Tom') </ENTRY> <ENTRY> char_length('jose') </ENTRY>
</ROW> </ROW>
<ROW> <ROW>
<ENTRY> substring(text [from int] [for int]) </ENTRY> <ENTRY> character_length(string) </ENTRY>
<ENTRY> text </ENTRY> <ENTRY> int4 </ENTRY>
<ENTRY> extract specified substring </ENTRY> <ENTRY> length of string </ENTRY>
<ENTRY> substring('Tom' from 2 for 2) </ENTRY> <ENTRY> char_length('jose') </ENTRY>
</ROW> </ROW>
<ROW> <ROW>
<ENTRY> trim([leading|trailing|both] [text] from text) </ENTRY> <ENTRY> lower(string) </ENTRY>
<ENTRY> text </ENTRY> <ENTRY> string </ENTRY>
<ENTRY> trim characters from text </ENTRY> <ENTRY> convert string to lower case </ENTRY>
<ENTRY> trim(both 'x' from 'xTomx') </ENTRY> <ENTRY> lower('TOM') </ENTRY>
</ROW> </ROW>
</TBODY> <ROW>
</TGROUP> <ENTRY> octet_length(string) </ENTRY>
</TABLE> <ENTRY> int4 </ENTRY>
</Para> <ENTRY> storage length of string </ENTRY>
<ENTRY> octet_length('jose') </ENTRY>
</ROW>
<ROW>
<ENTRY> position(string in string) </ENTRY>
<ENTRY> int4 </ENTRY>
<ENTRY> location of specified substring </ENTRY>
<ENTRY> position('o' in 'Tom') </ENTRY>
</ROW>
<ROW>
<ENTRY> substring(string [from int] [for int]) </ENTRY>
<ENTRY> string </ENTRY>
<ENTRY> extract specified substring </ENTRY>
<ENTRY> substring('Tom' from 2 for 2) </ENTRY>
</ROW>
<ROW>
<ENTRY> trim([leading|trailing|both] [string] from string) </ENTRY>
<ENTRY> string </ENTRY>
<ENTRY> trim characters from string </ENTRY>
<ENTRY> trim(both 'x' from 'xTomx') </ENTRY>
</ROW>
<ROW>
<ENTRY> upper(text) </ENTRY>
<ENTRY> text </ENTRY>
<ENTRY> convert text to upper case </ENTRY>
<ENTRY> upper('tom') </ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
<Para> <Para>
Many string functions are available for text, varchar(), and char() types. Many additional string functions are available for text, varchar(), and char() types.
Some are used internally to implement the SQL92 string functions listed above. Some are used internally to implement the SQL92 string functions listed above.
</Para> </Para>
<Para> <Para>
<TABLE TOCENTRY="1"> <TABLE TOCENTRY="1">
...@@ -146,12 +178,6 @@ Some are used internally to implement the SQL92 string functions listed above. ...@@ -146,12 +178,6 @@ Some are used internally to implement the SQL92 string functions listed above.
<ENTRY> initcap('thomas') </ENTRY> <ENTRY> initcap('thomas') </ENTRY>
</ROW> </ROW>
<ROW> <ROW>
<ENTRY> lower(text) </ENTRY>
<ENTRY> text </ENTRY>
<ENTRY> convert text to lower case </ENTRY>
<ENTRY> lower('TOM') </ENTRY>
</ROW>
<ROW>
<ENTRY> lpad(text,int,text) </ENTRY> <ENTRY> lpad(text,int,text) </ENTRY>
<ENTRY> text </ENTRY> <ENTRY> text </ENTRY>
<ENTRY> left pad string to specified length </ENTRY> <ENTRY> left pad string to specified length </ENTRY>
...@@ -164,9 +190,9 @@ Some are used internally to implement the SQL92 string functions listed above. ...@@ -164,9 +190,9 @@ Some are used internally to implement the SQL92 string functions listed above.
<ENTRY> ltrim('xxxxtrim','x') </ENTRY> <ENTRY> ltrim('xxxxtrim','x') </ENTRY>
</ROW> </ROW>
<ROW> <ROW>
<ENTRY> position(text,text) </ENTRY> <ENTRY> textpos(text,text) </ENTRY>
<ENTRY> text </ENTRY> <ENTRY> text </ENTRY>
<ENTRY> extract specified substring </ENTRY> <ENTRY> locate specified substring </ENTRY>
<ENTRY> position('high','ig') </ENTRY> <ENTRY> position('high','ig') </ENTRY>
</ROW> </ROW>
<ROW> <ROW>
...@@ -217,12 +243,6 @@ Some are used internally to implement the SQL92 string functions listed above. ...@@ -217,12 +243,6 @@ Some are used internally to implement the SQL92 string functions listed above.
<ENTRY> convert text to varchar type </ENTRY> <ENTRY> convert text to varchar type </ENTRY>
<ENTRY> varchar('text string') </ENTRY> <ENTRY> varchar('text string') </ENTRY>
</ROW> </ROW>
<ROW>
<ENTRY> upper(text) </ENTRY>
<ENTRY> text </ENTRY>
<ENTRY> convert text to upper case </ENTRY>
<ENTRY> upper('tom') </ENTRY>
</ROW>
</TBODY> </TBODY>
</TGROUP> </TGROUP>
</TABLE> </TABLE>
...@@ -689,3 +709,19 @@ support functions. ...@@ -689,3 +709,19 @@ support functions.
</chapter> </chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment