1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>9.18.Set Returning Functions</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="functions.html" title="Chapter9.Functions and Operators">
<link rel="prev" href="functions-comparisons.html" title="9.17.Row and Array Comparisons">
<link rel="next" href="functions-info.html" title="9.19.System Information Functions">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="functions-srf"></a>9.18.Set Returning Functions</h2></div></div></div>
<a name="id621146"></a><a name="id621159"></a><p> This section describes functions that possibly return more than one row.
Currently the only functions in this class are series generating functions,
as detailed in <a href="functions-srf.html#functions-srf-series" title="Table9.38.Series Generating Functions">Table9.38, “Series Generating Functions”</a>.
</p>
<div class="table">
<a name="functions-srf-series"></a><p class="title"><b>Table9.38.Series Generating Functions</b></p>
<div class="table-contents"><table summary="Series Generating Functions" border="1">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>Function</th>
<th>Argument Type</th>
<th>Return Type</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><code class="literal"><code class="function">generate_series</code>(<em class="parameter"><code>start</code></em>, <em class="parameter"><code>stop</code></em>)</code></td>
<td>
<code class="type">int</code> or <code class="type">bigint</code>
</td>
<td>
<code class="type">setof int</code> or <code class="type">setof bigint</code> (same as argument type)</td>
<td> Generate a series of values, from <em class="parameter"><code>start</code></em> to <em class="parameter"><code>stop</code></em>
with a step size of one
</td>
</tr>
<tr>
<td><code class="literal"><code class="function">generate_series</code>(<em class="parameter"><code>start</code></em>, <em class="parameter"><code>stop</code></em>, <em class="parameter"><code>step</code></em>)</code></td>
<td>
<code class="type">int</code> or <code class="type">bigint</code>
</td>
<td>
<code class="type">setof int</code> or <code class="type">setof bigint</code> (same as argument type)</td>
<td> Generate a series of values, from <em class="parameter"><code>start</code></em> to <em class="parameter"><code>stop</code></em>
with a step size of <em class="parameter"><code>step</code></em>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p> When <em class="parameter"><code>step</code></em> is positive, zero rows are returned if
<em class="parameter"><code>start</code></em> is greater than <em class="parameter"><code>stop</code></em>.
Conversely, when <em class="parameter"><code>step</code></em> is negative, zero rows are
returned if <em class="parameter"><code>start</code></em> is less than <em class="parameter"><code>stop</code></em>.
Zero rows are also returned for <code class="literal">NULL</code> inputs. It is an error
for <em class="parameter"><code>step</code></em> to be zero. Some examples follow:
</p>
<pre class="programlisting">select * from generate_series(2,4);
generate_series
-----------------
2
3
4
(3 rows)
select * from generate_series(5,1,-2);
generate_series
-----------------
5
3
1
(3 rows)
select * from generate_series(4,3);
generate_series
-----------------
(0 rows)
select current_date + s.a as dates from generate_series(0,14,7) as s(a);
dates
------------
2004-02-05
2004-02-12
2004-02-19
(3 rows)</pre>
<p>
</p>
</div></body>
</html>
|