]> begriffs open source - ai-pg/blob - full-docs/txt/contrib-dblink-build-sql-delete.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / contrib-dblink-build-sql-delete.txt
1
2 dblink_build_sql_delete
3
4    dblink_build_sql_delete — builds a DELETE statement using supplied
5    values for primary key field values
6
7 Synopsis
8
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
13
14 Description
15
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
20 Arguments
21
22    relname
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.
27
28    primary_key_attnums
29           Attribute numbers (1-based) of the primary key fields, for
30           example 1 2.
31
32    num_primary_key_atts
33           The number of primary key fields.
34
35    tgt_pk_att_vals_array
36           Values of the primary key fields to be used in the resulting
37           DELETE command. Each field is represented in text form.
38
39 Return Value
40
41    Returns the requested SQL statement as text.
42
43 Notes
44
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.
51
52 Examples
53
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'
58 (1 row)