Received: from fw1b.telekom.de (gw1.telekom.de [194.25.15.11]) by hub.org (8.9.3/8.9.3) with SMTP id EAA42684 for ; Fri, 19 May 2000 04:34:51 -0400 (EDT) (envelope-from Michael.Rudolph@telekom.de) Received: by fw1b.telekom.de; (5.65v4.0/1.3/10May95) id AA22676; Fri, 19 May 2000 10:34:44 +0200 Received: from G8PXB.blf01.telekom.de by U8PW4.blf01.telekom.de with ESMTP for pgsql-sql@postgresql.org; Fri, 19 May 2000 10:34:20 +0200 Received: from u8p10.blf01.telekom.de by G8PXB.blf01.telekom.de with ESMTP; Fri, 19 May 2000 10:34:05 +0200 Received: by U8P10.blf01.telekom.de with Internet Mail Service (5.5.2650.21) id ; Fri, 19 May 2000 10:34:04 +0200 Message-Id: From: "Rudolph, Michael" To: "'Michael A. Mayo'" Cc: "'pgsql-sql@postgresql.org'" Subject: AW: What is the difference between NULL and "undef" Date: Fri, 19 May 2000 10:34:02 +0200 Mime-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id EAA42734 X-Archive-Number: 200005/77 Thank you very much for your help. Unfortunately you had only nearly the same solution as I had, so I have to accept it cannot be handled directly in SQL. Thank you too for your tip with the Perl DBI-book. I've already heard of this book and tried to get it, but it is not yet available here in germany. My application works now so far (a bit slow, but it works) and I have learned by writing the program and receiving mails a lot of programming SQL-applications. Thanks again Michael -----Ursprüngliche Nachricht----- Von: Michael A. Mayo [mailto:mmayo@mcauleybrooklyn.org] Gesendet am: Donnerstag, 18. Mai 2000 23:10 An: Rudolph, Michael; 'Alessio Bragadini' Cc: pgsql-sql@postgresql.org Betreff: Re: [SQL] What is the difference between NULL and "undef" ----- 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