You are here: Re: Sequential Number in an Update « MsSQL Server « IT news, forums, messages
Re: Sequential Number in an Update

Posted by Hugo Kornelis on 10/30/06 23:20

On 30 Oct 2006 12:50:05 -0800, --CELKO-- wrote:

>>> I would really like to know how you would validate this as a URL (or email address) in a constraint. <<
>
>I would Google it and find this website, which is full of handy regular
>expressions for my constraints. This page gives ten answers.
>
>http://regexlib.com/Search.aspx?k=URL
>
>I guess cowboys post first and Google later :)

Hi Joe,

I guess cowboys don't google for regexp when they have to work with a
product that doesn't support them.

>>> The only way you are going to write a safe constraint like this is to use regular expressions and for that you'll need CLR. <<
>
>No CLR, Tony. You need the SIMILAR TO operator in SQL-92

Unfortunately, not implemented in MS SQL Server. Let's for arguments
sake assume that the client wants his database done BEFORE Microsoft
launches the next major release of SQL Server.

> or a vendor
>grep() functions such as Oracle and DB2 have.

No, NO, NO!!!!! You still don't understand it, do you?

The proprietary features change from release to release (BIT with and
without NULL, etc.) . Whatever a proprietary feature does is
determined by the vendor. Standard SQL is external and eventually the
vendor has to come into alignment.

Standard code means that another programmer can read and maintain it --
a great threat to Cowboy Coders who depend on tricks in the dialect to
hold their job. But maintainable code is one of the marks of a
professional.

Standard code means that the DB can be moved to another platform with
minimal effort -- another great threat to Cowboy Coders who speak only
in one dialect. Portable code is another marks of a professional.

We do not even write compilers or OS in assembly languages any more.
The lowest level languages used for those tasks is Standard C. Gee,
did you ever wonder why nobody is takign advantage of all the neat
hardware level "documented proprietary features" they coudl be using?

So DON'T use the proprietary grep() functions if you want to look like a
professional. Only cowboy coders would do that. Real professionals use
ANSI standard code only!

BTW, grep() is not implemented in MS SQL Server either, so even if you
do want to become a cowboy coder, you're still out of luck in this case.

> In SQL Server, you will
>still have an ugly translation today.

Yep. And I believe that was what Tony was asking you about. A question
that you appear to be attempting to dodge, by drowning your lack of a
real answer in lots of words.

So I'll join in the challenge - how would your constraint look like if
it _has_ to work on MS SQL Server 2005?

Here's mine:
CHECK (Assemblies.ValidURL(ColumnWithURL) = 'valid')
where Assemblies.ValidURL is a small, well-documented and carefully
managed CLR function that uses one of the regexps you so conveniently
located for me to do the actual check.

>The way people verify a URL is to send an email to it. It is like
>having a GPS tool or sextant to verify a (long, lat) location.

Funny. Each time I try to send e-mail to http://www.google.com, Outlook
Express complains that the address is not okay. Probably not a valid
URL, then.

--
Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация