X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8C1F13A4941 for ; Thu, 20 Jan 2005 22:12:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85287-07 for ; Thu, 20 Jan 2005 22:12:00 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id CB7963A4922 for ; Thu, 20 Jan 2005 22:12:01 +0000 (GMT) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j0KMBwa8025824; Thu, 20 Jan 2005 14:11:58 -0800 Message-ID: <41F02CA4.10100@commandprompt.com> Date: Thu, 20 Jan 2005 14:11:48 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Haron, Charles" Cc: pgsql-admin@postgresql.org Subject: Re: Trouble Escaping Quotes References: <593E515C9586D511BB4500010283D5E202564942@COG-MAIL> In-Reply-To: <593E515C9586D511BB4500010283D5E202564942@COG-MAIL> Content-Type: multipart/mixed; boundary="------------040401090303090509080704" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/230 X-Sequence-Number: 16089 This is a multi-part message in MIME format. --------------040401090303090509080704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Haron, Charles wrote: > Hello, > > I'm using a perl function in my PosgreSQL database to send an email. > However, field data containing single quotes causes the function to fail. > I'm having trouble escaping the quotes. Sample function definition follows. You escape single quotes in PostgreSQL with 2 single quotes... e.g; print 'foo'; Should be: print ''foo''; (not double quotes, two single quotes) Sincerely, Joshua D. Drake > > > If company_name is Bob's Fixit, the function will fail. > > CREATE OR REPLACE FUNCTION public.send_rma(rma_info) > RETURNS void AS > ' > use Mail::Sender; > my ($rma_data) = @_; > my ($sender) = new Mail::Sender { > smtp => \'192.168.1.1\', > from => \'supp@cog.com\', > on_errors => \'die\' > }; > > $sender->Open({ > to => \'pgsql-admin@postgresql.org\', > cc => \'supp@cog.com\', > subject => "RMA Request $rma_data->{\'rma\'}" > }); > > $sender->SendLineEnc("[RMA]"); > $sender->SendLineEnc("$rma_data->{\'rma\'}"); > > $sender->SendLineEnc("[CASE NUMBER]"); > $sender->SendLineEnc("$rma_data->{\'case_number\'}"); > > $sender->SendLineEnc("[COMPANY NAME]"); > $sender->SendLineEnc("$rma_data->{\'company_name\'}"); > > $sender->Close(); > > ' > LANGUAGE 'plperlu' STABLE; > > > Thanks, > Chuck > > *********************** > > Confidentiality notice: This electronic transmission message is intended only for the use of the individual or entity to whom it is addressed. This information should be treated as proprietary, confidential, legally privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, (or the employee or agent responsible for delivering the message to the intended recipient), you are hereby notified that any use, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please immediately notify us by telephone (720) 221-9421 or by return e-mail and delete this message. Thank you for your cooperation. > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match -- Command Prompt, Inc., your source for PostgreSQL replication, professional support, programming, managed services, shared and dedicated hosting. Home of the Open Source Projects plPHP, plPerlNG, pgManage, and pgPHPtoolkit. Contact us now at: +1-503-667-4564 - http://www.commandprompt.com --------------040401090303090509080704 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------040401090303090509080704--