PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: jander at lehman dot com (Jim Anderson)
Subject: Re: char or varchar
Date: Feb 27 1996 3:10PM

> Hmm, still having problems implementing this.  Here's my simple scenario:
> $tmp = "It's a small world"
> $db->dbcmd ("insert into foo (column1) values ($tmp)");
> 
> Now this by itself will generate:
> 	insert into foo (column1) values (It's a small world)
> 
> so, I've been manually putting quotes on via:
> 	$tmp = "'" . $tmp . "'"
> 
> but this generates:
> 	insert into foo (column1) values ('It's a small world')
> 
> which gives me a database error.  I've tried the following by itself:
> 	$tmp = $db->dbsafestr($tmp)
> 
> but that gave me:
> 	insert into foo (column1) values (It''s a small world)
> 
> So then I did both:
> 	$tmp = "'" . $tmp . "'"
> 	$tmp = $db->dbsafestr($tmp)
> 	$dbcmd ("insert ..... ")
> 
> but that just gave me:
> 	insert into foo (column1) values (''It''s a small world'')
> 
> Obviously I'm doing something wrong here.  Any suggestions?
> 
> Thanks,
> Angie

	$tmp = $db->dbsafestr($tmp)
	$tmp = "'" . $tmp . "'"
	$dbcmd ("insert ..... ")


On Feb 26,  3:08pm, Craig Kim wrote:
> Subject: char or varchar
> If you're generating HTML with sybperl, you can use &dbsafestr() to
> condition the string so that every (') becomes (''') and (") (""").  Or
> you can write a function to do it!
>
> --Craig
>
> Begin forwarded message:
>
> X-Listname: SybPerl Discussion List 
> Warnings-To: <>
> Sender: owner-sybperl-l@trln.lib.unc.edu
> From: "Angie Lin" 
> Reply-To: SYBPERL-L@trln.lib.unc.edu
> Date: Mon, 26 Feb 1996 11:17:27 -0800
> To: SYBPERL-L@trln.lib.unc.edu
> Subject: char or varchar
>
> I have a sybperl script which takes the input from an HTML form and
> performs an insertion into my database.  I'm encountering problems with
> char and varchar datatypes, however.
>
> Currently, I am manually appending and prepending the quote (') to the
> string which I want to insert into the database.  But if the string
> itself has a quote ('), then the insertion aborts with the error:
>
>     Sybase message 105, Severity 15, state 1
>     Line 1
>     Unclosed quote before the character string ' ) '.
>
> Likewise, manually appending and prepending the double-quote (") will
> get me into the same trouble because my data string might have both
> single and/or double-quotes.
>
> What's the solution?  Am I going about this the entirely wrong way by
manually
> putting the quotes on myself?
>
> Thanks,
> Angie
>-- End of excerpt from Craig Kim




-- 
Jim Anderson					Phone:  (201)524-4076
Lehman Brothers, Inc.				Fax:	(201)524-5153 
101 Hudson Street, 34th Floor			E-mail: jander@lehman.com
Jersey City, NJ 07302					jander@jander.com