Skip to content

Commit

Permalink
Traduction du chapitre sur les fonctions renvoyant des ensembles
Browse files Browse the repository at this point in the history
  • Loading branch information
gleu committed Oct 15, 2020
1 parent 266b0e3 commit bab9f6f
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions postgresql/func.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20747,30 +20747,31 @@ AND
</sect1>

<sect1 id="functions-srf">
<title>Set Returning Functions</title>
<title>Fonctions renvoyant des ensembles</title>

<indexterm zone="functions-srf">
<primary>set returning functions</primary>
<secondary>functions</secondary>
<primary>fonctions renvoyant des ensembles</primary>
<secondary>fonctions</secondary>
</indexterm>

<para>
This section describes functions that possibly return more than one row.
The most widely used functions in this class are series generating
functions, as detailed in <xref linkend="functions-srf-series"/> and
<xref linkend="functions-srf-subscripts"/>. Other, more specialized
set-returning functions are described elsewhere in this manual.
See <xref linkend="queries-tablefunctions"/> for ways to combine multiple
set-returning functions.
Cette section décrit les fonctions qui renvoient potentiellement plus d'une
ligne. Les fonctions les plus fréquemment utilisées de ce type sont celles
générant des séries, comme détaillées dans <xref
linkend="functions-srf-series"/> et <xref
linkend="functions-srf-subscripts"/>. D'autres, plus spécialisées, sont
décrites ailleurs dans ce manuel. Voir <xref
linkend="queries-tablefunctions"/> pour des façons de combiner plusieurs
fonctions renvoyant des ensembles.
</para>

<table id="functions-srf-series">
<title>Series Generating Functions</title>
<title>Fonctions générant des séries</title>
<tgroup cols="1">
<thead>
<row>
<entry role="func_table_entry"><para role="func_signature">
Function
Fonction
</para>
<para>
Description
Expand All @@ -20796,10 +20797,10 @@ AND
<returnvalue>setof numeric</returnvalue>
</para>
<para>
Generates a series of values from <parameter>start</parameter>
to <parameter>stop</parameter>, with a step size
of <parameter>step</parameter>. <parameter>step</parameter>
defaults to 1.
Génère une série de valeurs à partir de <parameter>start</parameter>
jusqu'à <parameter>stop</parameter>, avec un pas de
<parameter>step</parameter>. <parameter>step</parameter> a 1 pour
valeur par défaut.
</para></entry>
</row>

Expand All @@ -20813,23 +20814,23 @@ AND
<returnvalue>setof timestamp with time zone</returnvalue>
</para>
<para>
Generates a series of values from <parameter>start</parameter>
to <parameter>stop</parameter>, with a step size
of <parameter>step</parameter>.
Génère une série de valeurs à partir de <parameter>start</parameter>
jusqu'à <parameter>stop</parameter>, avec un pas de
<parameter>step</parameter>.
</para></entry>
</row>
</tbody>
</tgroup>
</table>

<para>
When <parameter>step</parameter> is positive, zero rows are returned if
<parameter>start</parameter> is greater than <parameter>stop</parameter>.
Conversely, when <parameter>step</parameter> is negative, zero rows are
returned if <parameter>start</parameter> is less than <parameter>stop</parameter>.
Zero rows are also returned if any input is <literal>NULL</literal>.
It is an error
for <parameter>step</parameter> to be zero. Some examples follow:
Quand <parameter>step</parameter> est positif, aucune ligne n'est renvoyée si
<parameter>start</parameter> est supérieure à <parameter>stop</parameter>.
Par contre, quand <parameter>step</parameter> est négatif negative, aucune ligne n'est renvoyée
si <parameter>start</parameter> est inférieur à <parameter>stop</parameter>.
Aucune ligne n'est renvoyé si au moins une entrée est <literal>NULL</literal>.
Si <parameter>step</parameter> vaut zéro, c'est considéré comme une erreur.
Voici quelques exemples&nbsp;:
<programlisting>
SELECT * FROM generate_series(2,4);
generate_series
Expand Down Expand Up @@ -20860,7 +20861,7 @@ SELECT generate_series(1.1, 4, 1.3);
3.7
(3 rows)

-- this example relies on the date-plus-integer operator:
-- cet exemple se base sur l'opérateur date-plus-integer :
SELECT current_date + s.a AS dates FROM generate_series(0,14,7) AS s(a);
dates
------------
Expand All @@ -20887,12 +20888,12 @@ SELECT * FROM generate_series('2008-03-01 00:00'::timestamp,
</para>

<table id="functions-srf-subscripts">
<title>Subscript Generating Functions</title>
<title>Fonctions générant des indices</title>
<tgroup cols="1">
<thead>
<row>
<entry role="func_table_entry"><para role="func_signature">
Function
Fonction
</para>
<para>
Description
Expand All @@ -20910,8 +20911,8 @@ SELECT * FROM generate_series('2008-03-01 00:00'::timestamp,
<returnvalue>setof integer</returnvalue>
</para>
<para>
Generates a series comprising the valid subscripts of
the <parameter>dim</parameter>'th dimension of the given array.
Génère une série comprenant les indices valides de la
<parameter>dim</parameter>-ème dimension du tableau fourni.
</para></entry>
</row>

Expand All @@ -20921,25 +20922,24 @@ SELECT * FROM generate_series('2008-03-01 00:00'::timestamp,
<returnvalue>setof integer</returnvalue>
</para>
<para>
Generates a series comprising the valid subscripts of
the <parameter>dim</parameter>'th dimension of the given array.
When <parameter>reverse</parameter> is true, returns the series in
reverse order.
Génère une série comprenant les indices valides de la
<parameter>dim</parameter>-ième dimension du tableau fourni. Quand
<parameter>reverse</parameter> vaut true, renvoie la série dans
l'ordre inverse.
</para></entry>
</row>
</tbody>
</tgroup>
</table>

<para>
<function>generate_subscripts</function> is a convenience function that generates
the set of valid subscripts for the specified dimension of the given
array.
Zero rows are returned for arrays that do not have the requested dimension,
or if any input is <literal>NULL</literal>.
Some examples follow:
<function>generate_subscripts</function> est une fonction de facilité qui génère
l'ensemble d'indices valides pour la dimension donnée pour le tableau.
Aucune ligne n'est renvoyée pour les tableaux qui n'ont pas la dimension
demandée ou si une des lignes vaut <literal>NULL</literal>.
Voici quelques exemples&nbsp;:
<programlisting>
-- basic usage:
-- utilisation basique :
SELECT generate_subscripts('{NULL,1,NULL,2}'::int[], 1) AS s;
s
---
Expand All @@ -20949,8 +20949,8 @@ SELECT generate_subscripts('{NULL,1,NULL,2}'::int[], 1) AS s;
4
(4 rows)

-- presenting an array, the subscript and the subscripted
-- value requires a subquery:
-- à partir d'un tableau, l'indice et la valeur indicée
-- nécessite une sous-requête :
SELECT * FROM arrays;
a
--------------------
Expand All @@ -20969,7 +20969,7 @@ FROM (SELECT generate_subscripts(a, 1) AS s, a FROM arrays) foo;
{100,200,300} | 3 | 300
(5 rows)

-- unnest a 2D array:
-- déballer un tableau 2D :
CREATE OR REPLACE FUNCTION unnest2(anyarray)
RETURNS SETOF anyelement AS $$
select $1[i][j]
Expand All @@ -20993,15 +20993,15 @@ SELECT * FROM unnest2(ARRAY[[1,2],[3,4]]);
</indexterm>

<para>
When a function in the <literal>FROM</literal> clause is suffixed
by <literal>WITH ORDINALITY</literal>, a <type>bigint</type> column is
appended to the function's output column(s), which starts from 1 and
increments by 1 for each row of the function's output.
This is most useful in the case of set returning
functions such as <function>unnest()</function>.
Quand une fonction dans la clause <literal>FROM</literal> a pour suffixe
<literal>WITH ORDINALITY</literal>, une colonne <type>bigint</type> est
ajoutée aux colonnes en sortie de la fonction, commençant à 1 et
s'incrémentant de 1 pour chaque ligne de la sortie de la fonction. Ceci est
plus utile dans le cas de fonctions renvoyant des ensembles comme
<function>unnest()</function>.

<programlisting>
-- set returning function WITH ORDINALITY:
-- fonction renvoyant un ensemble WITH ORDINALITY:
SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
ls | n
-----------------+----
Expand Down

0 comments on commit bab9f6f

Please sign in to comment.