Received: from rly-ip01.mx.aol.com (rly-ip01.mx.aol.com [205.188.156.49]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA01822 for ; Thu, 18 May 2000 17:14:56 -0400 (EDT) (envelope-from mmayo@mcauleybrooklyn.org) Received: from tot-wf1-we.proxy.aol.com (tot-wf1-we.proxy.aol.com [205.188.195.3]) by rly-ip01.mx.aol.com (8.8.8/8.8.8/AOL-5.0.0) with ESMTP id RAA13815; Thu, 18 May 2000 17:13:59 -0400 (EDT) Received: from 362197428 (AC81B974.ipt.aol.com [172.129.185.116]) by tot-wf1-we.proxy.aol.com (8.10.0/8.10.0) with ESMTP id e4ILDvp18118; Thu, 18 May 2000 17:13:58 -0400 (EDT) Message-ID: <00ff01bfc10d$63b057a0$1138b798@362197428> From: "Michael A. Mayo" To: "Rudolph, Michael" , "'Alessio Bragadini'" Cc: References: Subject: Re: What is the difference between NULL and "undef" Date: Thu, 18 May 2000 17:09:42 -0400 Organization: Brooklyn College MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Apparently-From: PerlWebGuy@aol.com X-Archive-Number: 200005/70 ----- Original Message ----- > > If I set the variable $var3 > in line 5 in quotes, NULL wouldn't be interpreted in the right way. > That solution works now, but it seems to me a bit fussy. And it is > a lot of testing and transforming, when there are a lot of date- > variables in the program. Oops...I missed this last part. If you don't want to have to do the quoting yourself, use the quote() method and make any empty strings undef instead NULL. $database = connect(); $name = $database->quote($var); $database->do("insert into employees(name) values $var"); if $var is undef, it inserts null, if not it properly quotes the string, including escaping any nasty characters it might include like the apostrophe. In the future, you might want to post questions like this to the dbi-users list; you are more likely to get help there. Also, you may want to take a look at the book "Programming the Perl DBI," or, if you are more harcore, try the command "perldoc DBI." This stuff is pretty well documented in both those resources. -Mike