Обсуждение: Please HELP: insert row ...

Поиск
Список
Период
Сортировка

Please HELP: insert row ...

От
"Thu Huynh"
Дата:
Hello,

Does anyone know how to insert/update data that contains single quote (')
into a field? Data such as: John's house is in Dalas.

I know one can insert double quote by using single quotes as field
delimiters.  But since I have to use single quotes as field delimiters, data
cannot contain single quote.  Is there a way to change the field delimiter?

Thanks for your helps.

Thu.

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.


Re: Please HELP: insert row ...

От
John McKown
Дата:
Simply double the qoute mark.

INSERT INTO table (name) VALUES('John''s house is in Dalas');

On Sat, 14 Oct 2000, Thu Huynh wrote:

> Hello,
>
> Does anyone know how to insert/update data that contains single quote (')
> into a field? Data such as: John's house is in Dalas.
>
> I know one can insert double quote by using single quotes as field
> delimiters.  But since I have to use single quotes as field delimiters, data
> cannot contain single quote.  Is there a way to change the field delimiter?
>
> Thanks for your helps.
>
> Thu.
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>


Re: Please HELP: insert row ...

От
Charles Curley
Дата:
On Sat, Oct 14, 2000 at 04:15:11AM +0000, Thu Huynh wrote:
> Hello,
>
> Does anyone know how to insert/update data that contains single quote (')
> into a field? Data such as: John's house is in Dalas.
>
> I know one can insert double quote by using single quotes as field
> delimiters.  But since I have to use single quotes as field delimiters, data
> cannot contain single quote.  Is there a way to change the field delimiter?

Try escaping the single quote you want to put into the database.

'John\'s house is in Dalas'

--

        -- C^2

No windows were crashed in the making of this email.

Looking for fine software and/or web pages?
http://w3.trib.com/~ccurley
Вложения

Re: Please HELP: insert row ...

От
"Albert REINER"
Дата:
On Sat, Oct 14, 2000 at 04:15:11AM +0000, Thu Huynh wrote:
> Hello,
>
> Does anyone know how to insert/update data that contains single quote (')
> into a field? Data such as: John's house is in Dalas.

Via Perl, I always wrap any strings with the following sub (adapted
from a similar sub of mmusic by ChLorenz@csi.com, and incorporating
advice from this list (David Rugge, 1 Aug 1999, and some
experimentation).

sub stdstr {
    my $or = $_[0];
    $or =~ s /\\/\\\\/g;
    $or =~ s /\'/\\\'/g;
    $or =~ s /\"/\\\"/g;
    $or =~ s /%/\\%/g;
    return $or;
}

Basically you have to quote \ ' " % (even though I am no longer sure
about the reasons for some of these; but quoting certainly cannot do
any harm). Works for me.

HTH,

Albert.


--

--------------------------------------------------------------------------
Albert Reiner                                   <areiner@tph.tuwien.ac.at>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------