From: | "Michael A(dot) Mayo" <mmayo(at)mcauleybrooklyn(dot)org> |
---|---|
To: | "Rudolph, Michael" <Michael(dot)Rudolph(at)telekom(dot)de>, "'Alessio Bragadini'" <alessio(at)albourne(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: What is the difference between NULL and "undef" |
Date: | 2000-05-18 21:09:42 |
Message-ID: | 00ff01bfc10d$63b057a0$1138b798@362197428 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
----- 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
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Sawtell | 2000-05-18 21:18:56 | Re: Re[2]: lower() for varchar data by creating an index |
Previous Message | Kate Collins | 2000-05-18 20:46:57 | Re: SQL command speed |