]> begriffs open source - ai-pg/blob - full-docs/man3/dblink_build_sql_delete.3
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man3 / dblink_build_sql_delete.3
1 '\" t
2 .\"     Title: dblink_build_sql_delete
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 "DBLINK_BUILD_SQL_DELETE" "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 dblink_build_sql_delete \- builds a DELETE statement using supplied values for primary key field values
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 dblink_build_sql_delete(text relname,
36                         int2vector primary_key_attnums,
37                         integer num_primary_key_atts,
38                         text[] tgt_pk_att_vals_array) returns text
39 .fi
40 .SH "DESCRIPTION"
41 .PP
42 \fBdblink_build_sql_delete\fR
43 can be useful in doing selective replication of a local table to a remote database\&. It builds an SQL
44 \fBDELETE\fR
45 command that will delete the row with the given primary key values\&.
46 .SH "ARGUMENTS"
47 .PP
48 \fIrelname\fR
49 .RS 4
50 Name of a local relation, for example
51 foo
52 or
53 myschema\&.mytab\&. Include double quotes if the name is mixed\-case or contains special characters, for example
54 "FooBar"; without quotes, the string will be folded to lower case\&.
55 .RE
56 .PP
57 \fIprimary_key_attnums\fR
58 .RS 4
59 Attribute numbers (1\-based) of the primary key fields, for example
60 1 2\&.
61 .RE
62 .PP
63 \fInum_primary_key_atts\fR
64 .RS 4
65 The number of primary key fields\&.
66 .RE
67 .PP
68 \fItgt_pk_att_vals_array\fR
69 .RS 4
70 Values of the primary key fields to be used in the resulting
71 \fBDELETE\fR
72 command\&. Each field is represented in text form\&.
73 .RE
74 .SH "RETURN VALUE"
75 .PP
76 Returns the requested SQL statement as text\&.
77 .SH "NOTES"
78 .PP
79 As of
80 PostgreSQL
81 9\&.0, the attribute numbers in
82 \fIprimary_key_attnums\fR
83 are interpreted as logical column numbers, corresponding to the column\*(Aqs position in
84 SELECT * FROM relname\&. Previous versions interpreted the numbers as physical column positions\&. There is a difference if any column(s) to the left of the indicated column have been dropped during the lifetime of the table\&.
85 .SH "EXAMPLES"
86 .sp
87 .if n \{\
88 .RS 4
89 .\}
90 .nf
91 SELECT dblink_build_sql_delete(\*(Aq"MyFoo"\*(Aq, \*(Aq1 2\*(Aq, 2, \*(Aq{"1", "b"}\*(Aq);
92            dblink_build_sql_delete
93 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
94  DELETE FROM "MyFoo" WHERE f1=\*(Aq1\*(Aq AND f2=\*(Aqb\*(Aq
95 (1 row)
96 .fi
97 .if n \{\
98 .RE
99 .\}