<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >pg_quote</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Pgtcl Reference Manual" HREF="index.html"><LINK REL="UP" TITLE="Query Execution Commands" HREF="pgtcl-ref-query.html"><LINK REL="PREVIOUS" TITLE="pg_escape_string" HREF="pg-escape-string.html"><LINK REL="NEXT" TITLE="pg_escape_bytea" HREF="pg-escape-bytea.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2004-11-09T00:53:06"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Pgtcl Reference Manual: The PostgreSQL Tcl Interface</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="pg-escape-string.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="pg-escape-bytea.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="PG-QUOTE" ></A >pg_quote</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN1670" ></A ><H2 >Name</H2 >pg_quote -- Escape and quote a string for use in an SQL string constant</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN1673" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >pg_quote <VAR CLASS="PARAMETER" >string</VAR ></PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1676" ></A ><H2 >Description</H2 ><P ><CODE CLASS="FUNCTION" >pg_quote</CODE > returns its argument in single quotes, with added characters which makes it safe for use as an SQL string constant. That is, it returns the string in single quotes, with all internal single quote marks and backslash characters doubled. </P ><P >For example, <TT CLASS="LITERAL" >pg_quote {a'b\c}</TT > returns the string <TT CLASS="LITERAL" >'a''b\\c'</TT >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1683" ></A ><H2 >Arguments</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><VAR CLASS="REPLACEABLE" >string</VAR ></DT ><DD ><P > The string to quote and escape. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1691" ></A ><H2 >Return Value</H2 ><P > The string argument, in single quotes, with added characters. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1694" ></A ><H2 >Notes</H2 ><P > See also <A HREF="pg-escape-string.html" >pg_escape_string</A >, which returns the same thing but without the single quotes. The reason both are present is to attempt to be compatible in the face of changes to another implementation of this interface. </P ><P > This command was added in <SPAN CLASS="APPLICATION" >pgtclng-1.5.1</SPAN > and in <SPAN CLASS="APPLICATION" >pgintcl-2.1.0</SPAN >. </P ><P > This command uses or emulates the <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > <SPAN CLASS="APPLICATION" >libpq</SPAN > function <CODE CLASS="FUNCTION" >PQescapeString</CODE >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="pg-escape-string.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="pg-escape-bytea.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pg_escape_string</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="pgtcl-ref-query.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >pg_escape_bytea</TD ></TR ></TABLE ></DIV ></BODY ></HTML >