1DBLINK_BUILD_SQL_DELETE(3)PostgreSQL 14.3 DocumentatioDnBLINK_BUILD_SQL_DELETE(3)
2
3
4

NAME

6       dblink_build_sql_delete - builds a DELETE statement using supplied
7       values for primary key field values
8

SYNOPSIS

10       dblink_build_sql_delete(text relname,
11                               int2vector primary_key_attnums,
12                               integer num_primary_key_atts,
13                               text[] tgt_pk_att_vals_array) returns text
14

DESCRIPTION

16       dblink_build_sql_delete can be useful in doing selective replication of
17       a local table to a remote database. It builds an SQL DELETE command
18       that will delete the row with the given primary key values.
19

ARGUMENTS

21       relname
22           Name of a local relation, for example foo or myschema.mytab.
23           Include double quotes if the name is mixed-case or contains special
24           characters, for example "FooBar"; without quotes, the string will
25           be folded to lower case.
26
27       primary_key_attnums
28           Attribute numbers (1-based) of the primary key fields, for example
29           1 2.
30
31       num_primary_key_atts
32           The number of primary key fields.
33
34       tgt_pk_att_vals_array
35           Values of the primary key fields to be used in the resulting DELETE
36           command. Each field is represented in text form.
37

RETURN VALUE

39       Returns the requested SQL statement as text.
40

NOTES

42       As of PostgreSQL 9.0, the attribute numbers in primary_key_attnums are
43       interpreted as logical column numbers, corresponding to the column's
44       position in SELECT * FROM relname. Previous versions interpreted the
45       numbers as physical column positions. There is a difference if any
46       column(s) to the left of the indicated column have been dropped during
47       the lifetime of the table.
48

EXAMPLES

50           SELECT dblink_build_sql_delete('"MyFoo"', '1 2', 2, '{"1", "b"}');
51                      dblink_build_sql_delete
52           ---------------------------------------------
53            DELETE FROM "MyFoo" WHERE f1='1' AND f2='b'
54           (1 row)
55
56
57
58PostgreSQL 14.3                      2022           DBLINK_BUILD_SQL_DELETE(3)
Impressum