2001-11-17 23:20:34 +01:00
<!--
2002-08-09 18:45:16 +02:00
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.110 2002/08/09 16:45:13 tgl Exp $
2001-11-21 06:53:41 +01:00
PostgreSQL documentation
2001-11-17 23:20:34 +01:00
-->
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<chapter id="functions">
<title>Functions and Operators</title>
<indexterm zone="functions">
<primary>functions</primary>
2001-05-13 00:51:36 +02:00
</indexterm>
2002-06-11 17:32:33 +02:00
<indexterm zone="functions">
<primary>operators</primary>
2001-05-13 00:51:36 +02:00
</indexterm>
2001-01-21 23:02:01 +01:00
<para>
2002-06-11 17:32:33 +02:00
<productname>PostgreSQL</productname> provides a large number of
functions and operators for the built-in data types. Users can also
define their own functions and operators, as described in the
<citetitle>Programmer's Guide</citetitle>. The
<application>psql</application> commands <command>\df</command> and
<command>\do</command> can be used to show the list of all actually
available functions and operators, respectively.
</para>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<para>
If you are concerned about portability then take note that most of
the functions and operators described in this chapter, with the
exception of the most trivial arithmetic and comparison operators
and some explicitly marked functions, are not specified by the
<acronym>SQL</acronym>
standard. Some of this extended functionality is present in other
<acronym>RDBMS</acronym> products, and in many cases this
functionality is compatible and consistent between various products.
</para>
2001-05-13 00:51:36 +02:00
2002-06-11 17:32:33 +02:00
<sect1 id="functions-logical">
<title>Logical Operators</title>
<indexterm zone="functions-logical">
<primary>operators</primary>
<secondary>logical</secondary>
2001-05-13 00:51:36 +02:00
</indexterm>
<indexterm>
2002-06-11 17:32:33 +02:00
<primary>Boolean</primary>
<secondary>operators</secondary>
<see>operators, logical</see>
2001-05-13 00:51:36 +02:00
</indexterm>
2002-06-11 17:32:33 +02:00
<para>
The usual logical operators are available:
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<indexterm>
<primary>and</primary>
<secondary>operator</secondary>
</indexterm>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<indexterm>
<primary>or</primary>
<secondary>operator</secondary>
</indexterm>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<indexterm>
<primary>not</primary>
<secondary>operator</secondary>
</indexterm>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<simplelist>
<member>AND</member>
<member>OR</member>
<member>NOT</member>
</simplelist>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<acronym>SQL</acronym> uses a three-valued Boolean logic where NULL represents
<quote>unknown</quote>. Observe the following truth tables:
<informaltable>
<tgroup cols="4">
<thead>
<row>
<entry><replaceable>a</replaceable></entry>
<entry><replaceable>b</replaceable></entry>
<entry><replaceable>a</replaceable> AND <replaceable>b</replaceable></entry>
<entry><replaceable>a</replaceable> OR <replaceable>b</replaceable></entry>
</row>
</thead>
<tbody>
<row>
<entry>TRUE</entry>
<entry>TRUE</entry>
<entry>TRUE</entry>
<entry>TRUE</entry>
</row>
<row>
<entry>TRUE</entry>
<entry>FALSE</entry>
<entry>FALSE</entry>
<entry>TRUE</entry>
</row>
<row>
<entry>TRUE</entry>
<entry>NULL</entry>
<entry>NULL</entry>
<entry>TRUE</entry>
</row>
<row>
<entry>FALSE</entry>
<entry>FALSE</entry>
<entry>FALSE</entry>
<entry>FALSE</entry>
</row>
<row>
<entry>FALSE</entry>
<entry>NULL</entry>
<entry>FALSE</entry>
<entry>NULL</entry>
</row>
<row>
<entry>NULL</entry>
<entry>NULL</entry>
<entry>NULL</entry>
<entry>NULL</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry><replaceable>a</replaceable></entry>
<entry>NOT <replaceable>a</replaceable></entry>
</row>
</thead>
<tbody>
<row>
<entry>TRUE</entry>
<entry>FALSE</entry>
</row>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>FALSE</entry>
<entry>TRUE</entry>
</row>
<row>
<entry>NULL</entry>
<entry>NULL</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</sect1>
<sect1 id="functions-comparison">
<title>Comparison Operators</title>
<indexterm zone="functions-comparison">
<primary>comparison</primary>
<secondary>operators</secondary>
</indexterm>
<table>
<title>Comparison Operators</title>
<tgroup cols="2">
<thead>
2001-01-21 23:02:01 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry>Operator</entry>
<entry>Description</entry>
2001-01-21 23:02:01 +01:00
</row>
2002-06-11 17:32:33 +02:00
</thead>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
2001-01-21 23:02:01 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal><</literal> </entry>
<entry>less than</entry>
2001-01-21 23:02:01 +01:00
</row>
2001-02-19 01:01:18 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>></literal> </entry>
<entry>greater than</entry>
2001-02-19 01:01:18 +01:00
</row>
2001-01-21 23:02:01 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal><=</literal> </entry>
<entry>less than or equal to</entry>
2001-01-21 23:02:01 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>>=</literal> </entry>
<entry>greater than or equal to</entry>
2001-01-21 23:02:01 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>=</literal> </entry>
<entry>equal</entry>
2001-01-21 23:02:01 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal><></literal> or <literal>!=</literal> </entry>
<entry>not equal</entry>
2001-01-21 23:02:01 +01:00
</row>
</tbody>
</tgroup>
2002-06-11 17:32:33 +02:00
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<note>
<para>
The <literal>!=</literal> operator is converted to
<literal><></literal> in the parser stage. It is not
possible to implement <literal>!=</literal> and
<literal><></literal> operators that do different things.
</para>
</note>
2000-12-14 23:30:56 +01:00
1999-06-14 09:36:12 +02:00
<para>
2002-06-11 17:32:33 +02:00
Comparison operators are available for all data types where this
makes sense. All comparison operators are binary operators that
return values of type <type>boolean</type>; expressions like
<literal>1 < 2 < 3</literal> are not valid (because there is
no <literal><</literal> operator to compare a Boolean value with
<literal>3</literal>).
1999-06-14 09:36:12 +02:00
</para>
2001-01-21 23:02:01 +01:00
2002-06-11 17:32:33 +02:00
<para>
<indexterm>
<primary>between</primary>
</indexterm>
In addition to the comparison operators, the special
<token>BETWEEN</token> construct is available.
<synopsis>
2001-02-05 20:21:45 +01:00
<replaceable>a</replaceable> BETWEEN <replaceable>x</replaceable> AND <replaceable>y</replaceable>
2002-06-11 17:32:33 +02:00
</synopsis>
is equivalent to
<synopsis>
<replaceable>a</replaceable> >= <replaceable>x</replaceable> AND <replaceable>a</replaceable>able> <= <replaceable>y</replaceable>
</synopsis>
Similarly,
<synopsis>
2001-02-05 20:21:45 +01:00
<replaceable>a</replaceable> NOT BETWEEN <replaceable>x</replaceable> AND <replaceable>y</replaceable>
2002-06-11 17:32:33 +02:00
</synopsis>
is equivalent to
<synopsis>
<replaceable>a</replaceable> < <replaceable>x</replaceable> OR <replaceable>a</replaceable>able> > <replaceable>y</replaceable>
</synopsis>
There is no difference between the two respective forms apart from
the <acronym>CPU</acronym> cycles required to rewrite the first one
into the second one internally.
</para>
2001-02-05 20:21:45 +01:00
2002-06-11 17:32:33 +02:00
<para>
To check whether a value is or is not NULL, use the constructs
<synopsis>
2001-01-21 23:02:01 +01:00
<replaceable>expression</replaceable> IS NULL
<replaceable>expression</replaceable> IS NOT NULL
2002-06-11 17:32:33 +02:00
</synopsis>
or the equivalent, but less standard, constructs
<synopsis>
2001-12-01 05:19:20 +01:00
<replaceable>expression</replaceable> ISNULL
<replaceable>expression</replaceable> NOTNULL
2002-06-11 17:32:33 +02:00
</synopsis>
</para>
2001-12-01 05:19:20 +01:00
2002-06-11 17:32:33 +02:00
<para>
Do <emphasis>not</emphasis> write
<literal><replaceable>expression</replaceable> = NULL</literal>
because NULL is not <quote>equal to</quote> NULL. (NULL represents
an unknown value, and it is not known whether two unknown values are
equal.)
</para>
2001-06-20 00:39:12 +02:00
2002-06-11 17:32:33 +02:00
<para>
Some applications may (incorrectly) require that
<literal><replaceable>expression</replaceable> = NULL</literal>
returns true if <replaceable>expression</replaceable> evaluates to
the NULL value. To support these applications, the run-time option
<varname>transform_null_equals</varname> can be turned on (e.g.,
<literal>SET transform_null_equals TO ON;</literal>).
<productname>PostgreSQL</productname> will then convert
<literal>x = NULL</literal> clauses to
<literal>x IS NULL</literal>. This was
the default behavior in releases 6.5 through 7.1.
</para>
2001-09-20 16:20:28 +02:00
2002-06-11 17:32:33 +02:00
<para>
Boolean values can also be tested using the constructs
<synopsis>
2001-06-20 00:39:12 +02:00
<replaceable>expression</replaceable> IS TRUE
<replaceable>expression</replaceable> IS NOT TRUE
<replaceable>expression</replaceable> IS FALSE
<replaceable>expression</replaceable> IS NOT FALSE
<replaceable>expression</replaceable> IS UNKNOWN
<replaceable>expression</replaceable> IS NOT UNKNOWN
2002-06-11 17:32:33 +02:00
</synopsis>
These are similar to <literal>IS NULL</literal> in that they will
always return TRUE or FALSE, never NULL, even when the operand is NULL.
A NULL input is treated as the logical value UNKNOWN.
</para>
</sect1>
2001-01-13 19:34:51 +01:00
2002-06-11 17:32:33 +02:00
<sect1 id="functions-math">
<title>Mathematical Functions and Operators</title>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
Mathematical operators are provided for many
<productname>PostgreSQL</productname> types. For types without
common mathematical conventions for all possible permutations
(e.g. date/time types) we
describe the actual behavior in subsequent sections.
</para>
2001-01-13 19:34:51 +01:00
<table>
2002-06-11 17:32:33 +02:00
<title>Mathematical Operators</title>
2001-01-13 19:34:51 +01:00
2002-06-11 17:32:33 +02:00
<tgroup cols="4">
2001-01-13 19:34:51 +01:00
<thead>
<row>
2002-06-11 17:32:33 +02:00
<entry>Name</entry>
<entry>Description</entry>
2001-01-13 19:34:51 +01:00
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
<tbody>
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>+</literal> </entry>
<entry>Addition</entry>
<entry>2 + 3</entry>
<entry>5</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
2001-01-13 19:34:51 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>-</literal> </entry>
<entry>Subtraction</entry>
<entry>2 - 3</entry>
<entry>-1</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
2001-01-13 19:34:51 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>*</literal> </entry>
<entry>Multiplication</entry>
<entry>2 * 3</entry>
<entry>6</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
2001-01-13 19:34:51 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>/</literal> </entry>
<entry>Division (integer division truncates results)</entry>
<entry>4 / 2</entry>
<entry>2</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
2001-01-13 19:34:51 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>%</literal> </entry>
<entry>Modulo (remainder)</entry>
<entry>5 % 4</entry>
<entry>1</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
2001-01-13 19:34:51 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry> <literal>^</literal> </entry>
<entry>Exponentiation</entry>
<entry>2.0 ^ 3.0</entry>
<entry>8</entry>
2001-01-13 19:34:51 +01:00
</row>
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>|/</literal> </entry>
<entry>Square root</entry>
<entry>|/ 25.0</entry>
<entry>5</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>||/</literal> </entry>
<entry>Cube root</entry>
<entry>||/ 27.0</entry>
<entry>3</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>!</literal> </entry>
<entry>Factorial</entry>
<entry>5 !</entry>
<entry>120</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>!!</literal> </entry>
<entry>Factorial (prefix operator)</entry>
<entry>!! 5</entry>
<entry>120</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>@</literal> </entry>
<entry>Absolute value</entry>
<entry>@ -5.0</entry>
<entry>5</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>&</literal> </entry>
<entry>Binary AND</entry>
<entry>91 & 15</entry>
<entry>11</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>|</literal> </entry>
<entry>Binary OR</entry>
<entry>32 | 3</entry>
<entry>35</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>#</literal> </entry>
<entry>Binary XOR</entry>
<entry>17 # 5</entry>
<entry>20</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>~</literal> </entry>
<entry>Binary NOT</entry>
<entry>~1</entry>
<entry>-2</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> << </entry>
<entry>Binary shift left</entry>
<entry>1 << 4</entry>
<entry>16</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> >> </entry>
<entry>Binary shift right</entry>
<entry>8 >> 2</entry>
<entry>2</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
The <quote>binary</quote> operators are also available for the bit
string types <type>BIT</type> and <type>BIT VARYING</type>.
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<table>
<title>Bit String Binary Operators</title>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tgroup cols="2">
<thead>
<row>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry>B'10001' & B'01101'</entry>
<entry>00001</entry>
</row>
<row>
<entry>B'10001' | B'01101'</entry>
<entry>11101</entry>
</row>
<row>
<entry>B'10001' # B'01101'</entry>
<entry>11110</entry>
</row>
<row>
<entry>~ B'10001'</entry>
<entry>01110</entry>
</row>
<row>
<entry>B'10001' << 3</entry>
<entry>01000</entry>
</row>
<row>
<entry>B'10001' >> 2</entry>
<entry>00100</entry>
</row>
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
Bit string arguments to <literal>&</literal>, <literal>|</literal>,
and <literal>#</literal> must be of equal length. When bit
shifting, the original length of the string is preserved, as shown
here.
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<table tocentry="1">
<title>Mathematical Functions</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>abs</function>(<replaceable>x</replaceable>)</entry>
<entry>(same as x)</entry>
<entry>absolute value</entry>
<entry><literal>abs(-17.4)</literal></entry>
<entry>17.4</entry>
</row>
<row>
<entry><function>cbrt</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>cube root</entry>
<entry><literal>cbrt(27.0)</literal></entry>
<entry>3</entry>
</row>
<row>
<entry><function>ceil</function>(<type>numeric</type>)</entry>
<entry><type>numeric</type></entry>
<entry>smallest integer not less than argument</entry>
<entry><literal>ceil(-42.8)</literal></entry>
<entry>-42</entry>
</row>
<row>
<entry><function>degrees</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>radians to degrees</entry>
<entry><literal>degrees(0.5)</literal></entry>
<entry>28.6478897565412</entry>
</row>
<row>
<entry><function>exp</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>exponential</entry>
<entry><literal>exp(1.0)</literal></entry>
<entry>2.71828182845905</entry>
</row>
<row>
<entry><function>floor</function>(<type>numeric</type>)</entry>
<entry><type>numeric</type></entry>
<entry>largest integer not greater than argument</entry>
<entry><literal>floor(-42.8)</literal></entry>
<entry>-43</entry>
</row>
<row>
<entry><function>ln</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>natural logarithm</entry>
<entry><literal>ln(2.0)</literal></entry>
<entry>0.693147180559945</entry>
</row>
<row>
<entry><function>log</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>base 10 logarithm</entry>
<entry><literal>log(100.0)</literal></entry>
<entry>2</entry>
</row>
<row>
<entry><function>log</function>(<parameter>b</parameter> <type>numeric</type>,
<parameter>x</parameter> <type>numeric</type>)</entry>
<entry><type>numeric</type></entry>
<entry>logarithm to base <parameter>b</parameter></entry>
<entry><literal>log(2.0, 64.0)</literal></entry>
<entry>6.0000000000</entry>
</row>
<row>
<entry><function>mod</function>(<parameter>y</parameter>,
<parameter>x</parameter>)</entry>
<entry>(same as argument types)</entry>
<entry>remainder of <parameter>y</parameter>/<parameter>x</parameter></entry>
<entry><literal>mod(9,4)</literal></entry>
<entry>1</entry>
</row>
<row>
<entry><function>pi</function>()</entry>
<entry><type>dp</type></entry>
<entry><quote>Pi</quote> constant</entry>
<entry><literal>pi()</literal></entry>
<entry>3.14159265358979</entry>
</row>
<row>
<entry><function>pow</function>(<parameter>e</parameter> <type>dp</type>,
<parameter>n</parameter> <type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>raise a number to exponent <parameter>e</parameter></entry>
<entry><literal>pow(9.0, 3.0)</literal></entry>
<entry>729</entry>
</row>
<row>
<entry><function>radians</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>degrees to radians</entry>
<entry><literal>radians(45.0)</literal></entry>
<entry>0.785398163397448</entry>
</row>
<row>
<entry><function>random</function>()</entry>
<entry><type>dp</type></entry>
<entry>value between 0.0 to 1.0</entry>
<entry><literal>random()</literal></entry>
<entry></entry>
</row>
<row>
<entry><function>round</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>round to nearest integer</entry>
<entry><literal>round(42.4)</literal></entry>
<entry>42</entry>
</row>
<row>
<entry><function>round</function>(<parameter>v</parameter> <type>numeric</type>, <parameter>s</parameter> <type>integer</type>)</entry>
<entry><type>numeric</type></entry>
<entry>round to <parameter>s</parameter> decimal places</entry>
<entry><literal>round(42.4382, 2)</literal></entry>
<entry>42.44</entry>
</row>
2000-12-14 23:30:56 +01:00
<!--
<row>
2001-09-09 19:21:59 +02:00
<entry><function>setseed</function>(<replaceable>new-seed</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>set seed for subsequent random() calls</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>setseed(0.54823)</literal></entry>
2000-12-14 23:30:56 +01:00
<entry></entry>
</row>
-->
2002-06-11 17:32:33 +02:00
<row>
<entry><function>sign</function>(<type>numeric</type>)</entry>
<entry><type>numeric</type></entry>
<entry>sign of the argument (-1, 0, +1)</entry>
<entry><literal>sign(-8.4)</literal></entry>
<entry>-1</entry>
</row>
2001-09-20 18:41:26 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>sqrt</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>square root</entry>
<entry><literal>sqrt(2.0)</literal></entry>
<entry>1.4142135623731</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>trunc</function>(<type>dp</type>)</entry>
<entry><type>dp</type></entry>
<entry>truncate toward zero</entry>
<entry><literal>trunc(42.8)</literal></entry>
<entry>42</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>trunc</function>(<type>numeric</type>,
<parameter>r</parameter>rameter> <type>integer</type>)</entry>
<entry><type>numeric</type></entry>
<entry>truncate to <parameter>s</parameter> decimal places</entry>
<entry><literal>trunc(42.4382, 2)</literal></entry>
<entry>42.43</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
In the table above, <literal>dp</literal> indicates <type>double precision</type>.
The functions <function>exp</function>, <function>ln</function>,
<function>log</function>, <function>pow</function>,
<function>round</function> (1 argument), <function>sqrt</function>,
and <function>trunc</function> (1 argument) are also available for
the type <type>numeric</type> in place of
<type>double precision</type>.
Functions returning a <type>numeric</type> result take
<type>numeric</type> input arguments, unless otherwise specified.
Many of these functions are implemented on top
of the host system's C library; accuracy and behavior in boundary cases
could therefore vary depending on the host system.
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<table>
<title>Trigonometric Functions</title>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tgroup cols="2">
<thead>
<row>
<entry>Function</entry>
<entry>Description</entry>
</row>
</thead>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry><function>acos</function>(<replaceable>x</replaceable>)</entry>
<entry>inverse cosine</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>asin</function>(<replaceable>x</replaceable>)</entry>
<entry>inverse sine</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>atan</function>(<replaceable>x</replaceable>)</entry>
<entry>inverse tangent</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>atan2</function>(<replaceable>x</replaceable>,
<replaceable>y</replaceable>)</entry>
<entry>inverse tangent of
<replaceable>a</replaceable>aceable>/<replaceable>x</replaceable></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>cos</function>(<replaceable>x</replaceable>)</entry>
<entry>cosine</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>cot</function>(<replaceable>x</replaceable>)</entry>
<entry>cotangent</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>sin</function>(<replaceable>x</replaceable>)</entry>
<entry>sine</entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>tan</function>(<replaceable>x</replaceable>)</entry>
<entry>tangent</entry>
</row>
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
All trigonometric functions have arguments and return values of
type <type>double precision</type>.
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
</sect1>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<sect1 id="functions-string">
<title>String Functions and Operators</title>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
This section describes functions and operators for examining and
manipulating string values. Strings in this context include values
of all the types <type>CHARACTER</type>, <type>CHARACTER
VARYING</type>, and <type>TEXT</type>. Unless otherwise noted, all
of the functions listed below work on all of these types, but be
wary of potential effects of the automatic padding when using the
<type>CHARACTER</type> type. Generally, the functions described
here also work on data of non-string types by converting that data
to a string representation first. Some functions also exist
natively for bit-string types.
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
<acronym>SQL</acronym> defines some string functions with a special syntax where
certain keywords rather than commas are used to separate the
arguments. Details are in <xref linkend="functions-string-sql">.
These functions are also implemented using the regular syntax for
function invocation. (See <xref linkend="functions-string-other">.)
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<table id="functions-string-sql">
<title><acronym>SQL</acronym> String Functions and Operators</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry> <parameter>string</parameter> <literal>||</literal>
<parameter>string</parameter> </entry>
<entry> <type>text</type> </entry>
<entry>
string concatenation
<indexterm>
<primary>character strings</primary>
<secondary>concatenation</secondary>
</indexterm>
</entry>
<entry><literal>'Postgre' || 'SQL'</literal></entry>
<entry><literal>PostgreSQL</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>bit_length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>number of bits in string</entry>
<entry><literal>bit_length('jose')</literal></entry>
<entry><literal>32</literal></entry>
</row>
2001-05-24 11:29:29 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>char_length</function>(<parameter>string</parameter>) or <function>character_length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>
number of characters in string
<indexterm>
<primary>character strings</primary>
<secondary>length</secondary>
</indexterm>
<indexterm>
<primary>length</primary>
<secondary>character strings</secondary>
<see>character strings, length</see>
</indexterm>
</entry>
<entry><literal>char_length('jose')</literal></entry>
<entry><literal>4</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-08-06 07:40:47 +02:00
<row>
<entry><function>convert</function>(<parameter>string</parameter>
using <parameter>conversion_name</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Change encoding using specified conversion name.
Conversions can be defined by <command>CREATE CONVERSION</command>.
Also there are some pre-defined conversion names.
See <xref linkend="conversion-names"> for available
conversion names. </entry>
<entry><literal>convert('PostgreSQL' using iso8859_1_to_utf8)</literal></entry>
<entry><literal>'PostgreSQL' in UNICODE(UTF-8) encoding</literal></entry>
</row>
2002-06-11 17:32:33 +02:00
<row>
<entry><function>lower</function>(<parameter>string</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Convert string to lower case.</entry>
<entry><literal>lower('TOM')</literal></entry>
<entry><literal>tom</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>octet_length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>number of bytes in string</entry>
<entry><literal>octet_length('jose')</literal></entry>
<entry><literal>4</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>overlay</function>(<parameter>string</parameter> placing <parameter>string</parameter> from <type>integer</type> <optional>for <type>integer</type></optional>)</entry>
<entry><type>text</type></entry>
<entry>
insert substring
<indexterm>
<primary>overlay</primary>
</indexterm>
</entry>
<entry><literal>overlay('Txxxxas' placing 'hom' from 2 for 4)</literal></entry>
<entry><literal>Thomas</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>location of specified substring</entry>
<entry><literal>position('om' in 'Thomas')</literal></entry>
<entry><literal>3</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>substring</function>(<parameter>string</parameter> <optional>from <type>integer</type></optional> <optional>for <type>integer</type></optional>)</entry>
<entry><type>text</type></entry>
<entry>
extract substring
<indexterm>
<primary>substring</primary>
</indexterm>
</entry>
<entry><literal>substring('Thomas' from 2 for 3)</literal></entry>
<entry><literal>hom</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>substring</function>(<parameter>string</parameter> <optional>from <replaceable>pattern</replaceable></optional> <optional>for <replaceable>escape</replaceable></optional>)</entry>
<entry><type>text</type></entry>
<entry>
extract regular expression
<indexterm>
<primary>substring</primary>
</indexterm>
</entry>
<entry><literal>substring('Thomas' from 'mas$' for <optional>escape '\\'</optional>)</literal></entry>
<entry><literal>mas</literal></entry>
</row>
1998-07-08 15:53:15 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>trim</function>(<optional>leading | trailing | both</optional>
<optional><parameter>characters</parameter></optional> from
<parameter>string</parameter>)
</entry>
<entry><type>text</type></entry>
<entry>
Removes the longest string containing only the
<parameter>characters</parameter> (a space by default) from the
beginning/end/both ends of the <parameter>string</parameter>.
</entry>
<entry><literal>trim(both 'x' from 'xTomxx')</literal></entry>
<entry><literal>Tom</literal></entry>
</row>
1998-07-08 15:53:15 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>upper</function>(<parameter>string</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Convert string to upper case.</entry>
<entry><literal>upper('tom')</literal></entry>
<entry><literal>TOM</literal></entry>
</row>
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-08-06 07:40:47 +02:00
<table id="conversion-names">
<title>Available conversion names</title>
<tgroup cols="3">
<thead>
<row>
<entry>conversion</entry>
<entry>source encoding</entry>
<entry>destination encoding</entry>
</row>
</thead>
<tbody>
<row>
<entry>ascii_to_utf8</entry>
<entry>SQL_ASCII</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>big5_to_euc_tw</entry>
<entry>BIG5</entry>
<entry>EUC_TW</entry>
</row>
<row>
<entry>big5_to_mic</entry>
<entry>BIG5</entry>
<entry>MULE_INTERNAL</entry>
</row>
<row>
<entry>big5_to_utf8</entry>
<entry>BIG5</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>euc_cn_to_utf8</entry>
<entry>EUC_CN</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>euc_jp_to_mic</entry>
<entry>EUC_JP</entry>
<entry>MULE_INTERNAL</entry>
</row>
<row>
<entry>euc_jp_to_sjis</entry>
<entry>EUC_JP</entry>
<entry>SJIS</entry>
</row>
<row>
<entry>euc_jp_to_utf8</entry>
<entry>EUC_JP</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>euc_kr_to_utf8</entry>
<entry>EUC_KR</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>euc_tw_to_big5</entry>
<entry>EUC_TW</entry>
<entry>BIG5</entry>
</row>
<row>
<entry>euc_tw_to_mic</entry>
<entry>EUC_TW</entry>
<entry>MULE_INTERNAL</entry>
</row>
<row>
<entry>euc_tw_to_utf8</entry>
<entry>EUC_TW</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>gb18030_to_utf8</entry>
<entry>GB18030</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>gbk_to_utf8</entry>
<entry>GBK</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_10_to_utf8</entry>
<entry>LATIN6</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_13_to_utf8</entry>
<entry>LATIN7</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_14_to_utf8</entry>
<entry>LATIN8</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_15_to_utf8</entry>
<entry>LATIN9</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_16_to_utf8</entry>
<entry>LATIN10</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_1_to_utf8</entry>
<entry>LATIN1</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_2_to_utf8</entry>
<entry>LATIN2</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_3_to_utf8</entry>
<entry>LATIN3</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_4_to_utf8</entry>
<entry>LATIN4</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_5_to_utf8</entry>
<entry>ISO_8859_5</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_6_to_utf8</entry>
<entry>ISO_8859_6</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_7_to_utf8</entry>
<entry>ISO_8859_7</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_8_to_utf8</entry>
<entry>ISO_8859_8</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>iso8859_9_to_utf8</entry>
<entry>LATIN5</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>johab_to_utf8</entry>
<entry>JOHAB</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>mic_to_big5</entry>
<entry>MULE_INTERNAL</entry>
<entry>BIG5</entry>
</row>
<row>
<entry>mic_to_euc_jp</entry>
<entry>MULE_INTERNAL</entry>
<entry>EUC_JP</entry>
</row>
<row>
<entry>mic_to_euc_tw</entry>
<entry>MULE_INTERNAL</entry>
<entry>EUC_TW</entry>
</row>
<row>
<entry>mic_to_sjis</entry>
<entry>MULE_INTERNAL</entry>
<entry>SJIS</entry>
</row>
<row>
<entry>sjis_to_euc_jp</entry>
<entry>SJIS</entry>
<entry>EUC_JP</entry>
</row>
<row>
<entry>sjis_to_mic</entry>
<entry>SJIS</entry>
<entry>MULE_INTERNAL</entry>
</row>
<row>
<entry>sjis_to_utf8</entry>
<entry>SJIS</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>tcvn_to_utf8</entry>
<entry>TCVN</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>uhc_to_utf8</entry>
<entry>UHC</entry>
<entry>UNICODE</entry>
</row>
<row>
<entry>utf8_to_ascii</entry>
<entry>UNICODE</entry>
<entry>SQL_ASCII</entry>
</row>
<row>
<entry>utf8_to_big5</entry>
<entry>UNICODE</entry>
<entry>BIG5</entry>
</row>
<row>
<entry>utf8_to_euc_cn</entry>
<entry>UNICODE</entry>
<entry>EUC_CN</entry>
</row>
<row>
<entry>utf8_to_euc_jp</entry>
<entry>UNICODE</entry>
<entry>EUC_JP</entry>
</row>
<row>
<entry>utf8_to_euc_kr</entry>
<entry>UNICODE</entry>
<entry>EUC_KR</entry>
</row>
<row>
<entry>utf8_to_euc_tw</entry>
<entry>UNICODE</entry>
<entry>EUC_TW</entry>
</row>
<row>
<entry>utf8_to_gb18030</entry>
<entry>UNICODE</entry>
<entry>GB18030</entry>
</row>
<row>
<entry>utf8_to_gbk</entry>
<entry>UNICODE</entry>
<entry>GBK</entry>
</row>
<row>
<entry>utf8_to_iso8859_1</entry>
<entry>UNICODE</entry>
<entry>LATIN1</entry>
</row>
<row>
<entry>utf8_to_iso8859_10</entry>
<entry>UNICODE</entry>
<entry>LATIN6</entry>
</row>
<row>
<entry>utf8_to_iso8859_13</entry>
<entry>UNICODE</entry>
<entry>LATIN7</entry>
</row>
<row>
<entry>utf8_to_iso8859_14</entry>
<entry>UNICODE</entry>
<entry>LATIN8</entry>
</row>
<row>
<entry>utf8_to_iso8859_15</entry>
<entry>UNICODE</entry>
<entry>LATIN9</entry>
</row>
<row>
<entry>utf8_to_iso8859_16</entry>
<entry>UNICODE</entry>
<entry>LATIN10</entry>
</row>
<row>
<entry>utf8_to_iso8859_2</entry>
<entry>UNICODE</entry>
<entry>LATIN2</entry>
</row>
<row>
<entry>utf8_to_iso8859_3</entry>
<entry>UNICODE</entry>
<entry>LATIN3</entry>
</row>
<row>
<entry>utf8_to_iso8859_4</entry>
<entry>UNICODE</entry>
<entry>LATIN4</entry>
</row>
<row>
<entry>utf8_to_iso8859_5</entry>
<entry>UNICODE</entry>
<entry>ISO_8859_5</entry>
</row>
<row>
<entry>utf8_to_iso8859_6</entry>
<entry>UNICODE</entry>
<entry>ISO_8859_6</entry>
</row>
<row>
<entry>utf8_to_iso8859_7</entry>
<entry>UNICODE</entry>
<entry>ISO_8859_7</entry>
</row>
<row>
<entry>utf8_to_iso8859_8</entry>
<entry>UNICODE</entry>
<entry>ISO_8859_8</entry>
</row>
<row>
<entry>utf8_to_iso8859_9</entry>
<entry>UNICODE</entry>
<entry>LATIN5</entry>
</row>
<row>
<entry>utf8_to_johab</entry>
<entry>UNICODE</entry>
<entry>JOHAB</entry>
</row>
<row>
<entry>utf8_to_sjis</entry>
<entry>UNICODE</entry>
<entry>SJIS</entry>
</row>
<row>
<entry>utf8_to_tcvn</entry>
<entry>UNICODE</entry>
<entry>TCVN</entry>
</row>
<row>
<entry>utf8_to_uhc</entry>
<entry>UNICODE</entry>
<entry>UHC</entry>
</row>
</tbody>
</tgroup>
</table>
2002-06-11 17:32:33 +02:00
<para>
Additional string manipulation functions are available and are
listed below. Some of them are used internally to implement the
<acronym>SQL</acronym>-standard string functions listed above.
</para>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<table id="functions-string-other">
<title>Other String Functions</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry><function>ascii</function>(<type>text</type>)</entry>
<entry>integer</entry>
<entry>Returns the <acronym>ASCII</acronym> code of the first character of the argument.</entry>
<entry><literal>ascii('x')</literal></entry>
<entry><literal>120</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>btrim</function>(<parameter>string</parameter> <type>text</type>, <parameter>trim</parameter> <type>text</type>)</entry>
<entry><type>text</type></entry>
<entry>
Remove (trim) the longest string consisting only of characters
in <parameter>trim</parameter> from the start and end of
<parameter>string</parameter>.
</entry>
<entry><literal>btrim('xyxtrimyyx','xy')</literal></entry>
<entry><literal>trim</literal></entry>
</row>
2001-08-15 09:10:12 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>chr</function>(<type>integer</type>)</entry>
<entry><type>text</type></entry>
<entry>Returns the character with the given <acronym>ASCII</acronym> code.</entry>
<entry><literal>chr(65)</literal></entry>
<entry><literal>A</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>convert</function>(<parameter>string</parameter>
<type>text</type>,
<optional><parameter>src_encoding</parameter> <type>name</type>,</optional>
<parameter>dest_encoding</parameter> <type>name</type>)
</entry>
<entry><type>text</type></entry>
<entry>
Converts string using <parameter>dest_encoding</parameter>.
The original encoding is specified by
<parameter>src_encoding</parameter>. If
<parameter>src_encoding</parameter> is omitted, database
encoding is assumed.
</entry>
<entry><literal>convert('text_in_unicode', 'UNICODE', 'LATIN1')</literal></entry>
<entry><literal>text_in_unicode</literal> represented in ISO 8859-1</entry>
</row>
2001-11-19 04:58:25 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>initcap</function>(<type>text</type>)</entry>
<entry><type>text</type></entry>
<entry>Converts first letter of each word (whitespace separated) to upper case.</entry>
<entry><literal>initcap('hi thomas')</literal></entry>
<entry><literal>Hi Thomas</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>
length of string
<indexterm>
<primary>character strings</primary>
<secondary>length</secondary>
</indexterm>
<indexterm>
<primary>length</primary>
<secondary>character strings</secondary>
<see>character strings, length</see>
</indexterm>
</entry>
<entry><literal>length('jose')</literal></entry>
<entry><literal>4</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>lpad</function>(<parameter>string</parameter> <type>text</type>,
<parameter>length</parameter> <type>integer</type>
<optional>, <parameter>fill</parameter> <type>text</type></optional>)
</entry>
<entry>text</entry>
<entry>
Fills up the <parameter>string</parameter> to length
<parameter>length</parameter> by prepending the characters
<parameter>fill</parameter> (a space by default). If the
<parameter>string</parameter> is already longer than
<parameter>length</parameter> then it is truncated (on the
right).
</entry>
<entry><literal>lpad('hi', 5, 'xy')</literal></entry>
<entry><literal>xyxhi</literal></entry>
</row>
2001-10-12 04:08:34 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>ltrim</function>(<parameter>string</parameter> <type>text</type>, <parameter>text</parameter> <type>text</type>)</entry>
<entry><type>text</type></entry>
<entry>
Removes the longest string containing only characters from
<parameter>trim</parameter> from the start of the string.
</entry>
<entry><literal>ltrim('zzzytrim','xyz')</literal></entry>
<entry><literal>trim</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>pg_client_encoding</function>()</entry>
<entry><type>name</type></entry>
<entry>
Returns current client encoding name.
</entry>
<entry><literal>pg_client_encoding()</literal></entry>
<entry><literal>SQL_ASCII</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-25 00:17:01 +02:00
<row>
<entry><function>quote_ident</function>(<parameter>string</parameter> text)</entry>
<entry><type>text</type></entry>
<entry>
Returns the given string suitably quoted to be used as an identifier
in an SQL query string.
Quotes are added only if necessary (i.e., if the string contains
non-identifier characters or would be case-folded).
Embedded quotes are properly doubled.
</entry>
<entry><literal>quote_ident('Foo')</literal></entry>
<entry><literal>"Foo"</literal></entry>
</row>
<row>
<entry><function>quote_literal</function>(<parameter>string</parameter> text)</entry>
<entry><type>text</type></entry>
<entry>
Returns the given string suitably quoted to be used as a literal
in an SQL query string.
Embedded quotes and backslashes are properly doubled.
</entry>
<entry><literal>quote_literal('O\'Reilly')</literal></entry>
<entry><literal>'O''Reilly'</literal></entry>
</row>
2002-06-11 17:32:33 +02:00
<row>
<entry><function>repeat</function>(<type>text</type>, <type>integer</type>)</entry>
<entry><type>text</type></entry>
<entry>Repeat text a number of times.</entry>
<entry><literal>repeat('Pg', 4)</literal></entry>
<entry><literal>PgPgPgPg</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>rpad</function>(<parameter>string</parameter> <type>text</type>,
<parameter>length</parameter> <type>integer</type>
<optional>, <parameter>fill</parameter> <type>text</type></optional>)
</entry>
<entry><type>text</type></entry>
<entry>
Fills up the <parameter>string</parameter> to length
<parameter>length</parameter> by appending the characters
<parameter>fill</parameter> (a space by default). If the
<parameter>string</parameter> is already longer than
<parameter>length</parameter> then it is truncated.
</entry>
<entry><literal>rpad('hi', 5, 'xy')</literal></entry>
<entry><literal>hixyx</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>rtrim</function>(<parameter>string</parameter>
text, <parameter>trim</parameter> text)</entry>
<entry><type>text</type></entry>
<entry>
Removes the longest string containing only characters from
<parameter>trim</parameter> from the end of the string.
</entry>
<entry><literal>rtrim('trimxxxx','x')</literal></entry>
<entry><literal>trim</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>strpos</function>(<parameter>string</parameter>, <parameter>substring</parameter>)</entry>
<entry><type>text</type></entry>
<entry>
Locates specified substring. (same as
<literal>position(<parameter>substring</parameter> in
<parameter>string</parameter>)</literal>, but note the reversed
argument order)
</entry>
<entry><literal>strpos('high','ig')</literal></entry>
<entry><literal>2</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>substr</function>(<parameter>string</parameter>, <parameter>from</parameter> <optional>, <parameter>count</parameter></optional>)</entry>
<entry><type>text</type></entry>
<entry>
Extracts specified substring. (same as
<literal>substring(<parameter>string</parameter> from <parameter>from</parameter> for <parameter>count</parameter>)</literal>)
</entry>
<entry><literal>substr('alphabet', 3, 2)</literal></entry>
<entry><literal>ph</literal></entry>
</row>
2001-07-12 00:14:03 +02:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>to_ascii</function>(<type>text</type>
<optional>ptional>, <parameter>encoding</parameter></optional>)</entry>
<entry><type>text</type></entry>
<entry>Converts text from multibyte encoding to <acronym>ASCII</acronym>.</entry>
<entry><literal>to_ascii('Karel')</literal></entry>
<entry><literal>Karel</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>translate</function>(<parameter>string</parameter>
<type>text</type>,
<parameter>from</parameter> <type>text</type>,
<parameter>to</parameter> <type>text</type>)
</entry>
<entry><type>text</type></entry>
<entry>
Any character in <parameter>string</parameter> that matches a
character in the <parameter>from</parameter> set is replaced by
the corresponding character in the <parameter>to</parameter>
set.
</entry>
<entry><literal>translate('12345', '14', 'ax')</literal></entry>
<entry><literal>a23x5</literal></entry>
</row>
<row>
<entry>
<function>encode</function>(<parameter>data</parameter> <type>bytea</type>,
<parameter>type</parameter> <type>text</type>)
</entry>
<entry><type>text</type></entry>
<entry>
Encodes binary data to <acronym>ASCII</acronym>-only representation. Supported
types are: 'base64', 'hex', 'escape'.
</entry>
<entry><literal>encode('123\\000\\001', 'base64')</literal></entry>
<entry><literal>MTIzAAE=</literal></entry>
</row>
<row>
<entry>
<function>decode</function>(<parameter>string</parameter> <type>text</type>,
<parameter>type</parameter> <type>text</type>)
</entry>
<entry><type>bytea</type></entry>
<entry>
Decodes binary data from <parameter>string</parameter> previously
encoded with encode(). Parameter type is same as in encode().
</entry>
<entry><literal>decode('MTIzAAE=', 'base64')</literal></entry>
<entry><literal>123\000\001</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<para>
The <function>to_ascii</function> function supports conversion from
LATIN1, LATIN2, WIN1250 (CP1250) only.
</para>
</sect1>
2000-12-14 23:30:56 +01:00
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<sect1 id="functions-binarystring">
<title>Binary String Functions and Operators</title>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<para>
This section describes functions and operators for examining and
manipulating binary string values. Strings in this context include
values of the type <type>BYTEA</type>.
</para>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<para>
<acronym>SQL</acronym> defines some string functions with a
special syntax where
certain keywords rather than commas are used to separate the
arguments. Details are in
<xref linkend="functions-binarystring-sql">.
Some functions are also implemented using the regular syntax for
function invocation.
(See <xref linkend="functions-binarystring-other">.)
</para>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<table id="functions-binarystring-sql">
<title><acronym>SQL</acronym> Binary String Functions and Operators</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry> <parameter>string</parameter> <literal>||</literal>
<parameter>string</parameter> </entry>
<entry> <type>bytea</type> </entry>
<entry>
string concatenation
<indexterm>
<primary>binary strings</primary>
<secondary>concatenation</secondary>
</indexterm>
</entry>
<entry><literal>'\\\\Postgre'::bytea || '\\047SQL\\000'::bytea</literal></entry>
<entry><literal>\\Postgre'SQL\000</literal></entry>
</row>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>octet_length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>number of bytes in binary string</entry>
<entry><literal>octet_length('jo\\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
</row>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>location of specified substring</entry>
<entry><literal>position('\\000om'::bytea in 'Th\\000omas'::bytea)</literal></entry>
<entry><literal>3</literal></entry>
</row>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry><function>substring</function>(<parameter>string</parameter> <optional>from <type>integer</type></optional> <optional>for <type>integer</type></optional>)</entry>
<entry><type>bytea</type></entry>
<entry>
extract substring
<indexterm>
<primary>substring</primary>
</indexterm>
</entry>
<entry><literal>substring('Th\\000omas'::bytea from 2 for 3)</literal></entry>
<entry><literal>h\000o</literal></entry>
</row>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry>
<function>trim</function>(<optional>both</optional>
<parameter>characters</parameter> from
<parameter>string</parameter>)
</entry>
<entry><type>bytea</type></entry>
<entry>
Removes the longest string containing only the
<parameter>characters</parameter> from the
beginning/end/both ends of the <parameter>string</parameter>.
</entry>
<entry><literal>trim('\\000'::bytea from '\\000Tom\\000'::bytea)</literal></entry>
<entry><literal>Tom</literal></entry>
</row>
</tbody>
</tgroup>
</table>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<para>
Additional binary string manipulation functions are available and are
listed below. Some of them are used internally to implement the
<acronym>SQL</acronym>-standard string functions listed above.
</para>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<table id="functions-binarystring-other">
<title>Other Binary String Functions</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
2001-11-20 16:42:44 +01:00
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry><function>btrim</function>(<parameter>string</parameter>
<type>bytea</type> <parameter>trim</parameter> <type>bytea</type>)</entry>
<entry><type>bytea</type></entry>
<entry>
Remove (trim) the longest string consisting only of characters
in <parameter>trim</parameter> from the start and end of
<parameter>string</parameter>.
2001-11-20 16:42:44 +01:00
</entry>
<entry><literal>btrim('\\000trim\\000'::bytea,'\\000'::bytea)</literal></entry>
<entry><literal>trim</literal></entry>
</row>
<row>
<entry><function>length</function>(<parameter>string</parameter>)</entry>
<entry><type>integer</type></entry>
<entry>
length of binary string
<indexterm>
<primary>binary strings</primary>
<secondary>length</secondary>
</indexterm>
<indexterm>
<primary>length</primary>
<secondary>binary strings</secondary>
<see>binary strings, length</see>
</indexterm>
</entry>
2002-06-11 17:32:33 +02:00
<entry><literal>length('jo\\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry>
2001-11-20 16:42:44 +01:00
</row>
<row>
<entry>
<function>encode</function>(<parameter>string</parameter> <type>bytea</type>,
<parameter>type</parameter> <type>text</type>)
</entry>
<entry><type>text</type></entry>
<entry>
Encodes binary string to <acronym>ASCII</acronym>-only representation. Supported
types are: 'base64', 'hex', 'escape'.
</entry>
<entry><literal>encode('123\\000456'::bytea, 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
<row>
<entry>
<function>decode</function>(<parameter>string</parameter> <type>text</type>,
<parameter>type</parameter> <type>text</type>)
</entry>
<entry><type>bytea</type></entry>
<entry>
Decodes binary string from <parameter>string</parameter> previously
encoded with encode(). Parameter type is same as in encode().
</entry>
<entry><literal>decode('123\\000456', 'escape')</literal></entry>
<entry><literal>123\000456</literal></entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
2000-12-14 23:30:56 +01:00
<sect1 id="functions-matching">
<title>Pattern Matching</title>
2002-06-11 17:32:33 +02:00
<para>
There are two separate approaches to pattern matching provided by
<productname>PostgreSQL</productname>: the traditional
<acronym>SQL</acronym>
<function>LIKE</function> operator and the more recent
<acronym>SQL99</acronym>
<function>SIMILAR TO</function> operator implementing
<acronym>POSIX</acronym>-style regular expressions.
Additionally, a pattern matching function,
<function>SUBSTRING</function>, is available, as defined in
<acronym>SQL99</acronym>.
</para>
<tip>
<para>
If you have pattern matching needs that go beyond this,
consider writing a user-defined function in Perl or Tcl.
</para>
</tip>
1998-07-08 15:53:15 +02:00
1999-05-12 09:32:47 +02:00
<para>
2002-06-11 17:32:33 +02:00
Both <function>LIKE</function> and <function>SIMILAR TO</function>
are SQL-standard operators which are also available in alternate
2002-06-11 18:00:17 +02:00
forms as <productname>PostgreSQL</productname> operators; look at
2002-06-11 17:32:33 +02:00
<literal>~</literal> and <literal>~~</literal> for examples.
1999-05-12 09:32:47 +02:00
</para>
2000-12-14 23:30:56 +01:00
<sect2 id="functions-like">
2002-06-11 17:32:33 +02:00
<title><function>LIKE</function></title>
2000-12-14 23:30:56 +01:00
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>like</primary>
</indexterm>
2002-06-11 17:32:33 +02:00
<synopsis>
<replaceable>string</replaceable> LIKE <replaceable>pattern</replaceable> <optional>ESCAPE <replaceable>escape-character</replaceable></optional>
<replaceable>string</replaceable> NOT LIKE <replaceable>pattern</replaceable> <optional>ESCAPE <replaceable>escape-character</replaceable></optional>
</synopsis>
1999-05-12 09:32:47 +02:00
2002-06-11 17:32:33 +02:00
<para>
Every <replaceable>pattern</replaceable> defines a set of strings.
The <function>LIKE</function> expression returns true if the
<replaceable>string</replaceable> is contained in the set of
strings represented by <replaceable>pattern</replaceable>. (As
expected, the <function>NOT LIKE</function> expression returns
false if <function>LIKE</function> returns true, and vice versa.
An equivalent expression is
<literal>NOT (<replaceable>string</replaceable> LIKE
<replaceable>pattern</replaceable>)</literal>.)
</para>
2000-12-14 23:30:56 +01:00
<para>
2002-06-11 17:32:33 +02:00
If <replaceable>pattern</replaceable> does not contain percent
signs or underscore, then the pattern only represents the string
itself; in that case <function>LIKE</function> acts like the
equals operator. An underscore (<literal>_</literal>) in
<replaceable>pattern</replaceable> stands for (matches) any single
character; a percent sign (<literal>%</literal>) matches any string
of zero or more characters.
</para>
<informalexample>
<para>
Some examples:
<programlisting>
2000-12-14 23:30:56 +01:00
'abc' LIKE 'abc' <lineannotation>true</lineannotation>
'abc' LIKE 'a%' <lineannotation>true</lineannotation>
'abc' LIKE '_b_' <lineannotation>true</lineannotation>
'abc' LIKE 'c' <lineannotation>false</lineannotation>
2002-06-11 17:32:33 +02:00
</programlisting>
</para>
</informalexample>
1999-05-12 09:32:47 +02:00
1999-06-14 09:36:12 +02:00
<para>
2000-12-14 23:30:56 +01:00
<function>LIKE</function> pattern matches always cover the entire
2000-12-16 20:33:23 +01:00
string. To match a pattern anywhere within a string, the
2000-12-14 23:30:56 +01:00
pattern must therefore start and end with a percent sign.
1999-06-14 09:36:12 +02:00
</para>
2000-03-20 05:20:52 +01:00
<para>
2000-12-16 20:33:23 +01:00
To match a literal underscore or percent sign without matching
other characters, the respective character in
<replaceable>pattern</replaceable> must be
preceded by the escape character. The default escape
2000-12-14 23:30:56 +01:00
character is the backslash but a different one may be selected by
2000-12-16 20:33:23 +01:00
using the <literal>ESCAPE</literal> clause. To match the escape
character itself, write two escape characters.
</para>
<para>
Note that the backslash already has a special meaning in string
literals, so to write a pattern constant that contains a backslash
2001-11-18 22:17:10 +01:00
you must write two backslashes in the query. Thus, writing a pattern
that actually matches a literal backslash means writing four backslashes
in the query. You can avoid this by selecting a different escape
2001-11-28 21:49:10 +01:00
character with <literal>ESCAPE</literal>; then backslash is not special
2002-06-11 17:32:33 +02:00
to <function>LIKE</function> anymore. (But it is still special to the string
2001-11-18 22:17:10 +01:00
literal parser, so you still need two of them.)
</para>
<para>
It's also possible to select no escape character by writing
2002-06-11 17:32:33 +02:00
<literal>ESCAPE ''</literal>. This effectively disables the
escape mechanism and
turns off the special meaning of underscore and percent signs in
2001-11-18 22:17:10 +01:00
the pattern.
2000-03-20 05:20:52 +01:00
</para>
2000-04-07 15:30:58 +02:00
<para>
2000-12-14 23:30:56 +01:00
The keyword <token>ILIKE</token> can be used instead of
<token>LIKE</token> to make the match case insensitive according
2001-02-18 18:17:17 +01:00
to the active locale. This is not in the <acronym>SQL</acronym> standard but is a
2001-11-21 06:53:41 +01:00
<productname>PostgreSQL</productname> extension.
2000-04-08 04:16:08 +02:00
</para>
2000-04-07 15:30:58 +02:00
2000-12-14 23:30:56 +01:00
<para>
The operator <literal>~~</literal> is equivalent to
2000-12-16 20:33:23 +01:00
<function>LIKE</function>, and <literal>~~*</literal> corresponds to
<function>ILIKE</function>. There are also
<literal>!~~</literal> and <literal>!~~*</literal> operators that
2000-12-14 23:30:56 +01:00
represent <function>NOT LIKE</function> and <function>NOT
2001-11-18 22:17:10 +01:00
ILIKE</function>. All of these operators are
2001-11-21 06:53:41 +01:00
<productname>PostgreSQL</productname>-specific.
2000-12-14 23:30:56 +01:00
</para>
</sect2>
1998-07-08 15:53:15 +02:00
2000-12-14 23:30:56 +01:00
<sect2 id="functions-regexp">
2002-06-11 17:32:33 +02:00
<title><function>SIMILAR TO</function> and <acronym>POSIX</acronym>
Regular Expressions</title>
1998-07-08 15:53:15 +02:00
2001-05-13 00:51:36 +02:00
<indexterm zone="functions-regexp">
<primary>regular expressions</primary>
<seealso>pattern matching</seealso>
</indexterm>
2000-12-14 23:30:56 +01:00
<table>
<title>Regular Expression Match Operators</title>
<tgroup cols="3">
<thead>
<row>
<entry>Operator</entry>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
2002-06-11 17:32:33 +02:00
<tbody>
<row>
<entry> <literal>~</literal> </entry>
<entry>Matches regular expression, case sensitive</entry>
<entry><literal>'thomas' ~ '.*thomas.*'</literal></entry>
</row>
2000-12-14 23:30:56 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>~*</literal> </entry>
<entry>Matches regular expression, case insensitive</entry>
<entry><literal>'thomas' ~* '.*Thomas.*'</literal></entry>
</row>
2000-12-16 20:33:23 +01:00
2002-06-11 17:32:33 +02:00
<row>
<entry> <literal>!~</literal> </entry>
<entry>Does not match regular expression, case sensitive</entry>
<entry><literal>'thomas' !~ '.*Thomas.*'</literal></entry>
</row>
<row>
<entry> <literal>!~*</literal> </entry>
<entry>Does not match regular expression, case insensitive</entry>
<entry><literal>'thomas' !~* '.*vadim.*'</literal></entry>
</row>
<row>
<entry> <literal>SIMILAR TO</literal> </entry>
<entry>Matches regular expression, case sensitive</entry>
<entry><literal>'thomas' SIMILAR TO '.*thomas.*'</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
<acronym>POSIX</acronym> regular expressions provide a more
powerful means for
pattern matching than the <function>LIKE</function> function.
Many Unix tools such as <command>egrep</command>,
<command>sed</command>, or <command>awk</command> use a pattern
matching language that is similar to the one described here.
</para>
<para>
A regular expression is a character sequence that is an
abbreviated definition of a set of strings (a <firstterm>regular
set</firstterm>). A string is said to match a regular expression
if it is a member of the regular set described by the regular
expression. As with <function>LIKE</function>, pattern characters
match string characters exactly unless they are special characters
in the regular expression language --- but regular expressions use
different special characters than <function>LIKE</function> does.
Unlike <function>LIKE</function> patterns, a
regular expression is allowed to match anywhere within a string, unless
the regular expression is explicitly anchored to the beginning or
end of the string.
</para>
2000-12-16 20:33:23 +01:00
2002-06-11 17:32:33 +02:00
<informalexample>
<para>
Some examples:
<programlisting>
'abc' SIMILAR TO 'abc' <lineannotation>true</lineannotation>
'abc' SIMILAR TO '^a' <lineannotation>true</lineannotation>
'abc' SIMILAR TO '(b|d)' <lineannotation>true</lineannotation>
'abc' SIMILAR TO '^(b|c)' <lineannotation>false</lineannotation>
</programlisting>
</para>
</informalexample>
2000-12-14 23:30:56 +01:00
<!-- derived from the re_format.7 man page -->
1999-06-14 09:36:12 +02:00
<para>
2002-06-11 17:32:33 +02:00
Regular expressions (<quote>RE</quote>s), as defined in
<acronym>POSIX</acronym>
2000-12-14 23:30:56 +01:00
1003.2, come in two forms: modern REs (roughly those of
<command>egrep</command>; 1003.2 calls these
<quote>extended</quote> REs) and obsolete REs (roughly those of
2000-12-16 20:33:23 +01:00
<command>ed</command>; 1003.2 <quote>basic</quote> REs).
2001-11-21 06:53:41 +01:00
<productname>PostgreSQL</productname> implements the modern form.
1999-06-14 09:36:12 +02:00
</para>
1998-07-08 15:53:15 +02:00
1999-06-14 09:36:12 +02:00
<para>
2000-12-14 23:30:56 +01:00
A (modern) RE is one or more non-empty
<firstterm>branches</firstterm>, separated by
<literal>|</literal>. It matches anything that matches one of the
branches.
1999-06-14 09:36:12 +02:00
</para>
1998-07-08 15:53:15 +02:00
1999-05-12 09:32:47 +02:00
<para>
2000-12-14 23:30:56 +01:00
A branch is one or more <firstterm>pieces</firstterm>,
concatenated. It matches a match for the first, followed by a
match for the second, etc.
1999-05-12 09:32:47 +02:00
</para>
2000-12-14 23:30:56 +01:00
2000-08-29 06:41:48 +02:00
<para>
2000-12-14 23:30:56 +01:00
A piece is an <firstterm>atom</firstterm> possibly followed by a
single <literal>*</literal>, <literal>+</literal>,
<literal>?</literal>, or <firstterm>bound</firstterm>. An atom
followed by <literal>*</literal> matches a sequence of 0 or more
matches of the atom. An atom followed by <literal>+</literal>
matches a sequence of 1 or more matches of the atom. An atom
followed by <literal>?</literal> matches a sequence of 0 or 1
matches of the atom.
2000-08-29 06:41:48 +02:00
</para>
1998-07-08 15:53:15 +02:00
2000-12-14 23:30:56 +01:00
<para>
A <firstterm>bound</firstterm> is <literal>{</literal> followed by
an unsigned decimal integer, possibly followed by
<literal>,</literal> possibly followed by another unsigned decimal
integer, always followed by <literal>}</literal>. The integers
must lie between 0 and <symbol>RE_DUP_MAX</symbol> (255)
inclusive, and if there are two of them, the first may not exceed
the second. An atom followed by a bound containing one integer
<replaceable>i</replaceable> and no comma matches a sequence of
exactly <replaceable>i</replaceable> matches of the atom. An atom
followed by a bound containing one integer
<replaceable>i</replaceable> and a comma matches a sequence of
<replaceable>i</replaceable> or more matches of the atom. An atom
followed by a bound containing two integers
<replaceable>i</replaceable> and <replaceable>j</replaceable>
matches a sequence of <replaceable>i</replaceable> through
<replaceable>j</replaceable> (inclusive) matches of the atom.
</para>
<note>
<para>
A repetition operator (<literal>?</literal>,
<literal>*</literal>, <literal>+</literal>, or bounds) cannot
follow another repetition operator. A repetition operator cannot
begin an expression or subexpression or follow
<literal>^</literal> or <literal>|</literal>.
</para>
</note>
1998-07-08 15:53:15 +02:00
1999-05-12 09:32:47 +02:00
<para>
2000-12-14 23:30:56 +01:00
An <firstterm>atom</firstterm> is a regular expression enclosed in
<literal>()</literal> (matching a match for the regular
expression), an empty set of <literal>()</literal> (matching the
null string), a <firstterm>bracket expression</firstterm> (see
below), <literal>.</literal> (matching any single character),
2001-03-25 20:14:31 +02:00
<literal>^</literal> (matching the null string at the beginning of the
input string), <literal>$</literal> (matching the null string at the end
of the input string), a <literal>\</literal> followed by one of the
2000-12-14 23:30:56 +01:00
characters <literal>^.[$()|*+?{\</literal> (matching that
character taken as an ordinary character), a <literal>\</literal>
followed by any other character (matching that character taken as
an ordinary character, as if the <literal>\</literal> had not been
present), or a single character with no other significance
(matching that character). A <literal>{</literal> followed by a
character other than a digit is an ordinary character, not the
beginning of a bound. It is illegal to end an RE with
<literal>\</literal>.
1999-05-12 09:32:47 +02:00
</para>
1998-07-08 15:53:15 +02:00
2000-12-16 20:33:23 +01:00
<para>
Note that the backslash (<literal>\</literal>) already has a special
meaning in string
literals, so to write a pattern constant that contains a backslash
you must write two backslashes in the query.
</para>
1999-06-14 09:36:12 +02:00
<para>
2000-12-14 23:30:56 +01:00
A <firstterm>bracket expression</firstterm> is a list of
characters enclosed in <literal>[]</literal>. It normally matches
any single character from the list (but see below). If the list
begins with <literal>^</literal>, it matches any single character
(but see below) not from the rest of the list. If two characters
in the list are separated by <literal>-</literal>, this is
shorthand for the full range of characters between those two
(inclusive) in the collating sequence,
e.g. <literal>[0-9]</literal> in <acronym>ASCII</acronym> matches
any decimal digit. It is illegal for two ranges to share an
endpoint, e.g. <literal>a-c-e</literal>. Ranges are very
collating-sequence-dependent, and portable programs should avoid
relying on them.
1999-06-14 09:36:12 +02:00
</para>
1998-07-08 15:53:15 +02:00
1999-06-14 09:36:12 +02:00
<para>
2000-12-14 23:30:56 +01:00
To include a literal <literal>]</literal> in the list, make it the
first character (following a possible <literal>^</literal>). To
include a literal <literal>-</literal>, make it the first or last
character, or the second endpoint of a range. To use a literal
<literal>-</literal> as the first endpoint of a range, enclose it
in <literal>[.</literal> and <literal>.]</literal> to make it a
collating element (see below). With the exception of these and
some combinations using <literal>[</literal> (see next
paragraphs), all other special characters, including
<literal>\</literal>, lose their special significance within a
bracket expression.
</para>
<para>
Within a bracket expression, a collating element (a character, a
2001-09-09 19:21:59 +02:00
multiple-character sequence that collates as if it were a single
2000-12-14 23:30:56 +01:00
character, or a collating-sequence name for either) enclosed in
<literal>[.</literal> and <literal>.]</literal> stands for the
sequence of characters of that collating element. The sequence is
a single element of the bracket expression's list. A bracket
2001-09-09 19:21:59 +02:00
expression containing a multiple-character collating element can thus
2000-12-14 23:30:56 +01:00
match more than one character, e.g. if the collating sequence
includes a <literal>ch</literal> collating element, then the RE
<literal>[[.ch.]]*c</literal> matches the first five characters of
<literal>chchcc</literal>.
</para>
<para>
Within a bracket expression, a collating element enclosed in
<literal>[=</literal> and <literal>=]</literal> is an equivalence
class, standing for the sequences of characters of all collating
elements equivalent to that one, including itself. (If there are
no other equivalent collating elements, the treatment is as if the
enclosing delimiters were <literal>[.</literal> and
<literal>.]</literal>.) For example, if <literal>o</literal> and
<literal>^</literal> are the members of an equivalence class, then
<literal>[[=o=]]</literal>, <literal>[[=^=]]</literal>, and
<literal>[o^]</literal> are all synonymous. An equivalence class
may not be an endpoint of a range.
</para>
<para>
Within a bracket expression, the name of a character class
enclosed in <literal>[:</literal> and <literal>:]</literal> stands
for the list of all characters belonging to that class. Standard
character class names are: <literal>alnum</literal>,
<literal>alpha</literal>, <literal>blank</literal>,
<literal>cntrl</literal>, <literal>digit</literal>,
<literal>graph</literal>, <literal>lower</literal>,
<literal>print</literal>, <literal>punct</literal>,
<literal>space</literal>, <literal>upper</literal>,
<literal>xdigit</literal>. These stand for the character classes
defined in
<citerefentry><refentrytitle>ctype</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
A locale may provide others. A character class may not be used as
an endpoint of a range.
</para>
<para>
There are two special cases of bracket expressions: the bracket
expressions <literal>[[:<:]]</literal> and
<literal>[[:>:]]</literal> match the null string at the beginning
and end of a word respectively. A word is defined as a sequence
of word characters which is neither preceded nor followed by word
characters. A word character is an alnum character (as defined by
<citerefentry><refentrytitle>ctype</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
or an underscore. This is an extension, compatible with but not
2001-09-09 19:21:59 +02:00
specified by <acronym>POSIX</acronym> 1003.2, and should be used with caution in
2000-12-14 23:30:56 +01:00
software intended to be portable to other systems.
</para>
<para>
In the event that an RE could match more than one substring of a
given string, the RE matches the one starting earliest in the
string. If the RE could match more than one substring starting at
that point, it matches the longest. Subexpressions also match the
longest possible substrings, subject to the constraint that the
whole match be as long as possible, with subexpressions starting
earlier in the RE taking priority over ones starting later. Note
that higher-level subexpressions thus take priority over their
lower-level component subexpressions.
</para>
<para>
Match lengths are measured in characters, not collating
elements. A null string is considered longer than no match at
all. For example, <literal>bb*</literal> matches the three middle
characters of <literal>abbbc</literal>,
<literal>(wee|week)(knights|nights)</literal> matches all ten
characters of <literal>weeknights</literal>, when
<literal>(.*).*</literal> is matched against
<literal>abc</literal> the parenthesized subexpression matches all
three characters, and when <literal>(a*)*</literal> is matched
against <literal>bc</literal> both the whole RE and the
parenthesized subexpression match the null string.
</para>
<para>
If case-independent matching is specified, the effect is much as
if all case distinctions had vanished from the alphabet. When an
alphabetic that exists in multiple cases appears as an ordinary
character outside a bracket expression, it is effectively
transformed into a bracket expression containing both cases,
e.g. <literal>x</literal> becomes <literal>[xX]</literal>. When
it appears inside a bracket expression, all case counterparts of
it are added to the bracket expression, so that (e.g.)
<literal>[x]</literal> becomes <literal>[xX]</literal> and
<literal>[^x]</literal> becomes <literal>[^xX]</literal>.
</para>
<para>
There is no particular limit on the length of REs, except insofar
as memory is limited. Memory usage is approximately linear in RE
size, and largely insensitive to RE complexity, except for bounded
repetitions. Bounded repetitions are implemented by macro
expansion, which is costly in time and space if counts are large
or bounded repetitions are nested. An RE like, say,
<literal>((((a{1,100}){1,100}){1,100}){1,100}){1,100}</literal>
will (eventually) run almost any existing machine out of swap
2001-04-20 17:52:33 +02:00
space.
<footnote>
<para>
This was written in 1994, mind you. The
numbers have probably changed, but the problem
persists.
</para>
</footnote>
1999-06-14 09:36:12 +02:00
</para>
2000-12-14 23:30:56 +01:00
<!-- end re_format.7 man page -->
</sect2>
1998-07-08 15:53:15 +02:00
2000-12-14 23:30:56 +01:00
</sect1>
<sect1 id="functions-formatting">
2001-10-09 20:46:00 +02:00
<title>Data Type Formatting Functions</title>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
2001-05-13 00:51:36 +02:00
<indexterm zone="functions-formatting">
<primary>formatting</primary>
</indexterm>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<note>
<title>Author</title>
<para>
2000-12-14 23:30:56 +01:00
Written by Karel Zak (<email>zakkr@zf.jcu.cz</email>) on 2000-01-24
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</para>
</note>
2000-12-14 23:30:56 +01:00
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<para>
2001-11-21 06:53:41 +01:00
The <productname>PostgreSQL</productname> formatting functions
2000-12-14 23:30:56 +01:00
provide a powerful set of tools for converting various data types
(date/time, integer, floating point, numeric) to formatted strings
2001-02-18 18:17:17 +01:00
and for converting from formatted strings to specific data types.
2001-03-15 02:07:51 +01:00
These functions all follow a common calling convention: the first
2000-12-14 23:30:56 +01:00
argument is the value to be formatted and the second argument is a
2001-03-15 02:07:51 +01:00
template that defines the output or input format.
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</para>
<table tocentry="1">
<title>Formatting Functions</title>
<tgroup cols="4">
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_char</function>(<type>timestamp</type>, <type>text</type>)</entry>
<entry><type>text</type></entry>
<entry>convert time stamp to string</entry>
<entry><literal>to_char(timestamp 'now','HH12:MI:SS')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2001-09-06 05:22:42 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_char</function>(<type>interval</type>, <type>text</type>)</entry>
<entry><type>text</type></entry>
2001-09-06 05:22:42 +02:00
<entry>convert interval to string</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(interval '15h 2m 12s','HH24:MI:SS')</literal></entry>
2001-09-06 05:22:42 +02:00
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_char</function>(<type>int</type>, <type>text</type>)</entry>
<entry><type>text</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert int4/int8 to string</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(125, '999')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>to_char</function>(<type>double precision</type>,
<type>text</type>)</entry>
2001-09-09 19:21:59 +02:00
<entry><type>text</type></entry>
2001-01-20 21:59:29 +01:00
<entry>convert real/double precision to string</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(125.8, '999D9')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_char</function>(<type>numeric</type>, <type>text</type>)</entry>
<entry><type>text</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert numeric to string</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(numeric '-125.8', '999D99S')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_date</function>(<type>text</type>, <type>text</type>)</entry>
<entry><type>date</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert string to date</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_date('05 Dec 2000', 'DD Mon YYYY')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_timestamp</function>(<type>text</type>, <type>text</type>)</entry>
<entry><type>timestamp</type></entry>
<entry>convert string to time stamp</entry>
<entry><literal>to_timestamp('05 Dec 2000', 'DD Mon YYYY')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>to_number</function>(<type>text</type>, <type>text</type>)</entry>
<entry><type>numeric</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert string to numeric</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>to_number('12,454.8-', '99G999D9S')</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
</tbody>
</tgroup>
</table>
2001-03-15 02:07:51 +01:00
<para>
In an output template string, there are certain patterns that are
recognized and replaced with appropriately-formatted data from the value
to be formatted. Any text that is not a template pattern is simply
2001-11-28 21:49:10 +01:00
copied verbatim. Similarly, in an input template string, template patterns
2001-03-15 02:07:51 +01:00
identify the parts of the input data string to be looked at and the
values to be found there.
</para>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<table tocentry="1">
2001-03-15 02:07:51 +01:00
<title>Template patterns for date/time conversions</title>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<tgroup cols="2">
<thead>
<row>
2001-03-15 02:07:51 +01:00
<entry>Pattern</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>HH</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>hour of day (01-12)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>HH12</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>hour of day (01-12)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2000-05-02 22:02:03 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>HH24</literal></entry>
2000-05-02 22:02:03 +02:00
<entry>hour of day (00-23)</entry>
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MI</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>minute (00-59)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>SS</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>second (00-59)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2001-09-06 05:22:42 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MS</literal></entry>
2001-09-06 05:22:42 +02:00
<entry>millisecond (000-999)</entry>
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>US</literal></entry>
2001-09-06 05:22:42 +02:00
<entry>microsecond (000000-999999)</entry>
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>SSSS</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>seconds past midnight (0-86399)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2000-04-07 21:17:51 +02:00
<row>
2002-06-11 17:32:33 +02:00
<entry><literal>AM</literal> or <literal>A.M.</literal> or
<literal>li</literal>literal> or <literal>P.M.</literal></entry>
2000-04-07 21:17:51 +02:00
<entry>meridian indicator (upper case)</entry>
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><literal>am</literal> or <literal>a.m.</literal> or
<literal>li</literal>literal> or <literal>p.m.</literal></entry>
2000-04-07 21:17:51 +02:00
<entry>meridian indicator (lower case)</entry>
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Y,YYY</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>year (4 and more digits) with comma</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>YYYY</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>year (4 and more digits)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>YYY</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>last 3 digits of year</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>YY</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>last 2 digits of year</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Y</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>last digit of year</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2000-04-07 21:17:51 +02:00
<row>
2002-06-11 17:32:33 +02:00
<entry><literal>BC</literal> or <literal>B.C.</literal> or
<literal>li</literal>literal> or <literal>A.D.</literal></entry>
2001-09-09 19:21:59 +02:00
<entry>era indicator (upper case)</entry>
2000-04-07 21:17:51 +02:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><literal>bc</literal> or <literal>b.c.</literal> or
<literal>li</literal>literal> or <literal>a.d.</literal></entry>
2001-09-09 19:21:59 +02:00
<entry>era indicator (lower case)</entry>
2000-04-07 21:17:51 +02:00
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MONTH</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full upper case month name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Month</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full mixed case month name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>month</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full lower case month name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MON</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>abbreviated upper case month name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Mon</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>abbreviated mixed case month name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>mon</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>abbreviated lower case month name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MM</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>month number (01-12)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>DAY</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full upper case day name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Day</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full mixed case day name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>day</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>full lower case day name (blank-padded to 9 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>DY</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>abbreviated upper case day name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Dy</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>abbreviated mixed case day name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>dy</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>abbreviated lower case day name (3 chars)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>DDD</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>day of year (001-366)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>DD</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>day of month (01-31)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>D</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>day of week (1-7; SUN=1)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>W</literal></entry>
2000-07-03 18:01:33 +02:00
<entry>week of month (1-5) where first week start on the first day of the month</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>WW</literal></entry>
2000-07-03 18:01:33 +02:00
<entry>week number of year (1-53) where first week start on the first day of the year</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2000-08-29 06:41:48 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>IW</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>ISO week number of year (The first Thursday of the new year is in week 1.)</entry>
2000-08-29 06:41:48 +02:00
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>CC</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>century (2 digits)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>J</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>Julian Day (days since January 1, 4712 BC)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>Q</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>quarter</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>RM</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>month in Roman Numerals (I-XII; I=January) - upper case</entry>
2000-04-07 21:17:51 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>rm</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>month in Roman Numerals (I-XII; I=January) - lower case</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
2000-07-03 18:01:33 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>TZ</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>timezone name - upper case</entry>
2000-07-03 18:01:33 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>tz</literal></entry>
2001-03-15 02:07:51 +01:00
<entry>timezone name - lower case</entry>
2000-07-03 18:01:33 +02:00
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</tbody>
</tgroup>
</table>
<para>
2001-03-15 02:07:51 +01:00
Certain modifiers may be applied to any template pattern to alter its
behavior. For example, <quote><literal>FMMonth</literal></quote>
is the <quote><literal>Month</literal></quote> pattern with the
<quote><literal>FM</literal></quote> prefix.
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</para>
<table tocentry="1">
2001-03-15 02:07:51 +01:00
<title>Template pattern modifiers for date/time conversions</title>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<tgroup cols="3">
<thead>
<row>
2001-03-15 02:07:51 +01:00
<entry>Modifier</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
2001-03-15 02:07:51 +01:00
<entry><literal>FM</literal> prefix</entry>
<entry>fill mode (suppress padding blanks and zeroes)</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>FMMonth</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-03-15 02:07:51 +01:00
<entry><literal>TH</literal> suffix</entry>
<entry>add upper-case ordinal number suffix</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>DDTH</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-03-15 02:07:51 +01:00
<entry><literal>th</literal> suffix</entry>
<entry>add lower-case ordinal number suffix</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>DDth</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-03-15 02:07:51 +01:00
<entry><literal>FX</literal> prefix</entry>
2001-09-09 19:21:59 +02:00
<entry>Fixed format global option (see below)</entry>
<entry><literal>FX Month DD Day</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-03-15 02:07:51 +01:00
<entry><literal>SP</literal> suffix</entry>
2000-03-27 19:14:43 +02:00
<entry>spell mode (not yet implemented)</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>DDSP</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
</tbody>
</tgroup>
</table>
<para>
2000-03-27 19:14:43 +02:00
Usage notes:
<itemizedlist>
2001-03-15 02:07:51 +01:00
<listitem>
<para>
<literal>FM</literal> suppresses leading zeroes or trailing blanks
that would otherwise be added to make the output of a pattern be
fixed-width.
</para>
</listitem>
2000-03-27 19:14:43 +02:00
<listitem>
<para>
<function>to_timestamp</function> and <function>to_date</function>
2001-03-15 02:07:51 +01:00
skip multiple blank spaces in the input string if the <literal>FX</literal> option
2000-07-03 18:01:33 +02:00
is not used. <literal>FX</literal> must be specified as the first item
in the template; for example
<literal>to_timestamp('2000 JUN','YYYY MON')</literal> is right, but
2001-03-15 02:07:51 +01:00
<literal>to_timestamp('2000 JUN','FXYYYY MON')</literal> returns an error,
because <function>to_timestamp</function> expects one blank space only.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
2000-12-14 23:30:56 +01:00
If a backslash (<quote><literal>\</literal></quote>) is desired
in a string constant, a double backslash
(<quote><literal>\\</literal></quote>) must be entered; for
example <literal>'\\HH\\MI\\SS'</literal>. This is true for
2001-11-21 06:53:41 +01:00
any string constant in <productname>PostgreSQL</productname>.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
2000-12-14 23:30:56 +01:00
Ordinary text is allowed in <function>to_char</function>
2001-03-15 02:07:51 +01:00
templates and will be output literally. You can put a substring
in double quotes to force it to be interpreted as literal text
even if it contains pattern keywords. For example, in
<literal>'"Hello Year: "YYYY'</literal>, the <literal>YYYY</literal>
will be replaced by year data, but the single <literal>Y</literal>
will not be.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
2001-05-13 00:51:36 +02:00
If you want to have a double quote in the output you must
precede it with a backslash, for example <literal>'\\"YYYY
Month\\"'</literal>. <!-- "" font-lock sanity :-) -->
2000-03-27 19:14:43 +02:00
</para>
</listitem>
2000-11-25 06:00:33 +01:00
<listitem>
<para>
2001-09-09 19:21:59 +02:00
<literal>YYYY</literal> conversion from string to <type>timestamp</type> or
<type>date</type> is restricted if you use a year with more than 4 digits. You must
2000-11-25 14:20:05 +01:00
use some non-digit character or template after <literal>YYYY</literal>,
2000-12-14 23:30:56 +01:00
otherwise the year is always interpreted as 4 digits. For example
2000-11-25 14:20:05 +01:00
(with year 20000):
<literal>to_date('200001131', 'YYYYMMDD')</literal> will be
2000-12-14 23:30:56 +01:00
interpreted as a 4-digit year; better is to use a non-digit
2000-11-25 14:20:05 +01:00
separator after the year, like
<literal>to_date('20000-1131', 'YYYY-MMDD')</literal> or
<literal>to_date('20000Nov31', 'YYYYMonDD')</literal>.
2000-11-25 06:00:33 +01:00
</para>
</listitem>
2001-09-06 05:22:42 +02:00
<listitem>
<para>
2001-09-09 19:21:59 +02:00
Millisecond <literal>MS</literal> and microsecond <literal>US</literal>
2001-11-28 21:49:10 +01:00
values in a conversion from string to time stamp are used as part of the
seconds after the decimal point. For example
2001-09-06 05:22:42 +02:00
<literal>to_timestamp('12:3', 'SS:MS')</literal> is not 3 milliseconds,
2001-11-28 21:49:10 +01:00
but 300, because the conversion counts it as 12 + 0.3.
2002-06-11 17:32:33 +02:00
This means for the format <literal>SS:MS</literal>, the input values
<literal>12:3</literal>, <literal>12:30</literal>, and <literal>12:300</literal> specify the
2001-11-28 21:49:10 +01:00
same number of milliseconds. To get three milliseconds, one must use
2002-06-11 17:32:33 +02:00
<literal>12:003</literal>, which the conversion counts as
2001-11-28 21:49:10 +01:00
12 + 0.003 = 12.003 seconds.
</para>
<para>
Here is a more
2001-09-06 05:22:42 +02:00
complex example:
<literal>to_timestamp('15:12:02.020.001230','HH:MI:SS.MS.US')</literal>
2001-11-28 21:49:10 +01:00
is 15 hours, 12 minutes, and 2 seconds + 20 milliseconds +
1230 microseconds = 2.021230 seconds.
2001-09-06 05:22:42 +02:00
</para>
</listitem>
2000-03-27 19:14:43 +02:00
</itemizedlist>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</para>
2000-03-27 19:14:43 +02:00
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<table tocentry="1">
2001-03-15 02:07:51 +01:00
<title>Template patterns for numeric conversions</title>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<tgroup cols="2">
<thead>
<row>
2001-03-15 02:07:51 +01:00
<entry>Pattern</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>9</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>value with the specified number of digits</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>0</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>value with leading zeros</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>.</literal> (period)</entry>
2000-03-27 19:14:43 +02:00
<entry>decimal point</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>,</literal> (comma)</entry>
2000-03-27 19:14:43 +02:00
<entry>group (thousand) separator</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>PR</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>negative value in angle brackets</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>S</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>negative value with minus sign (uses locale)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>L</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>currency symbol (uses locale)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>D</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>decimal point (uses locale)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>G</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>group separator (uses locale)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>MI</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>minus sign in specified position (if number < 0)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>PL</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>plus sign in specified position (if number > 0)</entry>
2000-02-08 16:57:01 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>SG</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>plus/minus sign in specified position</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>RN</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>roman numeral (input between 1 and 3999)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>TH</literal> or <literal>th</literal></entry>
2000-03-27 19:14:43 +02:00
<entry>convert to ordinal number</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>V</literal></entry>
2000-12-14 23:30:56 +01:00
<entry>shift <replaceable>n</replaceable> digits (see
2000-03-27 19:14:43 +02:00
notes)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>EEEE</literal></entry>
2001-11-28 21:49:10 +01:00
<entry>scientific notation (not implemented yet)</entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
</tbody>
</tgroup>
</table>
<para>
2000-03-27 19:14:43 +02:00
Usage notes:
<itemizedlist>
<listitem>
<para>
2002-06-11 17:32:33 +02:00
A sign formatted using <literal>SG</literal>, <literal>PL</literal>, or
<literal>MI</literal> is not an anchor in
2000-03-27 19:14:43 +02:00
the number; for example,
2002-06-11 17:32:33 +02:00
<literal>to_char(-12, 'S9999')</literal> produces <literal>' -12'</literal>,
but <literal>to_char(-12, 'MI9999')</literal> produces <literal>'- 12'</literal>.
2000-03-27 19:14:43 +02:00
The Oracle implementation does not allow the use of
<literal>MI</literal> ahead of <literal>9</literal>, but rather
2001-02-18 18:17:17 +01:00
requires that <literal>9</literal> precede
2000-03-27 19:14:43 +02:00
<literal>MI</literal>.
</para>
</listitem>
<listitem>
<para>
2001-03-15 02:07:51 +01:00
<literal>9</literal> specifies a value with the same number of
digits as there are <literal>9</literal>s. If a digit is
not available use blank space.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
2001-03-15 02:07:51 +01:00
<literal>TH</literal> does not convert values less than zero
and does not convert decimal numbers.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
2001-03-15 02:07:51 +01:00
<literal>PL</literal>, <literal>SG</literal>, and
2001-11-21 06:53:41 +01:00
<literal>TH</literal> are <productname>PostgreSQL</productname>
2001-03-15 02:07:51 +01:00
extensions.
2000-03-27 19:14:43 +02:00
</para>
</listitem>
<listitem>
<para>
<literal>V</literal> effectively
multiplies the input values by
<literal>10^<replaceable>n</replaceable></literal>, where
<replaceable>n</replaceable> is the number of digits following
<literal>V</literal>.
<function>to_char</function> does not support the use of
2000-12-14 23:30:56 +01:00
<literal>V</literal> combined with a decimal point.
(E.g., <literal>99.9V99</literal> is not allowed.)
2000-03-27 19:14:43 +02:00
</para>
</listitem>
</itemizedlist>
2000-02-08 16:57:01 +01:00
</para>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<table tocentry="1">
2000-03-27 19:14:43 +02:00
<title><function>to_char</function> Examples</title>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<tgroup cols="2">
<thead>
<row>
<entry>Input</entry>
<entry>Output</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(now(),'Day, DD HH12:MI:SS')</literal></entry>
2001-03-15 02:07:51 +01:00
<entry><literal>'Tuesday , 06 05:39:18'</literal></entry>
2000-03-27 19:14:43 +02:00
</row>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(now(),'FMDay, FMDD HH12:MI:SS')</literal></entry>
2001-03-15 02:07:51 +01:00
<entry><literal>'Tuesday, 6 05:39:18'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-0.1,'99.99')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' -.10'</literal></entry>
2000-02-08 16:57:01 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-0.1,'FM9.99')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'-.1'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(0.1,'0.9')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 0.1'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(12,'9990999.9')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 0012.0'</literal></entry>
2000-02-08 16:57:01 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(12,'FM9990999.9')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'0012'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'-485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'9 9 9')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 4 8 5'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(1485,'9,999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 1,485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(1485,'9G999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 1 485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(148.5,'999.999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 148.500'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(148.5,'999D999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 148,500'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(3148.5,'9G999D999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 3 148,500'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'999S')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'485-'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'999MI')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'485-'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'999MI')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'PL999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'+485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'SG999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'+485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'SG999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'-485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'9SG99')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'4-85'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(-485,'999PR')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'<485>'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'L999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'DM 485</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'RN')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' CDLXXXV'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485,'FMRN')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'CDLXXXV'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(5.2,'FMRN')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>V</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(482,'999th')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 482nd'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485, '"Good number:"999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>'Good number: 485'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(485.8,'"Pre:"999" Post:" .999')</literal></entry>
2001-04-20 17:52:33 +02:00
<entry><literal>'Pre: 485 Post: .800'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(12,'99V999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 12000'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(12.4,'99V999')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 12400'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><literal>to_char(12.45, '99V9')</literal></entry>
2000-03-27 19:14:43 +02:00
<entry><literal>' 125'</literal></entry>
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</row>
</tbody>
</tgroup>
</table>
2002-01-30 22:55:33 +01:00
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
</sect1>
2000-12-14 23:30:56 +01:00
<sect1 id="functions-datetime">
2001-09-28 10:15:35 +02:00
<title>Date/Time Functions and Operators</title>
1998-07-08 15:53:15 +02:00
1999-05-12 09:32:47 +02:00
<para>
2001-02-18 18:17:17 +01:00
<xref linkend="functions-datetime-table"> shows the available
2001-09-28 10:15:35 +02:00
functions for date/time value processing.
<xref linkend="operators-datetime-table"> illustrates the
behaviors of the basic arithmetic
operators (<literal>+</literal>, <literal>*</literal>, etc.).
For formatting functions, refer to <xref
2002-06-11 17:32:33 +02:00
linkend="functions-formatting">. You should be familiar with the
2001-02-18 18:17:17 +01:00
background information on date/time data types (see <xref
2002-06-11 17:32:33 +02:00
linkend="datatype-datetime">).
1999-05-12 09:32:47 +02:00
</para>
1998-07-08 15:53:15 +02:00
2001-09-28 10:15:35 +02:00
<para>
The date/time operators described below behave similarly for types
involving time zones as well as those without.
<table id="operators-datetime-table">
<title>Date/Time Operators</title>
2001-10-09 20:46:00 +02:00
<tgroup cols="3">
2001-09-28 10:15:35 +02:00
<thead>
<row>
<entry>Name</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
<tbody>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>+</literal> </entry>
2001-09-28 10:15:35 +02:00
<entry><type>timestamp</type> '2001-09-28 01:00' + <type>interval</type> '23 hours'</entry>
<entry><type>timestamp</type> '2001-09-29 00:00'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>+</literal> </entry>
2001-09-28 10:15:35 +02:00
<entry><type>date</type> '2001-09-28' + <type>interval</type> '1 hour'</entry>
<entry><type>timestamp</type> '2001-09-28 01:00'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>+</literal> </entry>
2001-09-28 10:15:35 +02:00
<entry><type>time</type> '01:00' + <type>interval</type> '3 hours'</entry>
<entry><type>time</type> '04:00'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>-</literal> </entry>
2001-09-28 10:15:35 +02:00
<entry><type>timestamp</type> '2001-09-28 23:00' - <type>interval</type> '23 hours'</entry>
<entry><type>timestamp</type> '2001-09-28'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>-</literal> </entry>
2002-01-25 03:39:28 +01:00
<entry><type>date</type> '2001-09-28' - <type>interval</type> '1 hour'</entry>
2001-09-28 10:15:35 +02:00
<entry><type>timestamp</type> '2001-09-27 23:00'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>-</literal> </entry>
2002-01-25 03:39:28 +01:00
<entry><type>time</type> '05:00' - <type>interval</type> '2 hours'</entry>
2001-09-28 10:15:35 +02:00
<entry><type>time</type> '03:00'</entry>
</row>
<row>
2001-09-28 22:48:17 +02:00
<entry> <literal>-</literal> </entry>
2001-09-28 10:15:35 +02:00
<entry><type>interval</type> '2 hours' - <type>time</type> '05:00'</entry>
<entry><type>time</type> '03:00:00'</entry>
</row>
<row>
<entry> <literal>*</literal> </entry>
<entry><type>interval</type> '1 hour' * <type>int</type> '3'</entry>
<entry><type>interval</type> '03:00'</entry>
</row>
<row>
<entry> <literal>/</literal> </entry>
<entry><type>interval</type> '1 hour' / <type>int</type> '3'</entry>
<entry><type>interval</type> '00:20'</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
The date/time functions are summarized below, with additional
details in subsequent sections.
2001-02-18 18:17:17 +01:00
<table id="functions-datetime-table">
2000-12-14 23:30:56 +01:00
<title>Date/Time Functions</title>
2001-10-09 20:46:00 +02:00
<tgroup cols="5">
2000-12-14 23:30:56 +01:00
<thead>
<row>
2001-02-18 18:17:17 +01:00
<entry>Name</entry>
<entry>Return Type</entry>
2000-12-14 23:30:56 +01:00
<entry>Description</entry>
<entry>Example</entry>
2001-02-18 18:17:17 +01:00
<entry>Result</entry>
2000-12-14 23:30:56 +01:00
</row>
</thead>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>age</function>(<type>timestamp</type>)</entry>
<entry><type>interval</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Subtract from today</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>age(timestamp '1957-06-13')</literal></entry>
<entry><literal>43 years 8 mons 3 days</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>age</function>(<type>timestamp</type>, <type>timestamp</type>)</entry>
<entry><type>interval</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Subtract arguments</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>age('2001-04-10', timestamp '1957-06-13')</literal></entry>
<entry><literal>43 years 9 mons 27 days</literal></entry>
2001-02-18 18:17:17 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>current_date</function></entry>
<entry><type>date</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Today's date; see <link linkend="functions-datetime-current">below</link>
2001-02-18 18:17:17 +01:00
</entry>
<entry></entry>
<entry></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
<row>
2002-06-15 05:00:09 +02:00
<entry><function>current_time</function></entry>
<entry><type>time with time zone</type></entry>
<entry>Time of day; see <link linkend="functions-datetime-current">below</link>
</entry>
<entry></entry>
<entry></entry>
2001-02-18 18:17:17 +01:00
</row>
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>current_timestamp</function></entry>
2002-06-15 05:00:09 +02:00
<entry><type>timestamp with time zone</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Date and time; see <link linkend="functions-datetime-current">below</link>
2001-02-18 18:17:17 +01:00
</entry>
<entry></entry>
<entry></entry>
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>date_part</function>(<type>text</type>, <type>timestamp</type>)</entry>
<entry><type>double precision</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Get subfield (equivalent to
2001-02-18 18:17:17 +01:00
<function>extract</function>); see also <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-datepart">below</link>
2001-02-18 18:17:17 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>date_part('hour', timestamp '2001-02-16 20:38:40')</literal></entry>
<entry><literal>20</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>date_part</function>(<type>text</type>, <type>interval</type>)</entry>
<entry><type>double precision</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Get subfield (equivalent to
2001-02-18 18:17:17 +01:00
<function>extract</function>); see also <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-datepart">below</link>
2001-02-18 18:17:17 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>date_part('month', interval '2 years 3 months')</literal></entry>
<entry><literal>3</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>date_trunc</function>(<type>text</type>, <type>timestamp</type>)</entry>
<entry><type>timestamp</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Truncate to specified precision; see also <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-trunc">below</link>
2001-02-18 18:17:17 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>date_trunc('hour', timestamp '2001-02-16 20:38:40')</literal></entry>
<entry><literal>2001-02-16 20:00:00+00</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry><function>extract</function>(<parameter>field</parameter> from
<type>timestamp</type>)</entry>
2001-09-09 19:21:59 +02:00
<entry><type>double precision</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Get subfield; see also <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-extract">below</link>
2001-02-18 18:17:17 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>extract(hour from timestamp '2001-02-16 20:38:40')</literal></entry>
<entry><literal>20</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
<row>
2002-06-11 17:32:33 +02:00
<entry><function>extract</function>(<parameter>field</parameter> from
<type>interval</type>)</entry>
2001-09-09 19:21:59 +02:00
<entry><type>double precision</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Get subfield; see also <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-extract">below</link>
2001-02-18 18:17:17 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>extract(month from interval '2 years 3 months')</literal></entry>
<entry><literal>3</literal></entry>
2001-02-18 18:17:17 +01:00
</row>
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>isfinite</function>(<type>timestamp</type>)</entry>
<entry><type>boolean</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Test for finite time stamp (neither invalid nor infinity)</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>isfinite(timestamp '2001-02-16 21:28:30')</literal></entry>
<entry><literal>true</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>isfinite</function>(<type>interval</type>)</entry>
<entry><type>boolean</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Test for finite interval</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>isfinite(interval '4 hours')</literal></entry>
<entry><literal>true</literal></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2002-06-15 05:00:09 +02:00
<row>
<entry><function>localtime</function></entry>
<entry><type>time</type></entry>
<entry>Time of day; see <link linkend="functions-datetime-current">below</link>
</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><function>localtimestamp</function></entry>
<entry><type>timestamp</type></entry>
<entry>Date and time; see <link linkend="functions-datetime-current">below</link>
</entry>
<entry></entry>
<entry></entry>
</row>
2000-12-14 23:30:56 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>now</function>()</entry>
<entry><type>timestamp</type></entry>
2001-04-20 17:52:33 +02:00
<entry>Current date and time (equivalent to
2001-12-27 22:36:57 +01:00
<function>current_timestamp</function>); see <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-current">below</link>
2001-02-18 18:17:17 +01:00
</entry>
<entry></entry>
<entry></entry>
2000-12-14 23:30:56 +01:00
</row>
2001-02-18 18:17:17 +01:00
2001-02-22 00:15:24 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>timeofday()</function></entry>
<entry><type>text</type></entry>
2001-12-23 21:22:49 +01:00
<entry>Current date and time; see <link
2002-06-11 17:32:33 +02:00
linkend="functions-datetime-current">below</link>
2001-02-22 00:15:24 +01:00
</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>timeofday()</literal></entry>
<entry><literal>Wed Feb 21 17:01:13.000126 2001 EST</literal></entry>
2001-02-22 00:15:24 +01:00
</row>
2000-12-14 23:30:56 +01:00
</tbody>
</tgroup>
</table>
2001-09-28 10:15:35 +02:00
</para>
2001-02-18 18:17:17 +01:00
<sect2 id="functions-datetime-extract">
<title><function>EXTRACT</function>, <function>date_part</function></title>
<synopsis>
EXTRACT (<replaceable>field</replaceable> FROM <replaceable>source</replaceable>)
</synopsis>
<para>
The <function>extract</function> function retrieves sub-fields
from date/time values, such as year or hour.
<replaceable>source</replaceable> is a value expression that
evaluates to type <type>timestamp</type> or <type>interval</type>.
(Expressions of type <type>date</type> or <type>time</type> will
be cast to <type>timestamp</type> and can therefore be used as
2001-04-20 17:52:33 +02:00
well.) <replaceable>field</replaceable> is an identifier or
string that selects what field to extract from the source value.
2001-02-18 18:17:17 +01:00
The <function>extract</function> function returns values of type
<type>double precision</type>.
The following are valid values:
<!-- alphabetical -->
<variablelist>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>century</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The year field divided by 100
</para>
<informalexample>
<screen>
SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>20</computeroutput>
</screen>
</informalexample>
<para>
2001-04-20 17:52:33 +02:00
Note that the result for the century field is simply the year field
divided by 100, and not the conventional definition which puts most
years in the 1900's in the twentieth century.
2001-02-18 18:17:17 +01:00
</para>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>day</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The day (of the month) field (1 - 31)
</para>
<informalexample>
<screen>
SELECT EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>16</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>decade</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The year field divided by 10
</para>
<informalexample>
<screen>
SELECT EXTRACT(DECADE FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>200</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>dow</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The day of the week (0 - 6; Sunday is 0) (for
<type>timestamp</type> values only)
</para>
<informalexample>
<screen>
SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>5</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>doy</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The day of the year (1 - 365/366) (for <type>timestamp</type> values only)
</para>
<informalexample>
<screen>
SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>47</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>epoch</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
For <type>date</type> and <type>timestamp</type> values, the
2001-09-28 10:15:35 +02:00
number of seconds since 1970-01-01 00:00:00-00 (Result may be
2001-02-18 18:17:17 +01:00
negative.); for <type>interval</type> values, the total number
of seconds in the interval
</para>
<informalexample>
<screen>
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>982352320</computeroutput>
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>hour</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The hour field (0 - 23)
</para>
<informalexample>
<screen>
SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>20</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>microseconds</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The seconds field, including fractional parts, multiplied by 1
000 000. Note that this includes full seconds.
</para>
<informalexample>
<screen>
SELECT EXTRACT(MICROSECONDS FROM TIME '17:12:28.5');
<lineannotation>Result: </lineannotation><computeroutput>28500000</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>millennium</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The year field divided by 1000
</para>
<informalexample>
<screen>
SELECT EXTRACT(MILLENNIUM FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>2</computeroutput>
</screen>
</informalexample>
<para>
2001-04-20 17:52:33 +02:00
Note that the result for the millennium field is simply the year field
divided by 1000, and not the conventional definition which puts
years in the 1900's in the second millennium.
2001-02-18 18:17:17 +01:00
</para>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>milliseconds</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The seconds field, including fractional parts, multiplied by
1000. Note that this includes full seconds.
</para>
<informalexample>
<screen>
SELECT EXTRACT(MILLISECONDS FROM TIME '17:12:28.5');
<lineannotation>Result: </lineannotation><computeroutput>28500</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>minute</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The minutes field (0 - 59)
</para>
<informalexample>
<screen>
SELECT EXTRACT(MINUTE FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>38</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>month</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
For <type>timestamp</type> values, the number of the month
within the year (1 - 12) ; for <type>interval</type> values
the number of months, modulo 12 (0 - 11)
</para>
<informalexample>
<screen>
SELECT EXTRACT(MONTH FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>2</computeroutput>
SELECT EXTRACT(MONTH FROM INTERVAL '2 years 3 months');
<lineannotation>Result: </lineannotation><computeroutput>3</computeroutput>
SELECT EXTRACT(MONTH FROM INTERVAL '2 years 13 months');
<lineannotation>Result: </lineannotation><computeroutput>1</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>quarter</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The quarter of the year (1 - 4) that the day is in (for
<type>timestamp</type> values only)
</para>
<informalexample>
<screen>
SELECT EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>1</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>second</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The seconds field, including fractional parts (0 -
59<footnote><simpara>60 if leap seconds are
implemented by the operating system</simpara></footnote>)
</para>
<informalexample>
<screen>
SELECT EXTRACT(SECOND FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>40</computeroutput>
SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
<lineannotation>Result: </lineannotation><computeroutput>28.5</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
2001-10-10 02:02:42 +02:00
<!--
<varlistentry>
<term><literal>timezone</literal></term>
<listitem>
<para>
The time zone offset. XXX But in what units?
</para>
</listitem>
</varlistentry>
-->
<varlistentry>
<term><literal>timezone_hour</literal></term>
<listitem>
<para>
The hour component of the time zone offset.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>timezone_minute</literal></term>
<listitem>
<para>
The minute component of the time zone offset.
</para>
</listitem>
</varlistentry>
2001-02-18 18:17:17 +01:00
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>week</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
From a <type>timestamp</type> value, calculate the number of
the week of the year that the day is in. By definition
(<acronym>ISO</acronym> 8601), the first week of a year
contains January 4 of that year. (The <acronym>ISO</acronym>
week starts on Monday.) In other words, the first Thursday of
a year is in week 1 of that year.
</para>
<informalexample>
<screen>
SELECT EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>7</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
2001-09-09 19:21:59 +02:00
<term><literal>year</literal></term>
2001-02-18 18:17:17 +01:00
<listitem>
<para>
The year field
</para>
<informalexample>
<screen>
SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>2001</computeroutput>
</screen>
</informalexample>
</listitem>
</varlistentry>
</variablelist>
2000-12-14 23:30:56 +01:00
</para>
<para>
2001-02-18 18:17:17 +01:00
The <function>extract</function> function is primarily intended
for computational processing. For formatting date/time values for
display, see <xref linkend="functions-formatting">.
2000-12-14 23:30:56 +01:00
</para>
2001-02-18 18:17:17 +01:00
<anchor id="functions-datetime-datepart">
<para>
2001-04-20 17:52:33 +02:00
The <function>date_part</function> function is modeled on the traditional
<productname>Ingres</productname> equivalent to the
2001-02-18 18:17:17 +01:00
<acronym>SQL</acronym>-function <function>extract</function>:
<synopsis>
date_part('<replaceable>field</replaceable>', <replaceable>source</replaceable>)
</synopsis>
Note that here the <replaceable>field</replaceable> value needs to
be a string. The valid field values for
<function>date_part</function> are the same as for
<function>extract</function>.
</para>
<informalexample>
<screen>
SELECT date_part('day', TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>16</computeroutput>
2001-09-10 04:46:18 +02:00
SELECT date_part('hour', INTERVAL '4 hours 3 minutes');
2001-02-18 18:17:17 +01:00
<lineannotation>Result: </lineannotation><computeroutput>4</computeroutput>
</screen>
</informalexample>
</sect2>
<sect2 id="functions-datetime-trunc">
<title><function>date_trunc</function></title>
<para>
The function <function>date_trunc</function> is conceptually
similar to the <function>trunc</function> function for numbers.
</para>
<para>
<synopsis>
date_trunc('<replaceable>field</replaceable>', <replaceable>source</replaceable>)
</synopsis>
<replaceable>source</replaceable> is a value expression of type
<type>timestamp</type> (values of type <type>date</type> and
<type>time</type> are cast automatically).
<replaceable>field</replaceable> selects to which precision to
truncate the time stamp value. The return value is of type
<type>timestamp</type> with all fields that are less than the
selected one set to zero (or one, for day and month).
</para>
<para>
Valid values for <replaceable>field</replaceable> are:
<simplelist>
<member>microseconds</member>
<member>milliseconds</member>
<member>second</member>
<member>minute</member>
<member>hour</member>
<member>day</member>
<member>month</member>
<member>year</member>
<member>decade</member>
<member>century</member>
<member>millennium</member>
</simplelist>
</para>
<informalexample>
<para>
<screen>
SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 20:00:00+00</computeroutput>
SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>Result: </lineannotation><computeroutput>2001-01-01 00:00:00+00</computeroutput>
</screen>
</para>
</informalexample>
</sect2>
<sect2 id="functions-datetime-current">
<title>Current Date/Time</title>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>date</primary>
<secondary>current</secondary>
</indexterm>
<indexterm>
<primary>time</primary>
<secondary>current</secondary>
</indexterm>
2001-02-18 18:17:17 +01:00
<para>
2001-02-22 00:15:24 +01:00
The following functions are available to obtain the current date and/or
time:
2002-06-15 05:00:09 +02:00
<synopsis>
2001-02-18 18:17:17 +01:00
CURRENT_DATE
2001-12-23 21:22:49 +01:00
CURRENT_TIME
2001-02-18 18:17:17 +01:00
CURRENT_TIMESTAMP
2002-06-11 17:32:33 +02:00
CURRENT_TIME ( <replaceable>precision</replaceable> )
CURRENT_TIMESTAMP ( <replaceable>precision</replaceable> )
2002-06-15 05:00:09 +02:00
LOCALTIME
LOCALTIMESTAMP
LOCALTIME ( <replaceable>precision</replaceable> )
LOCALTIMESTAMP ( <replaceable>precision</replaceable> )
</synopsis>
<function>CURRENT_TIME</function>,
<function>CURRENT_TIMESTAMP</function>,
<function>LOCALTIME</function>, and
<function>LOCALTIMESTAMP</function>
can optionally be given
a precision parameter, which causes the result to be rounded
to that many fractional digits. Without a precision parameter,
the result is given to the full available precision.
2001-12-23 21:22:49 +01:00
</para>
2002-06-15 05:00:09 +02:00
<note>
<para>
Prior to <productname>PostgreSQL</productname> 7.2, the precision
parameters were unimplemented, and the result was always given
in integer seconds.
</para>
</note>
2001-12-23 21:22:49 +01:00
2002-06-15 05:00:09 +02:00
<informalexample>
<screen>
2001-02-18 18:17:17 +01:00
SELECT CURRENT_TIME;
2001-12-23 21:22:49 +01:00
<computeroutput>14:39:53.662522-05</computeroutput>
2001-02-18 18:17:17 +01:00
SELECT CURRENT_DATE;
2001-12-23 21:22:49 +01:00
<computeroutput>2001-12-23</computeroutput>
2001-02-18 18:17:17 +01:00
SELECT CURRENT_TIMESTAMP;
2001-12-23 21:22:49 +01:00
<computeroutput>2001-12-23 14:39:53.662522-05</computeroutput>
SELECT CURRENT_TIMESTAMP(2);
<computeroutput>2001-12-23 14:39:53.66-05</computeroutput>
2002-06-15 05:00:09 +02:00
SELECT LOCALTIMESTAMP;
<computeroutput>2001-12-23 14:39:53.662522</computeroutput>
2001-02-18 18:17:17 +01:00
</screen>
</informalexample>
<para>
The function <function>now()</function> is the traditional
2001-11-21 06:53:41 +01:00
<productname>PostgreSQL</productname> equivalent to
2001-02-18 18:17:17 +01:00
<function>CURRENT_TIMESTAMP</function>.
2001-02-22 00:15:24 +01:00
</para>
<para>
2001-12-23 21:22:49 +01:00
There is also <function>timeofday()</function>, which for historical
reasons returns a text string rather than a <type>timestamp</type> value:
2001-02-22 00:15:24 +01:00
</para>
<informalexample>
<screen>
SELECT timeofday();
Sat Feb 17 19:07:32.000126 2001 EST
</screen>
</informalexample>
<para>
It is quite important to realize that
<function>CURRENT_TIMESTAMP</function> and related functions all return
the time as of the start of the current transaction; their values do not
increment while a transaction is running. But
<function>timeofday()</function> returns the actual current time.
</para>
<para>
2001-09-09 19:21:59 +02:00
All the date/time data types also accept the special literal value
2002-06-11 17:32:33 +02:00
<literal>now</literal> to specify the current date and time. Thus,
2001-02-22 00:15:24 +01:00
the following three all return the same result:
2001-02-18 18:17:17 +01:00
<programlisting>
SELECT CURRENT_TIMESTAMP;
SELECT now();
SELECT TIMESTAMP 'now';
</programlisting>
<note>
<para>
You do not want to use the third form when specifying a DEFAULT
2002-06-11 17:32:33 +02:00
value while creating a table. The system will convert <literal>now</literal>
2001-09-09 19:21:59 +02:00
to a <type>timestamp</type> as soon as the constant is parsed, so that when
2001-02-22 00:15:24 +01:00
the default value is needed,
2001-02-18 18:17:17 +01:00
the time of the table creation would be used! The first two
forms will not be evaluated until the default value is used,
2001-02-22 00:15:24 +01:00
because they are function calls. Thus they will give the desired
behavior of defaulting to the time of row insertion.
2001-02-18 18:17:17 +01:00
</para>
</note>
</para>
</sect2>
</sect1>
2000-12-14 23:30:56 +01:00
<sect1 id="functions-geometry">
<title>Geometric Functions and Operators</title>
<para>
2001-09-09 19:21:59 +02:00
The geometric types <type>point</type>, <type>box</type>,
<type>lseg</type>, <type>line</type>, <type>path</type>,
<type>polygon</type>, and <type>circle</type> have a large set of
native support functions and operators.
2000-12-14 23:30:56 +01:00
</para>
<table>
2002-06-11 17:32:33 +02:00
<title>Geometric Operators</title>
<tgroup cols="3">
<thead>
<row>
<entry>Operator</entry>
<entry>Description</entry>
<entry>Usage</entry>
</row>
</thead>
<tbody>
<row>
<entry> + </entry>
<entry>Translation</entry>
<entry><literal>box '((0,0),(1,1))' + point '(2.0,0)'</literal></entry>
</row>
<row>
<entry> - </entry>
<entry>Translation</entry>
<entry><literal>box '((0,0),(1,1))' - point '(2.0,0)'</literal></entry>
</row>
<row>
<entry> * </entry>
<entry>Scaling/rotation</entry>
<entry><literal>box '((0,0),(1,1))' * point '(2.0,0)'</literal></entry>
</row>
<row>
<entry> / </entry>
<entry>Scaling/rotation</entry>
<entry><literal>box '((0,0),(2,2))' / point '(2.0,0)'</literal></entry>
</row>
<row>
<entry> # </entry>
<entry>Intersection</entry>
<entry><literal>'((1,-1),(-1,1))' # '((1,1),(-1,-1))'</literal></entry>
</row>
<row>
<entry> # </entry>
2002-08-08 16:29:07 +02:00
<entry>Number of points in path or polygon</entry>
2002-06-11 17:32:33 +02:00
<entry><literal># '((1,0),(0,1),(-1,0))'</literal></entry>
</row>
<row>
<entry> ## </entry>
<entry>Point of closest proximity</entry>
<entry><literal>point '(0,0)' ## lseg '((2,0),(0,2))'</literal></entry>
</row>
<row>
<entry> && </entry>
<entry>Overlaps?</entry>
<entry><literal>box '((0,0),(1,1))' && box '((0,0),(2,2))'</literal></entry>
</row>
<row>
<entry> &< </entry>
<entry>Overlaps to left?</entry>
<entry><literal>box '((0,0),(1,1))' &< box '((0,0),(2,2))'</literal></entry>
</row>
<row>
<entry> &> </entry>
<entry>Overlaps to right?</entry>
<entry><literal>box '((0,0),(3,3))' &> box '((0,0),(2,2))'</literal></entry>
</row>
<row>
<entry> <-> </entry>
<entry>Distance between</entry>
<entry><literal>circle '((0,0),1)' <-> circle '((5,0),1)'</literal></entry>
</row>
<row>
<entry> << </entry>
<entry>Left of?</entry>
<entry><literal>circle '((0,0),1)' << circle '((5,0),1)'</literal></entry>
</row>
<row>
<entry> <^ </entry>
<entry>Is below?</entry>
<entry><literal>circle '((0,0),1)' <^ circle '((0,5),1)'</literal></entry>
</row>
<row>
<entry> >> </entry>
<entry>Is right of?</entry>
<entry><literal>circle '((5,0),1)' >> circle '((0,0),1)'</literal></entry>
</row>
<row>
<entry> >^ </entry>
<entry>Is above?</entry>
<entry><literal>circle '((0,5),1)' >^ circle '((0,0),1)'</literal></entry>
</row>
<row>
<entry> ?# </entry>
<entry>Intersects or overlaps</entry>
<entry><literal>lseg '((-1,0),(1,0))' ?# box '((-2,-2),(2,2))'</literal></entry>
</row>
<row>
<entry> ?- </entry>
<entry>Is horizontal?</entry>
<entry><literal>point '(1,0)' ?- point '(0,0)'</literal></entry>
</row>
<row>
<entry> ?-| </entry>
<entry>Is perpendicular?</entry>
<entry><literal>lseg '((0,0),(0,1))' ?-| lseg '((0,0),(1,0))'</literal></entry>
</row>
<row>
<entry> @-@ </entry>
<entry>Length or circumference</entry>
<entry><literal>@-@ path '((0,0),(1,0))'</literal></entry>
</row>
<row>
<entry> ?| </entry>
<entry>Is vertical?</entry>
<entry><literal>point '(0,1)' ?| point '(0,0)'</literal></entry>
</row>
<row>
<entry> ?|| </entry>
<entry>Is parallel?</entry>
<entry><literal>lseg '((-1,0),(1,0))' ?|| lseg '((-1,2),(1,2))'</literal></entry>
</row>
<row>
<entry> @ </entry>
<entry>Contained or on</entry>
<entry><literal>point '(1,1)' @ circle '((0,0),2)'</literal></entry>
</row>
<row>
<entry> @@ </entry>
<entry>Center of</entry>
<entry><literal>@@ circle '((0,0),10)'</literal></entry>
</row>
<row>
<entry> ~= </entry>
<entry>Same as</entry>
<entry><literal>polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'</literal></entry>
</row>
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
<table>
1999-06-14 09:36:12 +02:00
<title>Geometric Functions</title>
<tgroup cols="4">
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>area</function>(object)</entry>
<entry><type>double precision</type></entry>
2000-05-02 22:02:03 +02:00
<entry>area of item</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>area(box '((0,0),(1,1))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>box</function>(box, box)</entry>
<entry><type>box</type></entry>
2000-05-02 22:02:03 +02:00
<entry>intersection box</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>box(box '((0,0),(1,1))',box '((0.5,0.5),(2,2))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>center</function>(object)</entry>
<entry><type>point</type></entry>
2000-05-02 22:02:03 +02:00
<entry>center of item</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>center(box '((0,0),(1,2))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>diameter</function>(circle)</entry>
<entry><type>double precision</type></entry>
2000-03-27 19:14:43 +02:00
<entry>diameter of circle</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>diameter(circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>height</function>(box)</entry>
<entry><type>double precision</type></entry>
2000-03-27 19:14:43 +02:00
<entry>vertical size of box</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>height(box '((0,0),(1,1))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>isclosed</function>(path)</entry>
<entry><type>boolean</type></entry>
2000-03-27 19:14:43 +02:00
<entry>a closed path?</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>isclosed(path '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>isopen</function>(path)</entry>
<entry><type>boolean</type></entry>
2000-03-27 19:14:43 +02:00
<entry>an open path?</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>isopen(path '[(0,0),(1,1),(2,0)]')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>length</function>(object)</entry>
<entry><type>double precision</type></entry>
2000-05-02 22:02:03 +02:00
<entry>length of item</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>length(path '((-1,0),(1,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
2002-08-08 16:29:07 +02:00
<row>
<entry><function>npoints</function>(path)</entry>
<entry><type>integer</type></entry>
<entry>number of points</entry>
<entry><literal>npoints(path '[(0,0),(1,1),(2,0)]')</literal></entry>
</row>
<row>
<entry><function>npoints</function>(polygon)</entry>
<entry><type>integer</type></entry>
<entry>number of points</entry>
<entry><literal>npoints(polygon '((1,1),(0,0))')</literal></entry>
</row>
1999-06-14 09:36:12 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>pclose</function>(path)</entry>
<entry><type>path</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert path to closed</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>popen(path '[(0,0),(1,1),(2,0)]')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
2001-09-09 19:21:59 +02:00
<![IGNORE[
<!-- Not defined by this name. Implements the intersection operator '#' -->
1999-06-14 09:36:12 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>point</function>(lseg,lseg)</entry>
<entry><type>point</type></entry>
2000-03-27 19:14:43 +02:00
<entry>intersection</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>point(lseg '((-1,0),(1,0))',lseg '((-2,-2),(2,2))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
2001-09-09 19:21:59 +02:00
]]>
1999-06-14 09:36:12 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>popen</function>(path)</entry>
<entry><type>path</type></entry>
2000-03-27 19:14:43 +02:00
<entry>convert path to open path</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>popen(path '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>radius</function>(circle)</entry>
<entry><type>double precision</type></entry>
2000-03-27 19:14:43 +02:00
<entry>radius of circle</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>radius(circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>width</function>(box)</entry>
<entry><type>double precision</type></entry>
2000-03-27 19:14:43 +02:00
<entry>horizontal size</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>width(box '((0,0),(1,1))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
</tbody>
</tgroup>
2000-12-14 23:30:56 +01:00
</table>
1998-07-08 15:53:15 +02:00
2000-12-14 23:30:56 +01:00
<table>
1999-06-14 09:36:12 +02:00
<title>Geometric Type Conversion Functions</title>
<tgroup cols="4">
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>box</function>(<type>circle</type>)</entry>
<entry><type>box</type></entry>
2000-05-02 22:02:03 +02:00
<entry>circle to box</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>box(circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>box</function>(<type>point</type>, <type>point</type>)</entry>
<entry><type>box</type></entry>
2000-05-02 22:02:03 +02:00
<entry>points to box</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>box(point '(0,0)', point '(1,1)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>box</function>(<type>polygon</type>)</entry>
<entry><type>box</type></entry>
2000-05-02 22:02:03 +02:00
<entry>polygon to box</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>box(polygon '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>circle</function>(<type>box</type>)</entry>
<entry><type>circle</type></entry>
2000-05-02 22:02:03 +02:00
<entry>to circle</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>circle(box '((0,0),(1,1))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>circle</function>(<type>point</type>, <type>double precision</type>)</entry>
<entry><type>circle</type></entry>
2000-05-02 22:02:03 +02:00
<entry>point to circle</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>circle(point '(0,0)', 2.0)</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>lseg</function>(<type>box</type>)</entry>
<entry><type>lseg</type></entry>
2002-03-22 20:20:45 +01:00
<entry>box diagonal to <type>lseg</type></entry>
2001-09-09 19:21:59 +02:00
<entry><literal>lseg(box '((-1,0),(1,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>lseg</function>(<type>point</type>, <type>point</type>)</entry>
<entry><type>lseg</type></entry>
2002-03-22 20:20:45 +01:00
<entry>points to <type>lseg</type></entry>
2001-09-09 19:21:59 +02:00
<entry><literal>lseg(point '(-1,0)', point '(1,0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>path</function>(<type>polygon</type>)</entry>
<entry><type>point</type></entry>
2000-05-02 22:02:03 +02:00
<entry>polygon to path</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>path(polygon '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>point</function>(<type>circle</type>)</entry>
<entry><type>point</type></entry>
2000-05-02 22:02:03 +02:00
<entry>center</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>point(circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>point</function>(<type>lseg</type>, <type>lseg</type>)</entry>
<entry><type>point</type></entry>
2000-05-02 22:02:03 +02:00
<entry>intersection</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>point(lseg '((-1,0),(1,0))', lseg '((-2,-2),(2,2))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>point</function>(<type>polygon</type>)</entry>
<entry><type>point</type></entry>
2000-05-02 22:02:03 +02:00
<entry>center</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>point(polygon '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>polygon</function>(<type>box</type>)</entry>
<entry><type>polygon</type></entry>
2002-08-08 16:29:07 +02:00
<entry>4-point polygon</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>polygon(box '((0,0),(1,1))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>polygon</function>(<type>circle</type>)</entry>
<entry><type>polygon</type></entry>
2000-05-02 22:02:03 +02:00
<entry>12-point polygon</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>polygon(circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>polygon</function>(<replaceable class="parameter">npts</replaceable>, <type>circle</type>)</entry>
<entry><type>polygon</type></entry>
2000-05-02 22:02:03 +02:00
<entry><replaceable class="parameter">npts</replaceable> polygon</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>polygon(12, circle '((0,0),2.0)')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>polygon</function>(<type>path</type>)</entry>
<entry><type>polygon</type></entry>
2000-05-02 22:02:03 +02:00
<entry>path to polygon</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>polygon(path '((0,0),(1,1),(2,0))')</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
</tbody>
</tgroup>
2000-12-14 23:30:56 +01:00
</table>
2002-08-08 16:29:07 +02:00
<para>
It is possible to access the two component numbers of a <type>point</>
as though it were an array with subscripts 0,1. For example, if
<literal>t.p</> is a <type>point</> column then
<literal>SELECT p[0] FROM t</> retrieves the X coordinate;
<literal>UPDATE t SET p[1] = ...</> changes the Y coordinate.
In the same way, a <type>box</> or an <type>lseg</> may be treated
as an array of two <type>point</>s.
</para>
1999-05-12 09:32:47 +02:00
</sect1>
1998-07-08 15:53:15 +02:00
2000-12-14 23:30:56 +01:00
<sect1 id="functions-net">
2000-10-04 17:47:45 +02:00
<title>Network Address Type Functions</title>
1998-10-27 07:14:41 +01:00
2000-12-14 23:30:56 +01:00
<table tocentry="1" id="cidr-inet-operators-table">
2002-06-11 17:32:33 +02:00
<title><type>cidr</type> and <type>inet</type> Operators</title>
<tgroup cols="3">
<thead>
<row>
<entry>Operator</entry>
<entry>Description</entry>
<entry>Usage</entry>
</row>
</thead>
<tbody>
<row>
<entry> < </entry>
<entry>Less than</entry>
<entry><literal>inet '192.168.1.5' < inet '192.168.1.6'</literal></entry>
</row>
<row>
<entry> <= </entry>
<entry>Less than or equal</entry>
<entry><literal>inet '192.168.1.5' <= inet '192.168.1.5'</literal></entry>
</row>
<row>
<entry> = </entry>
<entry>Equals</entry>
<entry><literal>inet '192.168.1.5' = inet '192.168.1.5'</literal></entry>
</row>
<row>
<entry> >= </entry>
<entry>Greater or equal</entry>
<entry><literal>inet '192.168.1.5' >= inet '192.168.1.5'</literal></entry>
</row>
<row>
<entry> > </entry>
<entry>Greater</entry>
<entry><literal>inet '192.168.1.5' > inet '192.168.1.4'</literal></entry>
</row>
<row>
<entry> <> </entry>
<entry>Not equal</entry>
<entry><literal>inet '192.168.1.5' <> inet '192.168.1.4'</literal></entry>
</row>
<row>
<entry> << </entry>
<entry>is contained within</entry>
<entry><literal>inet '192.168.1.5' << inet '192.168.1/24'</literal></entry>
</row>
<row>
<entry> <<= </entry>
<entry>is contained within or equals</entry>
<entry><literal>inet '192.168.1/24' <<= inet '192.168.1/24'</literal></entry>
</row>
<row>
<entry> >> </entry>
<entry>contains</entry>
<entry><literal>inet'192.168.1/24' >> inet '192.168.1.5'</literal></entry>
</row>
<row>
<entry> >>= </entry>
<entry>contains or equals</entry>
<entry><literal>inet '192.168.1/24' >>= inet '192.168.1/24'</literal></entry>
</row>
</tbody>
</tgroup>
</table>
2000-12-14 23:30:56 +01:00
<para>
All of the operators for <type>inet</type> can be applied to
<type>cidr</type> values as well. The operators
2002-06-11 17:32:33 +02:00
<literal><<</literal>, <literal><<=</literal>,
<literal>>></literal>, <literal>>>=</literal>
2000-12-14 23:30:56 +01:00
test for subnet inclusion: they consider only the network parts
of the two addresses, ignoring any host part, and determine whether
one network part is identical to or a subnet of the other.
</para>
2000-10-04 17:47:45 +02:00
<table tocentry="1" id="cidr-inet-functions">
2002-06-11 17:32:33 +02:00
<title><type>cidr</type> and <type>inet</type> Functions</title>
2000-11-10 21:13:27 +01:00
<tgroup cols="5">
1999-06-14 09:36:12 +02:00
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
2000-11-10 21:13:27 +01:00
<entry>Result</entry>
1999-06-14 09:36:12 +02:00
</row>
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>broadcast</function>(<type>inet</type>)</entry>
<entry><type>inet</type></entry>
2000-11-10 21:13:27 +01:00
<entry>broadcast address for network</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>broadcast('192.168.1.5/24')</literal></entry>
<entry><literal>192.168.1.255/24</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>host</function>(<type>inet</type>)</entry>
<entry><type>text</type></entry>
2000-11-10 21:13:27 +01:00
<entry>extract IP address as text</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>host('192.168.1.5/24')</literal></entry>
<entry><literal>192.168.1.5</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>masklen</function>(<type>inet</type>)</entry>
<entry><type>integer</type></entry>
2000-11-10 21:13:27 +01:00
<entry>extract netmask length</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>masklen('192.168.1.5/24')</literal></entry>
<entry><literal>24</literal></entry>
1999-06-14 09:36:12 +02:00
</row>
2001-06-14 00:51:02 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>set_masklen</function>(<type>inet</type>,<type>integer</type>)</entry>
<entry><type>inet</type></entry>
2002-03-22 20:20:45 +01:00
<entry>set netmask length for <type>inet</type> value</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>set_masklen('192.168.1.5/24',16)</literal></entry>
<entry><literal>192.168.1.5/16</literal></entry>
2001-06-14 00:51:02 +02:00
</row>
1999-06-14 09:36:12 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>netmask</function>(<type>inet</type>)</entry>
<entry><type>inet</type></entry>
2000-11-10 21:13:27 +01:00
<entry>construct netmask for network</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>netmask('192.168.1.5/24')</literal></entry>
<entry><literal>255.255.255.0</literal></entry>
2000-11-10 21:13:27 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>network</function>(<type>inet</type>)</entry>
<entry><type>cidr</type></entry>
2000-11-10 21:13:27 +01:00
<entry>extract network part of address</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>network('192.168.1.5/24')</literal></entry>
<entry><literal>192.168.1.0/24</literal></entry>
2000-11-10 21:13:27 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>text</function>(<type>inet</type>)</entry>
<entry><type>text</type></entry>
2000-11-10 21:13:27 +01:00
<entry>extract IP address and masklen as text</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>text(inet '192.168.1.5')</literal></entry>
<entry><literal>192.168.1.5/32</literal></entry>
2000-11-10 21:13:27 +01:00
</row>
2000-12-22 19:00:24 +01:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>abbrev</function>(<type>inet</type>)</entry>
<entry><type>text</type></entry>
2000-12-22 19:00:24 +01:00
<entry>extract abbreviated display as text</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>abbrev(cidr '10.1.0.0/16')</literal></entry>
<entry><literal>10.1/16</literal></entry>
2000-12-22 19:00:24 +01:00
</row>
2000-11-10 21:13:27 +01:00
</tbody>
</tgroup>
</table>
<para>
All of the functions for <type>inet</type> can be applied to
2002-06-11 17:32:33 +02:00
<type>cidr</type> values as well. The <function>host</function>(),
<function>text</function>(), and <function>abbrev</function>() functions are primarily
2001-06-14 00:51:02 +02:00
intended to offer alternative display formats. You can cast a text
2001-09-09 19:21:59 +02:00
field to inet using normal casting syntax: <literal>inet(expression)</literal> or
<literal>colname::inet</literal>.
2000-11-10 21:13:27 +01:00
</para>
<table tocentry="1" id="macaddr-functions">
2002-06-11 17:32:33 +02:00
<title><type>macaddr</type> Functions</title>
2000-11-10 21:13:27 +01:00
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Returns</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
1999-06-14 09:36:12 +02:00
</row>
2000-11-10 21:13:27 +01:00
</thead>
<tbody>
2000-10-04 17:47:45 +02:00
<row>
2001-09-09 19:21:59 +02:00
<entry><function>trunc</function>(<type>macaddr</type>)</entry>
<entry><type>macaddr</type></entry>
2000-10-04 17:47:45 +02:00
<entry>set last 3 bytes to zero</entry>
2001-09-09 19:21:59 +02:00
<entry><literal>trunc(macaddr '12:34:56:78:90:ab')</literal></entry>
<entry><literal>12:34:56:00:00:00</literal></entry>
2000-10-04 17:47:45 +02:00
</row>
1999-06-14 09:36:12 +02:00
</tbody>
</tgroup>
</table>
2000-10-04 17:47:45 +02:00
2000-11-10 21:13:27 +01:00
<para>
2002-06-11 17:32:33 +02:00
The function <function>trunc</function>(<type>macaddr</type>) returns a MAC
2000-10-04 17:47:45 +02:00
address with the last 3 bytes set to 0. This can be used to
associate the remaining prefix with a manufacturer. The directory
2002-06-11 17:32:33 +02:00
<filename>contrib/mac</filename> in the source distribution contains some
2000-10-04 17:47:45 +02:00
utilities to create and maintain such an association table.
1999-06-14 09:36:12 +02:00
</para>
1998-10-27 07:14:41 +01:00
2000-12-14 23:30:56 +01:00
<para>
2002-06-11 17:32:33 +02:00
The <type>macaddr</type> type also supports the standard relational
operators (<literal>></literal>, <literal><=</literal>, etc.) for
2000-12-14 23:30:56 +01:00
lexicographical ordering.
</para>
1999-06-14 09:36:12 +02:00
</sect1>
1998-10-27 07:14:41 +01:00
2000-12-14 23:30:56 +01:00
2001-11-17 23:20:34 +01:00
<sect1 id="functions-sequence">
<title>Sequence-Manipulation Functions</title>
<indexterm>
<primary>sequences</primary>
</indexterm>
<indexterm>
<primary>nextval</primary>
</indexterm>
<indexterm>
<primary>currval</primary>
</indexterm>
<indexterm>
<primary>setval</primary>
</indexterm>
<table>
2002-06-11 17:32:33 +02:00
<title>Sequence Functions</title>
2001-11-17 23:20:34 +01:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Function</entry> <entry>Returns</entry> <entry>Description</entry></row>
2001-11-17 23:20:34 +01:00
</thead>
<tbody>
<row>
<entry><function>nextval</function>(<type>text</type>)</entry>
<entry><type>bigint</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Advance sequence and return new value</entry>
2001-11-17 23:20:34 +01:00
</row>
<row>
<entry><function>currval</function>(<type>text</type>)</entry>
<entry><type>bigint</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Return value most recently obtained with <function>nextval</function></entry>
2001-11-17 23:20:34 +01:00
</row>
<row>
<entry><function>setval</function>(<type>text</type>,<type>bigint</type>)</entry>
<entry><type>bigint</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Set sequence's current value</entry>
2001-11-17 23:20:34 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>setval</function>(<type>text</type>,<type>bigint</type>,<type>boolean</type>)</entry>
2001-11-17 23:20:34 +01:00
<entry><type>bigint</type></entry>
2002-06-11 17:32:33 +02:00
<entry>Set sequence's current value and <literal>is_called</literal> flag</entry>
2001-11-17 23:20:34 +01:00
</row>
</tbody>
</tgroup>
</table>
<para>
2001-11-21 06:53:41 +01:00
This section describes <productname>PostgreSQL</productname>'s functions
2002-06-11 17:32:33 +02:00
for operating on <firstterm>sequence objects</firstterm>.
2001-11-17 23:20:34 +01:00
Sequence objects (also called sequence generators or
just sequences) are special single-row tables created with
2002-06-11 17:32:33 +02:00
<command>CREATE SEQUENCE</command>. A sequence object is usually used to
2001-11-17 23:20:34 +01:00
generate unique identifiers for rows of a table. The sequence functions
2002-01-20 23:19:57 +01:00
provide simple, multiuser-safe methods for obtaining successive
2001-11-17 23:20:34 +01:00
sequence values from sequence objects.
</para>
<para>
For largely historical reasons, the sequence to be operated on by
a sequence-function call is specified by a text-string argument.
To achieve some compatibility with the handling of ordinary SQL
names, the sequence functions convert their argument to lower case
unless the string is double-quoted. Thus
<programlisting>
2002-06-11 17:32:33 +02:00
nextval('foo') <lineannotation>operates on sequence </><literal>foo</literal>
nextval('FOO') <lineannotation>operates on sequence </><literal>foo</literal>
nextval('"Foo"') <lineannotation>operates on sequence </><literal>Foo</literal>
2002-04-26 03:24:08 +02:00
</programlisting>
The sequence name can be schema-qualified if necessary:
<programlisting>
2002-06-11 17:32:33 +02:00
nextval('myschema.foo') <lineannotation>operates on </><literal>myschema.foo</literal>
nextval('"myschema".foo') <lineannotation>same as above</lineannotation>
nextval('foo') <lineannotation>searches search path for
</><literal>foo</literal>
2001-11-17 23:20:34 +01:00
</programlisting>
Of course, the text argument can be the result of an expression,
not only a simple literal, which is occasionally useful.
</para>
<para>
The available sequence functions are:
<variablelist>
<varlistentry>
2002-06-11 17:32:33 +02:00
<term><function>nextval</function></term>
2001-11-17 23:20:34 +01:00
<listitem>
<para>
Advance the sequence object to its next value and return that
value. This is done atomically: even if multiple server processes
2002-06-11 17:32:33 +02:00
execute <function>nextval</function> concurrently, each will safely receive
2001-11-17 23:20:34 +01:00
a distinct sequence value.
</para>
</listitem>
</varlistentry>
<varlistentry>
2002-06-11 17:32:33 +02:00
<term><function>currval</function></term>
2001-11-17 23:20:34 +01:00
<listitem>
<para>
2002-06-11 17:32:33 +02:00
Return the value most recently obtained by <function>nextval</function>
2001-11-17 23:20:34 +01:00
for this sequence in the current server process. (An error is
2002-06-11 17:32:33 +02:00
reported if <function>nextval</function> has never been called for this
2001-11-17 23:20:34 +01:00
sequence in this process.) Notice that because this is returning
a process-local value, it gives a predictable answer even if other
2002-06-11 17:32:33 +02:00
server processes are executing <function>nextval</function> meanwhile.
2001-11-17 23:20:34 +01:00
</para>
</listitem>
</varlistentry>
<varlistentry>
2002-06-11 17:32:33 +02:00
<term><function>setval</function></term>
2001-11-17 23:20:34 +01:00
<listitem>
<para>
Reset the sequence object's counter value. The two-parameter
2002-06-11 17:32:33 +02:00
form sets the sequence's <literal>last_value</literal> field to the specified
value and sets its <literal>is_called</literal> field to <literal>true</literal>,
meaning that the next <function>nextval</function> will advance the sequence
2001-11-17 23:20:34 +01:00
before returning a value. In the three-parameter form,
2002-06-11 17:32:33 +02:00
<literal>is_called</literal> may be set either <literal>true</literal> or
<literal>false</literal>. If it's set to <literal>false</literal>,
the next <function>nextval</function> will return exactly the specified
2001-11-17 23:20:34 +01:00
value, and sequence advancement commences with the following
2002-06-11 17:32:33 +02:00
<function>nextval</function>. For example,
2001-11-17 23:20:34 +01:00
</para>
<informalexample>
<screen>
2002-06-11 17:32:33 +02:00
SELECT setval('foo', 42); <lineannotation>Next nextval() will return 43</lineannotation>
SELECT setval('foo', 42, true); <lineannotation>Same as above</lineannotation>
SELECT setval('foo', 42, false); <lineannotation>Next nextval() will return 42</lineannotation>
2001-11-17 23:20:34 +01:00
</screen>
</informalexample>
<para>
2002-06-11 17:32:33 +02:00
The result returned by <function>setval</function> is just the value of its
2001-11-17 23:20:34 +01:00
second argument.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<important>
<para>
To avoid blocking of concurrent transactions that obtain numbers from the
2002-06-11 17:32:33 +02:00
same sequence, a <function>nextval</function> operation is never rolled back;
2001-11-17 23:20:34 +01:00
that is, once a value has been fetched it is considered used, even if the
2002-06-11 17:32:33 +02:00
transaction that did the <function>nextval</function> later aborts. This means
2001-11-17 23:20:34 +01:00
that aborted transactions may leave unused <quote>holes</quote> in the
2002-06-11 17:32:33 +02:00
sequence of assigned values. <function>setval</function> operations are never
2001-11-17 23:20:34 +01:00
rolled back, either.
</para>
</important>
<para>
If a sequence object has been created with default parameters,
2002-06-11 17:32:33 +02:00
<function>nextval()</function> calls on it will return successive values
2001-11-17 23:20:34 +01:00
beginning with one. Other behaviors can be obtained by using
2002-06-11 17:32:33 +02:00
special parameters in the <command>CREATE SEQUENCE</command> command;
2001-11-17 23:20:34 +01:00
see its command reference page for more information.
</para>
</sect1>
2000-12-14 23:30:56 +01:00
<sect1 id="functions-conditional">
<title>Conditional Expressions</title>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>case</primary>
</indexterm>
<indexterm>
<primary>conditionals</primary>
</indexterm>
2000-12-14 23:30:56 +01:00
<para>
2001-02-18 18:17:17 +01:00
This section describes the <acronym>SQL</acronym>-compliant conditional expressions
2001-11-21 06:53:41 +01:00
available in <productname>PostgreSQL</productname>.
2000-12-14 23:30:56 +01:00
</para>
<tip>
<para>
If your needs go beyond the capabilities of these conditional
expressions you might want to consider writing a stored procedure
in a more expressive programming language.
</para>
</tip>
<bridgehead renderas="sect2">CASE</bridgehead>
<synopsis>
CASE WHEN <replaceable>condition</replaceable> THEN <replaceable>result</replaceable>
<optional>WHEN ...</optional>
<optional>ELSE <replaceable>result</replaceable></optional>
END
</synopsis>
<para>
The <acronym>SQL</acronym> <token>CASE</token> expression is a
generic conditional expression, similar to if/else statements in
2001-02-18 18:17:17 +01:00
other languages. <token>CASE</token> clauses can be used wherever
2000-12-14 23:30:56 +01:00
an expression is valid. <replaceable>condition</replaceable> is an
2001-02-18 18:17:17 +01:00
expression that returns a <type>boolean</type> result. If the result is true
2000-12-14 23:30:56 +01:00
then the value of the <token>CASE</token> expression is
<replaceable>result</replaceable>. If the result is false any
subsequent <token>WHEN</token> clauses are searched in the same
manner. If no <token>WHEN</token>
<replaceable>condition</replaceable> is true then the value of the
case expression is the <replaceable>result</replaceable> in the
<token>ELSE</token> clause. If the <token>ELSE</token> clause is
omitted and no condition matches, the result is NULL.
</para>
<informalexample>
<para>
An example:
<screen>
<prompt>=></prompt> <userinput>SELECT * FROM test;</userinput>
<computeroutput>
a
---
1
2
3
</computeroutput>
2001-10-09 20:46:00 +02:00
<prompt>=></prompt> <userinput>SELECT a,
CASE WHEN a=1 THEN 'one'
WHEN a=2 THEN 'two'
ELSE 'other'
END
FROM test;</userinput>
2000-12-14 23:30:56 +01:00
<computeroutput>
a | case
---+-------
1 | one
2 | two
3 | other
</computeroutput>
</screen>
</para>
</informalexample>
<para>
2000-12-17 06:55:26 +01:00
The data types of all the <replaceable>result</replaceable>
expressions must be coercible to a single output type.
See <xref linkend="typeconv-union-case"> for more detail.
2000-12-14 23:30:56 +01:00
</para>
<synopsis>
CASE <replaceable>expression</replaceable>
WHEN <replaceable>value</replaceable> THEN <replaceable>result</replaceable>
<optional>WHEN ...</optional>
<optional>ELSE <replaceable>result</replaceable></optional>
END
</synopsis>
<para>
This <quote>simple</quote> <token>CASE</token> expression is a
specialized variant of the general form above. The
<replaceable>expression</replaceable> is computed and compared to
all the <replaceable>value</replaceable>s in the
<token>WHEN</token> clauses until one is found that is equal. If
no match is found, the <replaceable>result</replaceable> in the
<token>ELSE</token> clause (or NULL) is returned. This is similar
to the <function>switch</function> statement in C.
</para>
<informalexample>
<para>
The example above can be written using the simple
<token>CASE</token> syntax:
<screen>
2001-10-09 20:46:00 +02:00
<prompt>=></prompt> <userinput>SELECT a,
CASE a WHEN 1 THEN 'one'
WHEN 2 THEN 'two'
ELSE 'other'
END
FROM test;</userinput>
2000-12-14 23:30:56 +01:00
<computeroutput>
a | case
---+-------
1 | one
2 | two
3 | other
</computeroutput>
</screen>
</para>
</informalexample>
<bridgehead renderas="sect2">COALESCE</bridgehead>
<synopsis>
2002-06-11 17:32:33 +02:00
<function>COALESCE</function>(<replaceable>value</replaceable><optional
>, ...</optional>)
2000-12-14 23:30:56 +01:00
</synopsis>
<para>
The <function>COALESCE</function> function returns the first of its
arguments that is not NULL. This is often useful to substitute a
default value for NULL values when data is retrieved for display,
for example:
<programlisting>
SELECT COALESCE(description, short_description, '(none)') ...
</programlisting>
</para>
<bridgehead renderas="sect2">NULLIF</bridgehead>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>nullif</primary>
</indexterm>
2000-12-14 23:30:56 +01:00
<synopsis>
2002-06-11 17:32:33 +02:00
<function>NULLIF</function>(<replaceable>value1</replaceable>,
<replaceable>value2</replaceable>)
2000-12-14 23:30:56 +01:00
</synopsis>
<para>
The <function>NULLIF</function> function returns NULL if and only
if <replaceable>value1</replaceable> and
<replaceable>value2</replaceable> are equal. Otherwise it returns
<replaceable>value1</replaceable>. This can be used to perform the
inverse operation of the <function>COALESCE</function> example
given above:
<programlisting>
SELECT NULLIF(value, '(none)') ...
</programlisting>
</para>
2000-12-16 19:33:13 +01:00
<tip>
<para>
<function>COALESCE</function> and <function>NULLIF</function> are
just shorthand for <token>CASE</token> expressions. They are actually
converted into <token>CASE</token> expressions at a very early stage
of processing, and subsequent processing thinks it is dealing with
<token>CASE</token>. Thus an incorrect <function>COALESCE</function> or
<function>NULLIF</function> usage may draw an error message that
refers to <token>CASE</token>.
</para>
</tip>
2000-12-14 23:30:56 +01:00
</sect1>
<sect1 id="functions-misc">
2002-06-11 17:32:33 +02:00
<title>Miscellaneous Functions</title>
2000-09-19 20:18:04 +02:00
<table>
2002-06-11 17:32:33 +02:00
<title>Session Information Functions</title>
2000-09-19 20:18:04 +02:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
2000-09-19 20:18:04 +02:00
</thead>
<tbody>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>current_user</function></entry>
<entry><type>name</type></entry>
2002-04-26 03:24:08 +02:00
<entry>user name of current execution context</entry>
2000-09-19 20:18:04 +02:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>session_user</function></entry>
<entry><type>name</type></entry>
2002-04-26 03:24:08 +02:00
<entry>session user name</entry>
2000-09-19 20:18:04 +02:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>user</function></entry>
<entry><type>name</type></entry>
<entry>equivalent to <function>current_user</function></entry>
2002-04-26 03:24:08 +02:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>current_schema()</function></entry>
<entry><type>name</type></entry>
2002-04-26 03:24:08 +02:00
<entry>name of current schema</entry>
</row>
<row>
2002-06-15 22:03:51 +02:00
<entry><function>current_schemas(boolean)</function></entry>
2002-06-11 17:32:33 +02:00
<entry><type>name[]</type></entry>
2002-06-15 22:03:51 +02:00
<entry>names of schemas in search path optionally including implicit schemas</entry>
2000-09-19 20:18:04 +02:00
</row>
</tbody>
</tgroup>
</table>
2001-05-13 00:51:36 +02:00
<indexterm zone="functions-misc">
<primary>user</primary>
<secondary>current</secondary>
</indexterm>
2002-04-26 03:24:08 +02:00
<indexterm zone="functions-misc">
<primary>schema</primary>
<secondary>current</secondary>
</indexterm>
<indexterm zone="functions-misc">
<primary>search path</primary>
<secondary>current</secondary>
</indexterm>
2000-09-19 20:18:04 +02:00
<para>
2002-06-11 17:32:33 +02:00
The <function>session_user</function> is the user that initiated a
2002-05-18 15:48:01 +02:00
database connection; it is fixed for the duration of that
2002-06-11 17:32:33 +02:00
connection. The <function>current_user</function> is the user identifier
2002-05-18 15:48:01 +02:00
that is applicable for permission checking. Normally, it is equal
to the session user, but it changes during the execution of
functions with the attribute <literal>SECURITY DEFINER</literal>.
2002-06-11 17:32:33 +02:00
In Unix parlance, the session user is the <quote>real user</quote> and
the current user is the <quote>effective user</quote>.
2000-09-19 20:18:04 +02:00
</para>
2002-04-26 03:24:08 +02:00
<note>
<para>
2002-06-11 17:32:33 +02:00
<function>current_user</function>, <function>session_user</function>, and
<function>user</function> have special syntactic status in <acronym>SQL</acronym>:
2002-04-26 03:24:08 +02:00
they must be called without trailing parentheses.
</para>
</note>
2000-09-19 20:18:04 +02:00
<note>
2002-06-11 17:32:33 +02:00
<title>Deprecated</title>
2000-09-19 20:18:04 +02:00
<para>
2002-06-11 17:32:33 +02:00
The function <function>getpgusername()</function> is an obsolete equivalent
of <function>current_user</function>.
2000-09-19 20:18:04 +02:00
</para>
</note>
2001-06-15 23:03:07 +02:00
2002-04-26 03:24:08 +02:00
<para>
2002-06-11 17:32:33 +02:00
<function>current_schema</function> returns the name of the schema that is
2002-04-26 03:24:08 +02:00
at the front of the search path (or NULL if the search path is
empty). This is the schema that will be used for any tables or
other named objects that are created without specifying a target schema.
2002-06-15 22:03:51 +02:00
<function>current_schemas(boolean)</function> returns an array of the names of all
schemas presently in the search path. The boolean option determines whether or not
implicitly included system schemas such as pg_catalog are included in the search
path returned.
2002-04-26 03:24:08 +02:00
</para>
2001-11-21 23:33:14 +01:00
<table>
2002-06-11 17:32:33 +02:00
<title>System Information Functions</title>
2001-11-21 23:33:14 +01:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
2001-11-21 23:33:14 +01:00
</thead>
<tbody>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>version</function></entry>
<entry><type>text</type></entry>
<entry>PostgreSQL version information</entry>
2001-11-21 23:33:14 +01:00
</row>
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
<primary>version</primary>
</indexterm>
<para>
2002-06-11 17:32:33 +02:00
<function>version()</function> returns a string describing the PostgreSQL
2001-11-21 23:33:14 +01:00
server's version.
</para>
2002-08-04 05:53:11 +02:00
<table>
<title>Configuration Settings Information Functions</title>
<tgroup cols="3">
<thead>
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
</thead>
<tbody>
<row>
<entry>
<function>current_setting</function>(<parameter>setting_name</parameter>)
</entry>
<entry><type>text</type></entry>
<entry>value of current setting</entry>
</row>
<row>
<entry>
<function>set_config(<parameter>setting_name</parameter>,
<parameter>new_value</parameter>,
<parameter>is_local</parameter>)</function>
</entry>
<entry><type>text</type></entry>
<entry>new value of current setting</entry>
</row>
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
<primary>setting</primary>
<secondary>current</secondary>
</indexterm>
<indexterm zone="functions-misc">
<primary>setting</primary>
<secondary>set</secondary>
</indexterm>
<para>
The <function>current_setting</function> is used to obtain the current
value of the <parameter>setting_name</parameter> setting, as a query
result. It is the equivalent to the SQL <command>SHOW</command> command.
For example:
<programlisting>
select current_setting('DateStyle');
current_setting
---------------------------------------
ISO with US (NonEuropean) conventions
(1 row)
</programlisting>
</para>
<para>
<function>set_config</function> allows the <parameter>setting_name
</parameter> setting to be changed to <parameter>new_value</parameter>.
If <parameter>is_local</parameter> is set to <literal>true</literal>,
the new value will only apply to the current transaction. If you want
the new value to apply for the current session, use
<literal>false</literal> instead. It is the equivalent to the SQL
<command>SET</command> command. For example:
<programlisting>
select set_config('show_query_stats','off','f');
set_config
------------
off
(1 row)
</programlisting>
</para>
2001-06-15 23:03:07 +02:00
<table>
2002-06-11 17:32:33 +02:00
<title>Access Privilege Inquiry Functions</title>
2001-06-15 23:03:07 +02:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
2001-06-15 23:03:07 +02:00
</thead>
<tbody>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>has_table_privilege</function>(<parameter>user</parameter>,
2001-06-15 23:03:07 +02:00
<parameter>table</parameter>,
<parameter>access</parameter>)
</entry>
2002-06-11 17:32:33 +02:00
<entry><type>boolean</type></entry>
<entry>does user have access to table</entry>
2001-06-15 23:03:07 +02:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>has_table_privilege</function>(<parameter>table</parameter>,
2001-06-15 23:03:07 +02:00
<parameter>access</parameter>)
</entry>
2002-06-11 17:32:33 +02:00
<entry><type>boolean</type></entry>
<entry>does current user have access to table</entry>
2001-06-15 23:03:07 +02:00
</row>
2002-08-09 18:45:16 +02:00
<row>
<entry><function>has_database_privilege</function>(<parameter>user</parameter>,
<parameter>database</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does user have access to database</entry>
</row>
<row>
<entry><function>has_database_privilege</function>(<parameter>database</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does current user have access to database</entry>
</row>
<row>
<entry><function>has_function_privilege</function>(<parameter>user</parameter>,
<parameter>function</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does user have access to function</entry>
</row>
<row>
<entry><function>has_function_privilege</function>(<parameter>function</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does current user have access to function</entry>
</row>
<row>
<entry><function>has_language_privilege</function>(<parameter>user</parameter>,
<parameter>language</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does user have access to language</entry>
</row>
<row>
<entry><function>has_language_privilege</function>(<parameter>language</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does current user have access to language</entry>
</row>
<row>
<entry><function>has_schema_privilege</function>(<parameter>user</parameter>,
<parameter>schema</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does user have access to schema</entry>
</row>
<row>
<entry><function>has_schema_privilege</function>(<parameter>schema</parameter>,
<parameter>access</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>does current user have access to schema</entry>
</row>
2001-06-15 23:03:07 +02:00
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
<primary>has_table_privilege</primary>
</indexterm>
2002-08-09 18:45:16 +02:00
<indexterm zone="functions-misc">
<primary>has_database_privilege</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>has_function_privilege</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>has_language_privilege</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>has_schema_privilege</primary>
</indexterm>
2001-06-15 23:03:07 +02:00
<para>
2002-08-09 18:45:16 +02:00
<function>has_table_privilege</function> checks whether a user
2001-06-15 23:03:07 +02:00
can access a table in a particular way. The user can be
2001-11-21 23:33:14 +01:00
specified by name or by ID
2002-06-11 17:32:33 +02:00
(<classname>pg_user</classname>.<structfield>usesysid</structfield>), or if the argument is
2001-11-21 23:33:14 +01:00
omitted
2002-06-11 17:32:33 +02:00
<function>current_user</function> is assumed. The table can be specified
2001-06-15 23:03:07 +02:00
by name or by OID. (Thus, there are actually six variants of
2002-06-11 17:32:33 +02:00
<function>has_table_privilege</function>, which can be distinguished by
2002-04-26 03:24:08 +02:00
the number and types of their arguments.) When specifying by name,
the name can be schema-qualified if necessary.
The desired access type
2001-06-15 23:03:07 +02:00
is specified by a text string, which must evaluate to one of the
2002-06-11 17:32:33 +02:00
values <literal>SELECT</literal>, <literal>INSERT</literal>, <literal>UPDATE</literal>,
<literal>DELETE</literal>, <literal>RULE</literal>, <literal>REFERENCES</literal>, or
<literal>TRIGGER</literal>. (Case of the string is not significant, however.)
2002-04-26 03:24:08 +02:00
An example is:
<programlisting>
SELECT has_table_privilege('myschema.mytable', 'select');
</programlisting>
2001-06-15 23:03:07 +02:00
</para>
2002-08-09 18:45:16 +02:00
<para>
<function>has_database_privilege</function> checks whether a user
can access a database in a particular way. The possibilities for its
arguments are analogous to <function>has_table_privilege</function>.
The desired access type must evaluate to
<literal>CREATE</literal>,
<literal>TEMPORARY</literal>, or
<literal>TEMP</literal> (which is equivalent to
<literal>TEMPORARY</literal>).
</para>
<para>
<function>has_function_privilege</function> checks whether a user
can access a function in a particular way. The possibilities for its
arguments are analogous to <function>has_table_privilege</function>.
When specifying a function by a text string rather than by OID,
the allowed input is the same as for the <type>regprocedure</> datatype.
The desired access type must currently evaluate to
<literal>EXECUTE</literal>.
</para>
<para>
<function>has_language_privilege</function> checks whether a user
can access a procedural language in a particular way. The possibilities
for its arguments are analogous to <function>has_table_privilege</function>.
The desired access type must currently evaluate to
<literal>USAGE</literal>.
</para>
<para>
<function>has_schema_privilege</function> checks whether a user
can access a schema in a particular way. The possibilities for its
arguments are analogous to <function>has_table_privilege</function>.
The desired access type must evaluate to
<literal>CREATE</literal> or
<literal>USAGE</literal>.
</para>
<table>
<title>Schema Visibility Inquiry Functions</title>
<tgroup cols="3">
<thead>
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
</thead>
<tbody>
<row>
<entry><function>pg_table_is_visible</function>(<parameter>tableOID</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>is table visible in search path</entry>
</row>
<row>
<entry><function>pg_type_is_visible</function>(<parameter>typeOID</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>is type visible in search path</entry>
</row>
<row>
<entry><function>pg_function_is_visible</function>(<parameter>functionOID</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>is function visible in search path</entry>
</row>
<row>
<entry><function>pg_operator_is_visible</function>(<parameter>operatorOID</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>is operator visible in search path</entry>
</row>
<row>
<entry><function>pg_opclass_is_visible</function>(<parameter>opclassOID</parameter>)
</entry>
<entry><type>boolean</type></entry>
<entry>is operator class visible in search path</entry>
</row>
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
<primary>pg_table_is_visible</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_type_is_visible</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_function_is_visible</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_operator_is_visible</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_opclass_is_visible</primary>
</indexterm>
<para>
<function>pg_table_is_visible</function> checks whether a table
(or view, or any other kind of <structname>pg_class</> entry) is
<firstterm>visible</> in the current schema search path. A table
is said to be visible if its containing schema is in the search path
and no table of the same name appears earlier in the search path.
This is equivalent to the statement that the table can be referenced
by name without explicit schema qualification.
For example, to list the names of all visible tables:
<programlisting>
SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
</programlisting>
</para>
<para>
<function>pg_type_is_visible</function>,
<function>pg_function_is_visible</function>,
<function>pg_operator_is_visible</function>, and
<function>pg_opclass_is_visible</function> perform the same sort of
visibility check for types, functions, operators, and operator classes,
respectively. For functions and operators, an object in the search path
is visible if there is no object of the same name <emphasis>and argument
datatype(s)</> earlier in the path. For operator classes,
both name and associated index access method are considered.
</para>
<para>
All these functions require object OIDs to identify the object to be
checked. If you want to test an object by name, it is convenient to use
the OID alias types (<type>regclass</>, <type>regtype</>,
<type>regprocedure</>, or <type>regoperator</>), for example
<programlisting>
SELECT pg_type_is_visible('myschema.widget'::regtype);
</programlisting>
Note that it would not make much sense to test an unqualified name in
this way --- if the name can be recognized at all, it must be visible.
</para>
2001-11-19 04:58:25 +01:00
<table>
2002-06-11 17:32:33 +02:00
<title>Catalog Information Functions</title>
2001-11-19 04:58:25 +01:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
2001-11-19 04:58:25 +01:00
</thead>
<tbody>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>pg_get_viewdef</function>(<parameter>viewname</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get CREATE VIEW command for view</entry>
2001-11-21 23:33:14 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>pg_get_viewdef</function>(<parameter>viewOID</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get CREATE VIEW command for view</entry>
2002-04-18 22:01:11 +02:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>pg_get_ruledef</function>(<parameter>ruleOID</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get CREATE RULE command for rule</entry>
2001-11-21 23:33:14 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>pg_get_indexdef</function>(<parameter>indexOID</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get CREATE INDEX command for index</entry>
2001-11-21 23:33:14 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>pg_get_userbyid</function>(<parameter>userid</parameter>)</entry>
<entry><type>name</type></entry>
<entry>Get user name given ID</entry>
2001-11-19 04:58:25 +01:00
</row>
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
2001-11-21 23:33:14 +01:00
<primary>pg_get_viewdef</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_get_ruledef</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_get_indexdef</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>pg_get_userbyid</primary>
2001-11-19 04:58:25 +01:00
</indexterm>
<para>
2001-11-21 23:33:14 +01:00
These functions extract information from the system catalogs.
2002-06-11 17:32:33 +02:00
<function>pg_get_viewdef()</function>, <function>pg_get_ruledef()</function>, and
<function>pg_get_indexdef()</function> respectively reconstruct the creating
2001-11-21 23:33:14 +01:00
command for a view, rule, or index. (Note that this is a decompiled
reconstruction, not the verbatim text of the command.)
2002-06-11 17:32:33 +02:00
<function>pg_get_userbyid()</function> extracts a user's name given a
<structfield>usesysid</structfield> value.
2001-11-19 04:58:25 +01:00
</para>
2001-12-27 22:36:57 +01:00
<table>
2002-06-11 17:32:33 +02:00
<title>Comment Information Functions</title>
2001-12-27 22:36:57 +01:00
<tgroup cols="3">
<thead>
2002-06-11 17:32:33 +02:00
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
2001-12-27 22:36:57 +01:00
</thead>
<tbody>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>obj_description</function>(<parameter>objectOID</parameter>, <parameter>tablename</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get comment for a database object</entry>
2001-12-27 22:36:57 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>obj_description</function>(<parameter>objectOID</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get comment for a database object (<emphasis>deprecated</emphasis>)</entry>
2001-12-27 22:36:57 +01:00
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>col_description</function>(<parameter>tableOID</parameter>, <parameter>columnnumber</parameter>)</entry>
<entry><type>text</type></entry>
<entry>Get comment for a table column</entry>
2001-12-27 22:36:57 +01:00
</row>
</tbody>
</tgroup>
</table>
<indexterm zone="functions-misc">
<primary>obj_description</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>col_description</primary>
</indexterm>
<para>
These functions extract comments previously stored with the
2002-06-11 17:32:33 +02:00
<command>COMMENT</command> command. <literal>NULL</literal> is returned if
2001-12-27 22:36:57 +01:00
no comment can be found matching the specified parameters.
</para>
<para>
2002-06-11 17:32:33 +02:00
The two-parameter form of <function>obj_description()</function> returns the
2001-12-27 22:36:57 +01:00
comment for a database object specified by its OID and the name of the
containing system catalog. For example,
2002-06-11 17:32:33 +02:00
<literal>obj_description(123456,'pg_class')</literal>
2001-12-27 22:36:57 +01:00
would retrieve the comment for a table with OID 123456.
2002-06-11 17:32:33 +02:00
The one-parameter form of <function>obj_description()</function> requires only
2001-12-27 22:36:57 +01:00
the object OID. It is now deprecated since there is no guarantee that
OIDs are unique across different system catalogs; therefore, the wrong
comment could be returned.
</para>
<para>
2002-06-11 17:32:33 +02:00
<function>col_description()</function> returns the comment for a table column,
2001-12-27 22:36:57 +01:00
which is specified by the OID of its table and its column number.
2002-06-11 17:32:33 +02:00
<function>obj_description()</function> cannot be used for table columns since
2001-12-27 22:36:57 +01:00
columns do not have OIDs of their own.
</para>
2000-09-19 20:18:04 +02:00
</sect1>
2000-06-20 20:04:18 +02:00
2000-12-14 23:30:56 +01:00
<sect1 id="functions-aggregate">
<title>Aggregate Functions</title>
2000-06-20 20:04:18 +02:00
2000-12-14 23:30:56 +01:00
<note>
<title>Author</title>
2000-06-20 20:04:18 +02:00
<para>
2000-12-14 23:30:56 +01:00
Written by Isaac Wilcox <email>isaac@azartmedia.com</email> on 2000-06-16
2000-06-20 20:04:18 +02:00
</para>
2000-12-14 23:30:56 +01:00
</note>
2000-06-20 20:04:18 +02:00
2000-12-14 23:30:56 +01:00
<para>
<firstterm>Aggregate functions</firstterm> compute a single result
value from a set of input values. The special syntax
considerations for aggregate functions are explained in <xref
2002-06-11 17:32:33 +02:00
linkend="syntax-aggregates">. Consult the <citetitle>PostgreSQL
2000-12-14 23:30:56 +01:00
Tutorial</citetitle> for additional introductory information.
</para>
2000-07-17 05:52:28 +02:00
2000-12-14 23:30:56 +01:00
<table tocentry="1">
<title>Aggregate Functions</title>
2000-07-17 05:52:28 +02:00
2000-12-14 23:30:56 +01:00
<tgroup cols="3">
<thead>
<row>
<entry>Function</entry>
<entry>Description</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
2002-05-13 21:22:06 +02:00
<entry>avg(<replaceable class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>the average (arithmetic mean) of all input values</entry>
<entry>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>average</primary>
<secondary>function</secondary>
</indexterm>
2000-12-14 23:30:56 +01:00
Finding the average value is available on the following data
types: <type>smallint</type>, <type>integer</type>,
<type>bigint</type>, <type>real</type>, <type>double
precision</type>, <type>numeric</type>, <type>interval</type>.
The result is of type <type>numeric</type> for any integer type
2002-01-07 03:29:15 +01:00
input, <type>double precision</type> for floating-point input,
2000-12-14 23:30:56 +01:00
otherwise the same as the input data type.
</entry>
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>count</function>(*)</entry>
2000-12-14 23:30:56 +01:00
<entry>number of input values</entry>
2001-08-15 00:21:59 +02:00
<entry>The return value is of type <type>bigint</type>.</entry>
2000-12-14 23:30:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>count</function>(<replaceable class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>
Counts the input values for which the value of <replaceable
2002-06-11 17:32:33 +02:00
class="parameter">expression</replaceable> is not NULL.
2000-12-14 23:30:56 +01:00
</entry>
2001-08-15 00:21:59 +02:00
<entry>The return value is of type <type>bigint</type>.</entry>
2000-12-14 23:30:56 +01:00
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>max</function>(<replaceable class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>the maximum value of <replaceable class="parameter">expression</replaceable> across all input values</entry>
<entry>
Available for all numeric, string, and date/time types. The
result has the same type as the input expression.
</entry>
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>min</function>(<replaceable class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>the minimum value of <replaceable class="parameter">expression</replaceable> across all input values</entry>
<entry>
Available for all numeric, string, and date/time types. The
result has the same type as the input expression.
</entry>
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>stddev</function>(<replaceable
class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>the sample standard deviation of the input values</entry>
<entry>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>standard deviation</primary>
</indexterm>
2000-12-14 23:30:56 +01:00
Finding the standard deviation is available on the following
data types: <type>smallint</type>, <type>integer</type>,
<type>bigint</type>, <type>real</type>, <type>double
precision</type>, <type>numeric</type>. The result is of type
2002-01-07 03:29:15 +01:00
<type>double precision</type> for floating-point input,
2000-12-14 23:30:56 +01:00
otherwise <type>numeric</type>.
</entry>
</row>
<row>
2001-09-09 19:21:59 +02:00
<entry><function>sum</function>(<replaceable class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>sum of <replaceable class="parameter">expression</replaceable> across all input values</entry>
<entry>
Summation is available on the following data types:
<type>smallint</type>, <type>integer</type>,
<type>bigint</type>, <type>real</type>, <type>double
precision</type>, <type>numeric</type>, <type>interval</type>.
2001-08-15 00:21:59 +02:00
The result is of type <type>bigint</type> for <type>smallint</type>
or <type>integer</type> input, <type>numeric</type> for
<type>bigint</type>
2002-01-07 03:29:15 +01:00
input, <type>double precision</type> for floating-point input,
2000-12-14 23:30:56 +01:00
otherwise the same as the input data type.
</entry>
</row>
<row>
2002-06-11 17:32:33 +02:00
<entry><function>variance</function>(<replaceable
class="parameter">expression</replaceable>)</entry>
2000-12-14 23:30:56 +01:00
<entry>the sample variance of the input values</entry>
<entry>
2001-05-13 00:51:36 +02:00
<indexterm>
<primary>variance</primary>
</indexterm>
2000-12-14 23:30:56 +01:00
The variance is the square of the standard deviation. The
2001-08-15 00:21:59 +02:00
supported data types and result types are the same as for
standard deviation.
2000-12-14 23:30:56 +01:00
</entry>
</row>
</tbody>
</tgroup>
</table>
2000-07-17 05:52:28 +02:00
2000-12-14 23:30:56 +01:00
<para>
It should be noted that except for <function>COUNT</function>,
these functions return NULL when no rows are selected. In
particular, <function>SUM</function> of no rows returns NULL, not
2001-08-15 00:21:59 +02:00
zero as one might expect. <function>COALESCE</function> may be
used to substitute zero for NULL when necessary.
2000-12-14 23:30:56 +01:00
</para>
2000-07-17 05:52:28 +02:00
2000-12-14 23:30:56 +01:00
</sect1>
2000-07-17 05:52:28 +02:00
2001-12-01 05:19:20 +01:00
<sect1 id="functions-subquery">
<title>Subquery Expressions</title>
<indexterm>
<primary>exists</primary>
</indexterm>
<indexterm>
<primary>in</primary>
</indexterm>
<indexterm>
<primary>not in</primary>
</indexterm>
<indexterm>
<primary>any</primary>
</indexterm>
<indexterm>
<primary>all</primary>
</indexterm>
<indexterm>
<primary>some</primary>
</indexterm>
<indexterm>
<primary>subqueries</primary>
</indexterm>
<para>
This section describes the <acronym>SQL</acronym>-compliant subquery
expressions available in <productname>PostgreSQL</productname>.
All of the expression forms documented in this section return
Boolean (true/false) results.
</para>
<bridgehead renderas="sect2">EXISTS</bridgehead>
<synopsis>
EXISTS ( <replaceable>subquery</replaceable> )
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The argument of <token>EXISTS</token> is an arbitrary SELECT statement,
or <firstterm>subquery</firstterm>. The
2001-12-01 05:19:20 +01:00
subquery is evaluated to determine whether it returns any rows.
2002-06-11 17:32:33 +02:00
If it returns at least one row, the result of <token>EXISTS</token> is
TRUE; if the subquery returns no rows, the result of <token>EXISTS</token>
2001-12-01 05:19:20 +01:00
is FALSE.
</para>
<para>
The subquery can refer to variables from the surrounding query,
which will act as constants during any one evaluation of the subquery.
</para>
<para>
The subquery will generally only be executed far enough to determine
whether at least one row is returned, not all the way to completion.
It is unwise to write a subquery that has any side-effects (such as
calling sequence functions); whether the side-effects occur or not
may be difficult to predict.
</para>
<para>
Since the result depends only on whether any rows are returned,
and not on the contents of those rows, the output list of the
subquery is normally uninteresting. A common coding convention is
to write all EXISTS tests in the form
2002-06-11 17:32:33 +02:00
<literal>EXISTS(SELECT 1 WHERE ...)</literal>. There are exceptions to
this rule however, such as subqueries that use <token>INTERSECT</token>.
2001-12-01 05:19:20 +01:00
</para>
<para>
This simple example is like an inner join on col2, but it produces at
most one output row for each tab1 row, even if there are multiple matching
tab2 rows:
<screen>
SELECT col1 FROM tab1
WHERE EXISTS(SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
</screen>
</para>
<bridgehead renderas="sect2">IN (scalar form)</bridgehead>
<synopsis>
2002-06-11 17:32:33 +02:00
<replaceable>expression</replaceable> IN
<replaceable>ble>value</replaceable><optional>, ...</optional>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>IN</token> is a parenthesized list
2001-12-01 05:19:20 +01:00
of scalar expressions. The result is TRUE if the left-hand expression's
result is equal to any of the right-hand expressions. This is a shorthand
notation for
<synopsis>
<replaceable>expression</replaceable> = <replaceable>value1</replaceable>
OR
<replaceable>expression</replaceable> = <replaceable>value2</replaceable>
OR
...
</synopsis>
Note that if the left-hand expression yields NULL, or if there are
no equal right-hand values and at least one right-hand expression yields
2002-06-11 17:32:33 +02:00
NULL, the result of the <token>IN</token> construct will be NULL, not FALSE.
2001-12-01 05:19:20 +01:00
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<note>
<para>
2002-06-11 17:32:33 +02:00
This form of <token>IN</token> is not truly a subquery expression, but it
seems best to document it in the same place as subquery <token>IN</token>.
2001-12-01 05:19:20 +01:00
</para>
</note>
<bridgehead renderas="sect2">IN (subquery form)</bridgehead>
<synopsis>
<replaceable>expression</replaceable> IN (<replaceable>subquery</replaceable>)
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>IN</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly one column. The left-hand expression
is evaluated and compared to each row of the subquery result.
2002-06-11 17:32:33 +02:00
The result of <token>IN</token> is TRUE if any equal subquery row is found.
2001-12-01 05:19:20 +01:00
The result is FALSE if no equal row is found (including the special
case where the subquery returns no rows).
</para>
<para>
Note that if the left-hand expression yields NULL, or if there are
no equal right-hand values and at least one right-hand row yields
2002-06-11 17:32:33 +02:00
NULL, the result of the <token>IN</token> construct will be NULL, not FALSE.
2001-12-01 05:19:20 +01:00
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<para>
2002-06-11 17:32:33 +02:00
As with <token>EXISTS</token>, it's unwise to assume that the subquery will
2001-12-01 05:19:20 +01:00
be evaluated completely.
</para>
<synopsis>
2002-06-11 17:32:33 +02:00
(<replaceable>expression</replaceable>,
<replaceable>ble>expres</replaceable><optional>nal>,</optional>nal>)
IN (<replaceable>subquery</replaceable>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>IN</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly as many columns as there are
expressions in the left-hand list. The left-hand expressions are
evaluated and compared row-wise to each row of the subquery result.
2002-06-11 17:32:33 +02:00
The result of <token>IN</token> is TRUE if any equal subquery row is found.
2001-12-01 05:19:20 +01:00
The result is FALSE if no equal row is found (including the special
case where the subquery returns no rows).
</para>
<para>
As usual, NULLs in the expressions or subquery rows are combined per
2002-01-20 23:19:57 +01:00
the normal rules of SQL Boolean expressions. Two rows are considered
2001-12-01 05:19:20 +01:00
equal if all their corresponding members are non-null and equal; the rows
are unequal if any corresponding members are non-null and unequal;
otherwise the result of that row comparison is unknown (NULL).
If all the row results are either unequal or NULL, with at least one NULL,
2002-06-11 17:32:33 +02:00
then the result of <token>IN</token> is NULL.
2001-12-01 05:19:20 +01:00
</para>
<bridgehead renderas="sect2">NOT IN (scalar form)</bridgehead>
<synopsis>
2002-06-11 17:32:33 +02:00
<replaceable>expression</replaceable> NOT IN
<replaceable>ble>value</replaceable><optional>, ...</optional>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>NOT IN</token> is a parenthesized list
2001-12-01 05:19:20 +01:00
of scalar expressions. The result is TRUE if the left-hand expression's
result is unequal to all of the right-hand expressions. This is a shorthand
notation for
<synopsis>
<replaceable>expression</replaceable> <> <replaceable>value1</replaceable>
AND
<replaceable>expression</replaceable> <> <replaceable>value2</replaceable>
AND
...
</synopsis>
Note that if the left-hand expression yields NULL, or if there are
no equal right-hand values and at least one right-hand expression yields
2002-06-11 17:32:33 +02:00
NULL, the result of the <token>NOT IN</token> construct will be NULL, not TRUE
2001-12-01 05:19:20 +01:00
as one might naively expect.
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<tip>
<para>
2002-06-11 17:32:33 +02:00
<literal>x NOT IN y</literal> is equivalent to <literal>NOT (x IN y)</literal> in all
2001-12-01 05:19:20 +01:00
cases. However, NULLs are much more likely to trip up the novice when
2002-06-11 17:32:33 +02:00
working with <token>NOT IN</token> than when working with <token>IN</token>.
2001-12-01 05:19:20 +01:00
It's best to express your condition positively if possible.
</para>
</tip>
<bridgehead renderas="sect2">NOT IN (subquery form)</bridgehead>
<synopsis>
<replaceable>expression</replaceable> NOT IN (<replaceable>subquery</replaceable>)
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>NOT IN</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly one column. The left-hand expression
is evaluated and compared to each row of the subquery result.
2002-06-11 17:32:33 +02:00
The result of <token>NOT IN</token> is TRUE if only unequal subquery rows
2001-12-01 05:19:20 +01:00
are found (including the special case where the subquery returns no rows).
The result is FALSE if any equal row is found.
</para>
<para>
Note that if the left-hand expression yields NULL, or if there are
no equal right-hand values and at least one right-hand row yields
2002-06-11 17:32:33 +02:00
NULL, the result of the <token>NOT IN</token> construct will be NULL, not TRUE.
2001-12-01 05:19:20 +01:00
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<para>
2002-06-11 17:32:33 +02:00
As with <token>EXISTS</token>, it's unwise to assume that the subquery will
2001-12-01 05:19:20 +01:00
be evaluated completely.
</para>
<synopsis>
2002-06-11 17:32:33 +02:00
(<replaceable>expression</replaceable>,
<replaceable>ble>expres</replaceable><optional>nal>,</optional>nal>)
NOT IN (<replaceable>subquery</replaceable>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>NOT IN</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly as many columns as there are
expressions in the left-hand list. The left-hand expressions are
evaluated and compared row-wise to each row of the subquery result.
2002-06-11 17:32:33 +02:00
The result of <token>NOT IN</token> is TRUE if only unequal subquery rows
2001-12-01 05:19:20 +01:00
are found (including the special case where the subquery returns no rows).
The result is FALSE if any equal row is found.
</para>
<para>
As usual, NULLs in the expressions or subquery rows are combined per
2002-01-20 23:19:57 +01:00
the normal rules of SQL Boolean expressions. Two rows are considered
2001-12-01 05:19:20 +01:00
equal if all their corresponding members are non-null and equal; the rows
are unequal if any corresponding members are non-null and unequal;
otherwise the result of that row comparison is unknown (NULL).
If all the row results are either unequal or NULL, with at least one NULL,
2002-06-11 17:32:33 +02:00
then the result of <token>NOT IN</token> is NULL.
2001-12-01 05:19:20 +01:00
</para>
<bridgehead renderas="sect2">ANY</bridgehead>
<synopsis>
2002-06-11 17:32:33 +02:00
<replaceable>expression</replaceable>
<replaceable>ble>oper</replaceable>ble> ANY (<replaceable>subquery</replaceable>)
<replaceable>expression</replaceable>
<replaceable>ble>oper</replaceable>ble> SOME (<replaceable>subquery</replaceable>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>ANY</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly one column. The left-hand expression
is evaluated and compared to each row of the subquery result using the
2002-01-20 23:19:57 +01:00
given <replaceable>operator</replaceable>, which must yield a Boolean
2001-12-01 05:19:20 +01:00
result.
2002-06-11 17:32:33 +02:00
The result of <token>ANY</token> is TRUE if any true result is obtained.
2001-12-01 05:19:20 +01:00
The result is FALSE if no true result is found (including the special
case where the subquery returns no rows).
</para>
<para>
2002-06-11 17:32:33 +02:00
<token>SOME</token> is a synonym for <token>ANY</token>.
<token>IN</token> is equivalent to <literal>= ANY</literal>.
2001-12-01 05:19:20 +01:00
</para>
<para>
Note that if there are no successes and at least one right-hand row yields
2002-06-11 17:32:33 +02:00
NULL for the operator's result, the result of the <token>ANY</token> construct
2001-12-01 05:19:20 +01:00
will be NULL, not FALSE.
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<para>
2002-06-11 17:32:33 +02:00
As with <token>EXISTS</token>, it's unwise to assume that the subquery will
2001-12-01 05:19:20 +01:00
be evaluated completely.
</para>
<synopsis>
2002-06-11 17:32:33 +02:00
(<replaceable>expression</replaceable>,
<replaceable>ble>expres</replaceable><optional>nal>,</optional>optiona<replaceable>aceable></replaceable>aceable> ANY (<replaceable>subquery</replaceable>)
(<replaceable>expression</replaceable>,
<replaceable>ble>expres</replaceable><optional>nal>,</optional>optiona<replaceable>aceable></replaceable>aceable> SOME (<replaceable>subquery</replaceable>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>ANY</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly as many columns as there are
expressions in the left-hand list. The left-hand expressions are
evaluated and compared row-wise to each row of the subquery result,
using the given <replaceable>operator</replaceable>. Presently,
2002-06-11 17:32:33 +02:00
only <literal>=</literal> and <literal><></literal> operators are allowed
in row-wise <token>ANY</token> queries.
The result of <token>ANY</token> is TRUE if any equal or unequal row is
2001-12-01 05:19:20 +01:00
found, respectively.
The result is FALSE if no such row is found (including the special
case where the subquery returns no rows).
</para>
<para>
As usual, NULLs in the expressions or subquery rows are combined per
2002-01-20 23:19:57 +01:00
the normal rules of SQL Boolean expressions. Two rows are considered
2001-12-01 05:19:20 +01:00
equal if all their corresponding members are non-null and equal; the rows
are unequal if any corresponding members are non-null and unequal;
otherwise the result of that row comparison is unknown (NULL).
2002-06-11 17:32:33 +02:00
If there is at least one NULL row result, then the result of <token>ANY</token>
2001-12-01 05:19:20 +01:00
cannot be FALSE; it will be TRUE or NULL.
</para>
<bridgehead renderas="sect2">ALL</bridgehead>
<synopsis>
2002-06-11 17:32:33 +02:00
<replaceable>expression</replaceable>
<replaceable>ble>oper</replaceable>ble> ALL (<replaceable>subquery</replaceable>)
2001-12-01 05:19:20 +01:00
</synopsis>
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>ALL</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly one column. The left-hand expression
is evaluated and compared to each row of the subquery result using the
2002-01-20 23:19:57 +01:00
given <replaceable>operator</replaceable>, which must yield a Boolean
2001-12-01 05:19:20 +01:00
result.
2002-06-11 17:32:33 +02:00
The result of <token>ALL</token> is TRUE if all rows yield TRUE
2001-12-01 05:19:20 +01:00
(including the special case where the subquery returns no rows).
The result is FALSE if any false result is found.
</para>
<para>
2002-06-11 17:32:33 +02:00
<token>NOT IN</token> is equivalent to <literal><> ALL</literal>.
2001-12-01 05:19:20 +01:00
</para>
<para>
Note that if there are no failures but at least one right-hand row yields
2002-06-11 17:32:33 +02:00
NULL for the operator's result, the result of the <token>ALL</token> construct
2001-12-01 05:19:20 +01:00
will be NULL, not TRUE.
This is in accordance with SQL's normal rules for Boolean combinations
of NULL values.
</para>
<para>
2002-06-11 17:32:33 +02:00
As with <token>EXISTS</token>, it's unwise to assume that the subquery will
2001-12-01 05:19:20 +01:00
be evaluated completely.
</para>
2002-06-11 17:32:33 +02:00
<synopsis>
2001-12-01 05:19:20 +01:00
(<replaceable>expression</replaceable>, <replaceable>expression</replaceable><optional>, ...</optional>) <replaceable>operator</replaceable> ALL (<replaceable>subquery</replaceable>)
2002-06-11 17:32:33 +02:00
</synopsis>
2001-12-01 05:19:20 +01:00
<para>
2002-06-11 17:32:33 +02:00
The right-hand side of this form of <token>ALL</token> is a parenthesized
2001-12-01 05:19:20 +01:00
subquery, which must return exactly as many columns as there are
expressions in the left-hand list. The left-hand expressions are
evaluated and compared row-wise to each row of the subquery result,
using the given <replaceable>operator</replaceable>. Presently,
2002-06-11 17:32:33 +02:00
only <literal>=</literal> and <literal><></literal> operators are allowed
in row-wise <token>ALL</token> queries.
The result of <token>ALL</token> is TRUE if all subquery rows are equal
2001-12-01 05:19:20 +01:00
or unequal, respectively (including the special
case where the subquery returns no rows).
The result is FALSE if any row is found to be unequal or equal,
respectively.
</para>
<para>
As usual, NULLs in the expressions or subquery rows are combined per
2002-01-20 23:19:57 +01:00
the normal rules of SQL Boolean expressions. Two rows are considered
2001-12-01 05:19:20 +01:00
equal if all their corresponding members are non-null and equal; the rows
are unequal if any corresponding members are non-null and unequal;
otherwise the result of that row comparison is unknown (NULL).
2002-06-11 17:32:33 +02:00
If there is at least one NULL row result, then the result of <token>ALL</token>
2001-12-01 05:19:20 +01:00
cannot be TRUE; it will be FALSE or NULL.
</para>
<bridgehead renderas="sect2">Row-wise comparison</bridgehead>
2002-06-11 17:32:33 +02:00
<synopsis>
2001-12-01 05:19:20 +01:00
(<replaceable>expression</replaceable>, <replaceable>expression</replaceable><optional>, ...</optional>) <replaceable>operator</replaceable> (<replaceable>subquery</replaceable>)
2002-06-11 17:32:33 +02:00
(<replaceable>expression</replaceable>, <replaceable>expression</replaceable><optional>, ...</optional>) <replaceable>operator</replaceable> (<replaceable>expression</replaceable> <replaceable>expression</replaceable><optional>, ...</optional>)
</synopsis>
2001-12-01 05:19:20 +01:00
<para>
The left-hand side is a list of scalar expressions. The right-hand side
can be either a list of scalar expressions of the same length, or a
parenthesized subquery, which must return exactly as many columns as there
are expressions on the left-hand side. Furthermore, the subquery cannot
return more than one row. (If it returns zero rows, the result is taken to
be NULL.) The left-hand side is evaluated and compared row-wise to the
single subquery result row, or to the right-hand expression list.
2002-06-11 17:32:33 +02:00
Presently, only <literal>=</literal> and <literal><></literal> operators are allowed
2001-12-01 05:19:20 +01:00
in row-wise comparisons.
The result is TRUE if the two rows are equal or unequal, respectively.
</para>
<para>
As usual, NULLs in the expressions or subquery rows are combined per
2002-01-20 23:19:57 +01:00
the normal rules of SQL Boolean expressions. Two rows are considered
2001-12-01 05:19:20 +01:00
equal if all their corresponding members are non-null and equal; the rows
are unequal if any corresponding members are non-null and unequal;
otherwise the result of the row comparison is unknown (NULL).
</para>
</sect1>
2000-12-14 23:30:56 +01:00
</chapter>
1998-07-08 15:53:15 +02:00
1999-01-19 17:11:18 +01:00
<!-- Keep this comment at the end of the file
Local variables:
2000-03-31 00:22:41 +02:00
mode:sgml
1999-05-12 09:32:47 +02:00
sgml-omittag:nil
1999-01-19 17:11:18 +01:00
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
2000-03-31 00:22:41 +02:00
sgml-local-catalogs:("/usr/lib/sgml/catalog")
1999-01-19 17:11:18 +01:00
sgml-local-ecat-files:nil
End:
-->