Skip site navigation (1) Skip section navigation (2)

AW: What is the difference between NULL and "undef"

From: "Rudolph, Michael" <Michael(dot)Rudolph(at)telekom(dot)de>
To: "'Michael A(dot) Mayo'" <mmayo(at)mcauleybrooklyn(dot)org>
Cc: "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: AW: What is the difference between NULL and "undef"
Date: 2000-05-19 08:34:02
Message-ID: EB8366869DABD2119F3200A0C9F02CC8016544EC@U8P27 (view raw or flat)
Thread:
Lists: pgsql-sql
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(at)mcauleybrooklyn(dot)org]
Gesendet am: Donnerstag, 18. Mai 2000 23:10
An: Rudolph, Michael; 'Alessio Bragadini'
Cc: pgsql-sql(at)postgresql(dot)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


pgsql-sql by date

Next:From: Hiroshi InoueDate: 2000-05-19 11:28:17
Subject: Re: Re: [SQL] Foreign keys breaks tables permissions
Previous:From: Tom LaneDate: 2000-05-19 03:38:19
Subject: Re: [SQL] Foreign keys breaks tables permissions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group