Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Jeff Greif" <jgreif at befree dot com>
Subject: Re: single quotes and perl
Date: Jan 12 2001 5:37PM

single quotes and perlThis is not a Perl question, but an SQL question.  To include a single quote in a value of a char() or varchar() column of the database table, you construct an sql string exactly as the docs you cite say, that is:

insert people (name,age) values ('John O''Connor', 28)

This inserts a single-quote into the name field between O and C.

I've never tried it, but I presume the same must be true for values of columns of type text.

  ----- Original Message ----- 
  From: Tanja Davidson 
  To: SybPerl Discussion List 
  Sent: Friday, January 12, 2001 9:02 AM
  Subject: single quotes and perl

  I've got a newbie perl programmer question. 

  I've been using sybase::Ctlib to do my database connections and all has 
  gone fine until I realized that there's a problem with single quotes if 
  they exist in the text fields of my web forms. 

  Can anyone give me a work around for inserting and searching on text 
  variables which may have embedded single quotes?  

  The docs I've found so far have said to $var=~s/'/''/g but that ends up 
  inserting two single quotes into my database which is unacceptable.  

  This should be a fairly simple question for any guru who has done much 
  perl programming with sybase databases and the web. 

  Thanks in advance!