regexp on null

Started by Gauthier, Daveover 15 years ago7 messagesgeneral
Jump to latest
#1Gauthier, Dave
dave.gauthier@intel.com

8.3.4 on Linux

Is there a way to regexp match on a null value? Or is it necessary to OR in a .... "or x is null"?

Thanks in Advance !

#2Dmitriy Igrishin
dmitigr@gmail.com
In reply to: Gauthier, Dave (#1)
Re: regexp on null

Hey Dave,

Did you consider to use coalesce() ?

Regards,
Dmitriy

2010/9/10 Gauthier, Dave <dave.gauthier@intel.com>

Show quoted text

8.3.4 on Linux

Is there a way to regexp match on a null value? Or is it necessary to OR
in a .... "or x is null"?

Thanks in Advance !

#3Richard Broersma
richard.broersma@gmail.com
In reply to: Gauthier, Dave (#1)
Re: regexp on null

On Fri, Sep 10, 2010 at 9:00 AM, Gauthier, Dave <dave.gauthier@intel.com> wrote:

Is there a way to regexp match on a null value?

I would say no.

  Or is it necessary to OR in a .... "or x is null"?

you could use a

COALESCE( text_column, '') ~ E'MyRegEx';

Or perhaps:
( text_column ~ E'MyRegEx' ) IS UNKNOWN
might work.

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

#4Gauthier, Dave
dave.gauthier@intel.com
In reply to: Richard Broersma (#3)
Re: regexp on null

Ya, I kinda knew about these approaches. The problem ahs to do with novice users who don't know about coalesce or or;ing a check ofr nulls. I was hoping there was some special regexp expression that would match to a null.

Thanks for the quick response, and have a great weekend !

-----Original Message-----
From: Richard Broersma [mailto:richard.broersma@gmail.com]
Sent: Friday, September 10, 2010 12:19 PM
To: Gauthier, Dave
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] regexp on null

On Fri, Sep 10, 2010 at 9:00 AM, Gauthier, Dave <dave.gauthier@intel.com> wrote:

Is there a way to regexp match on a null value?

I would say no.

  Or is it necessary to OR in a .... "or x is null"?

you could use a

COALESCE( text_column, '') ~ E'MyRegEx';

Or perhaps:
( text_column ~ E'MyRegEx' ) IS UNKNOWN
might work.

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

#5Richard Broersma
richard.broersma@gmail.com
In reply to: Gauthier, Dave (#4)
Re: regexp on null

On Fri, Sep 10, 2010 at 9:56 AM, Gauthier, Dave <dave.gauthier@intel.com> wrote:

Ya, I kinda knew about these approaches.  The problem ahs to do with novice users who don't know about coalesce or or;ing a check ofr nulls.  I was hoping there was some special regexp expression that would match to a null.

Perhaps the easiest was to help such users is to make the column(s) in
question NOT NULL DEFAULT ''.

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

#6David Fetter
david@fetter.org
In reply to: Richard Broersma (#5)
Re: regexp on null

On Fri, Sep 10, 2010 at 10:25:55AM -0700, Richard Broersma wrote:

On Fri, Sep 10, 2010 at 9:56 AM, Gauthier, Dave <dave.gauthier@intel.com> wrote:

Ya, I kinda knew about these approaches. �The problem ahs to do
with novice users who don't know about coalesce or or;ing a check
ofr nulls. �I was hoping there was some special regexp expression
that would match to a null.

Perhaps the easiest was to help such users is to make the column(s)
in question NOT NULL DEFAULT ''.

I think it's a very, very bad idea to make a default like that. I'm
aware that it's common in one of those Oracle properties, but it needs
to stay confined there.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#7Dmitriy Igrishin
dmitigr@gmail.com
In reply to: David Fetter (#6)
Re: regexp on null

Agree with David.

Regards,
Dmitriy

2010/9/10 David Fetter <david@fetter.org>

Show quoted text

On Fri, Sep 10, 2010 at 10:25:55AM -0700, Richard Broersma wrote:

On Fri, Sep 10, 2010 at 9:56 AM, Gauthier, Dave <dave.gauthier@intel.com>

wrote:

Ya, I kinda knew about these approaches. The problem ahs to do
with novice users who don't know about coalesce or or;ing a check
ofr nulls. I was hoping there was some special regexp expression
that would match to a null.

Perhaps the easiest was to help such users is to make the column(s)
in question NOT NULL DEFAULT ''.

I think it's a very, very bad idea to make a default like that. I'm
aware that it's common in one of those Oracle properties, but it needs
to stay confined there.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general