At 15:15 -0400 6/27/02, walt wrote:
>On Thursday 27 June 2002 02:30 pm, Mike(mickalo)Blezien wrote:
>>  Walt,
>>
>>  Use Perl's 'undef' for NULL values.
>>
>>  $quoted_some_variable = undef;
>>
>>  now the $quoted_some_variable will be a null value.
>>
>>  >>On Thu, 27 Jun 2002 12:50:55 -0400, walt <[EMAIL PROTECTED]>   wrote:
>>  >>
>>  >>I'm in the process of re-writing 100+ perl CGIs written for oracle to
>>  >> mysql.
>>  >>
>>  >>Does anyone know how to get the dbh->quote(some_value) function in perl
>>  >> to return the string "NULL" if some_value is empty. Currently its
>>  >> returning '' (2 ticks) and when you update a numeric column, it sets the
>>  >> value to 0 "zero".
><snip>
>
>Thanks for you reply Mike!
>This almost gets me where I want, but I'd still have to run a check to see if
>the value for the variable is null and that is what I'm trying to get away
>from. There are about 10 editable text fields in one the CGIs and many of
>those may be blank (user deleted the value)  in which case I'd need to update
>that column in the db to NULL. Any other ideas would be appreciated!

I don't think you can necessarily do what you want easily, although
perhaps the easiest thing to do is to convert all empty strings to undef
and insert that (which will insert NULL).  If the underlying columns are
declared as NULL, you'll end up inserting NULL.  If they are declared as
NOT NULL, you'll end up inserting the default value.  Probably in most
cases that will be an empty string for string columns and 0 for numeric
columns.

But this still won't avoid the need to check values and convert them
to under if empty.

>
>Thanks!
>--
>Walter Anthony
>System Administrator
>National Electronic Attachment
>Atlanta, Georgia
>1-800-782-5150 ext. 1608
>  "If it's not broke....tweak it"


"If it jams, force it.  If it breaks, it needed fixing anyway."

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to