]> begriffs open source - ai-pg/blob - full-docs/man3/SPI_cursor_open_with_args.3
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man3 / SPI_cursor_open_with_args.3
1 '\" t
2 .\"     Title: SPI_cursor_open_with_args
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "SPI_CURSOR_OPEN_WITH_ARGS" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 SPI_cursor_open_with_args \- set up a cursor using a query and parameters
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 Portal SPI_cursor_open_with_args(const char *\fIname\fR,
36                                  const char *\fIcommand\fR,
37                                  int \fInargs\fR, Oid *\fIargtypes\fR,
38                                  Datum *\fIvalues\fR, const char *\fInulls\fR,
39                                  bool \fIread_only\fR, int \fIcursorOptions\fR)
40 .fi
41 .SH "DESCRIPTION"
42 .PP
43 \fBSPI_cursor_open_with_args\fR
44 sets up a cursor (internally, a portal) that will execute the specified query\&. Most of the parameters have the same meanings as the corresponding parameters to
45 \fBSPI_prepare_cursor\fR
46 and
47 \fBSPI_cursor_open\fR\&.
48 .PP
49 For one\-time query execution, this function should be preferred over
50 \fBSPI_prepare_cursor\fR
51 followed by
52 \fBSPI_cursor_open\fR\&. If the same command is to be executed with many different parameters, either method might be faster, depending on the cost of re\-planning versus the benefit of custom plans\&.
53 .PP
54 The passed\-in parameter data will be copied into the cursor\*(Aqs portal, so it can be freed while the cursor still exists\&.
55 .PP
56 This function is now deprecated in favor of
57 \fBSPI_cursor_parse_open\fR, which provides equivalent functionality using a more modern API for handling query parameters\&.
58 .SH "ARGUMENTS"
59 .PP
60 const char * \fIname\fR
61 .RS 4
62 name for portal, or
63 NULL
64 to let the system select a name
65 .RE
66 .PP
67 const char * \fIcommand\fR
68 .RS 4
69 command string
70 .RE
71 .PP
72 int \fInargs\fR
73 .RS 4
74 number of input parameters ($1,
75 $2, etc\&.)
76 .RE
77 .PP
78 Oid * \fIargtypes\fR
79 .RS 4
80 an array of length
81 \fInargs\fR, containing the
82 OIDs of the data types of the parameters
83 .RE
84 .PP
85 Datum * \fIvalues\fR
86 .RS 4
87 an array of length
88 \fInargs\fR, containing the actual parameter values
89 .RE
90 .PP
91 const char * \fInulls\fR
92 .RS 4
93 an array of length
94 \fInargs\fR, describing which parameters are null
95 .sp
96 If
97 \fInulls\fR
98 is
99 NULL
100 then
101 \fBSPI_cursor_open_with_args\fR
102 assumes that no parameters are null\&. Otherwise, each entry of the
103 \fInulls\fR
104 array should be
105 \*(Aq\ \&\*(Aq
106 if the corresponding parameter value is non\-null, or
107 \*(Aqn\*(Aq
108 if the corresponding parameter value is null\&. (In the latter case, the actual value in the corresponding
109 \fIvalues\fR
110 entry doesn\*(Aqt matter\&.) Note that
111 \fInulls\fR
112 is not a text string, just an array: it does not need a
113 \*(Aq\e0\*(Aq
114 terminator\&.
115 .RE
116 .PP
117 bool \fIread_only\fR
118 .RS 4
119 true
120 for read\-only execution
121 .RE
122 .PP
123 int \fIcursorOptions\fR
124 .RS 4
125 integer bit mask of cursor options; zero produces default behavior
126 .RE
127 .SH "RETURN VALUE"
128 .PP
129 Pointer to portal containing the cursor\&. Note there is no error return convention; any error will be reported via
130 \fBelog\fR\&.