AW: What is the difference between NULL and "undef"
От | Rudolph, Michael |
---|---|
Тема | AW: What is the difference between NULL and "undef" |
Дата | |
Msg-id | EB8366869DABD2119F3200A0C9F02CC8016544EC@U8P27 обсуждение исходный текст |
Список | 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@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
В списке pgsql-sql по дате отправления: