pg_escape_string

pg_escape_string — Escape a string for use in an SQL string constant

Synopsis

pg_escape_string string

Description

pg_escape_string returns its argument with added characters which makes it safe for use in single-quoted SQL string constants. Mostly it returns the string with all single quote marks and backslash characters doubled.

For example, pg_escape_string {a'b\c} returns the string a''b\\c.

Arguments

string

The string to escape.

Return Value

The string argument, with added characters.

Notes

See also pg_quote.

This command uses or emulates the PostgreSQL libpq function PQescapeString.

Caution

The original Pgtcl implementation has a command with the same name but a different return value.