Re: Trouble Escaping Quotes

Поиск
Список
Период
Сортировка
От Haron, Charles
Тема Re: Trouble Escaping Quotes
Дата
Msg-id 593E515C9586D511BB4500010283D5E2025649A9@COG-MAIL
обсуждение исходный текст
Ответ на Trouble Escaping Quotes  ("Haron, Charles" <charles.haron@cognitive.com>)
Ответы Re: Trouble Escaping Quotes
Список pgsql-admin
Yes, but how do you escape the quote when the value of the string isn't know
until the function is run?

If $rma_data->{\'company_name\'} is returning Bob's Fixit at run time, how
do escape the quote BEFORE Perl interprets the string and generates an
error?

Regards,
Chuck

> -----Original Message-----
> From: Joshua D. Drake [mailto:jd@commandprompt.com]
> Sent: Thursday, January 20, 2005 3:12 PM
> To: Haron, Charles
> Cc: pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] Trouble Escaping Quotes
>
> 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
>
>

В списке pgsql-admin по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: [GENERAL] Restoring fscked up postgres 7.1
Следующее
От: Kristaps Armanis
Дата:
Сообщение: Re: [GENERAL] Restoring fscked up postgres 7.1