Saluton!

On Thu, Jan 25, 2001 at 11:12:34AM +0100, Markus Wagner wrote:
...
> Some of the data are strings containing the apostrophe "'" which I use
> as string delimiter.
> 
> How can I put these into my database using the INSERT statement?

I always use this sub:

    #
    # This sub adapted from sub TEXT of mmusic by [EMAIL PROTECTED], using
    # advice from the pgsql-novice mailing list (David Rugge, 1 Aug 1999).
    #
    # Do the necessary quoting for strings.
    #
    sub stdstr {
      my $or = $_[0];
      return undef unless (defined($or));
      $or =~ s /\\/\\\\/g;    # mmusic doesn't have this, nor does D. Rugge.
      $or =~ s /\'/\\\'/g;
      $or =~ s /\"/\\\"/g;
      $or =~ s /%/\\%/g;      # mmusic doesn't have this.
      return $or;
    }

Obviously you also need to escape the \. I no longer remember why "
and % are needed, but I certainly did have some reason then.

Albert.


-- 

--------------------------------------------------------------------------
Albert Reiner                                   <[EMAIL PROTECTED]>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------

Reply via email to