4
>Passing Data Values</TITLE
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PL/R User's Guide - R Procedural Language"
13
HREF="index.html"><LINK
15
TITLE="Functions and Arguments"
16
HREF="plr-funcs.html"><LINK
18
TITLE="Using Global Data"
19
HREF="plr-global-data.html"><LINK
22
HREF="stylesheet.css"><META
24
CONTENT="2003-08-25T17:44:28"></HEAD
35
SUMMARY="Header navigation table"
44
>PL/R User's Guide - R Procedural Language</TH
66
HREF="plr-global-data.html"
81
>Chapter 4. Passing Data Values</H1
83
> The argument values supplied to a PL/R function's script are
84
the input arguments converted to a corresponding R form.
86
HREF="plr-data.html#PLR-ARGS-TABLE"
89
values become single element R vectors. One-dimensional
90
PostgreSQL arrays are converted to multi-element R vectors, two-dimensional
91
PostgreSQL arrays are mapped to R matrixes, and three-dimensional
92
PostgreSQL arrays are converted to three-dimensional R arrays. Greater
93
than three-dimensional arrays are not supported. Composite-types are
94
transformed into R data.frames.
103
>Table 4-1. Function Arguments</B
202
> Conversely, the return values are first coerced to R character, and
203
therefore anything that resolves to a string that is acceptable input
204
format for the function's declared return type will produce a result.
205
Similar to argument conversion, there is also a mapping between the
206
dimensionality of the declared PostgreSQL return type and the type of
207
R object. That mapping is shown in
209
HREF="plr-data.html#PLR-DATA-RESULTS-DIMS-TABLE"
216
NAME="PLR-DATA-RESULTS-DIMS-TABLE"
220
>Table 4-2. Function Result Dimensionality</B
230
>PgSQL return type</TH
270
>first column of first row</TD
274
>c(1,2,3) in R returns 1 in PostgreSQL</TD
292
>greater than 2D array</TT
300
>multi-row, 1 column set</TD
304
>array(1:10) in R returns 10 rows in PostgreSQL</TD
324
>textual representation of the first column's vector</TD
328
>data.frame(c(1,2,3)) in R returns 'c(1, 2, 3)'</TD
354
>#columns > 1, error; #columns == 1, multi-row, 1 column set</TD
358
>(as.data.frame(array(1:10,c(2,5))))[,1] in R returns 2 rows of scalar</TD
376
>greater than 3D array</TT
388
>array(1:8,c(2,2,2,2)) in R returns {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}</TD
418
>array(1:4,c(2,2)) in R returns {{1,3},{2,4}}</TD
442
>array(1:8,c(2,2,2)) in R returns {{{1,5},{3,7}},{{2,6},{4,8}}}</TD
460
>greater than 2D array</TT
468
>first row, 1 column</TD
472
>array(1:8,c(2,2,2)) in R returns 1 row of scalar</TD
490
>greater than 2D array</TT
498
>multi-row, 1 column set</TD
502
>array(1:8,c(2,2,2)) in R returns 8 rows of scalar</TD
528
>first row, multi-column</TD
532
>array(1:4,c(2,2)) in R returns 1 row of 2 columns</TD
558
>multi-row, multi-column set</TD
562
>array(1:4,c(2,2)) in R returns 2 rows of 2 columns</TD
573
SUMMARY="Footer navigation table"
584
HREF="plr-funcs.html"
602
HREF="plr-global-data.html"
612
>Functions and Arguments</TD
622
>Using Global Data</TD
b'\\ No newline at end of file'