2 dblink_build_sql_delete
4 dblink_build_sql_delete — builds a DELETE statement using supplied
5 values for primary key field values
9 dblink_build_sql_delete(text relname,
10 int2vector primary_key_attnums,
11 integer num_primary_key_atts,
12 text[] tgt_pk_att_vals_array) returns text
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.
23 Name of a local relation, for example foo or myschema.mytab.
24 Include double quotes if the name is mixed-case or contains
25 special characters, for example "FooBar"; without quotes, the
26 string will be folded to lower case.
29 Attribute numbers (1-based) of the primary key fields, for
33 The number of primary key fields.
36 Values of the primary key fields to be used in the resulting
37 DELETE command. Each field is represented in text form.
41 Returns the requested SQL statement as text.
45 As of PostgreSQL 9.0, the attribute numbers in primary_key_attnums are
46 interpreted as logical column numbers, corresponding to the column's
47 position in SELECT * FROM relname. Previous versions interpreted the
48 numbers as physical column positions. There is a difference if any
49 column(s) to the left of the indicated column have been dropped during
50 the lifetime of the table.
54 SELECT dblink_build_sql_delete('"MyFoo"', '1 2', 2, '{"1", "b"}');
55 dblink_build_sql_delete
56 ---------------------------------------------
57 DELETE FROM "MyFoo" WHERE f1='1' AND f2='b'