in reply to Re: Re: How NOT to do it
in thread How NOT to do it

Actually no, Sybase.

You actually made me go look at the documentation. Turns out that there does exist such a function in Sybase, but it's called char_leng (talk about obvious).

In any event, there are length functions in the various SQL dialects, but there is no such beast in the SQL standard (although it's been years since I've tracked the standard closely, SQL-92 is still pretty new-fangled for me). So much for portability.


--
g r i n d e r

Replies are listed 'Best First'.
Re (tilly) 4: How NOT to do it
by tilly (Archbishop) on Mar 19, 2001 at 20:21 UTC
    But note that SQL is pretty unusual. For instance how many other programming languages do you know which, by design, are not Turing complete?

    Brownie points to the first person who can say why it is very important that SQL not be a Turing complete language. :-)

      Since no one has answered your challenge in 2 years, I'll ask:
      Why is it very important that SQL not be a Turing complete language?
      The only answer^W guess I can come up with is the rhetorical - imagine someone trying to code an OS or any complete program in a database. But I don't really know. Thanks.


      Perl programming and scheduling in the corporate world, as explained by dragonchild:
      "Uhh ... that'll take me three weeks, broken down as follows: 1 day for coding, the rest for meetings to explain why I only need 1 day for coding."
        Sorry for being slow getting back, I have been offline.

        The answer is that the database is supposed to figure out exactly what the SQL is supposed to do, and then come up with a very efficient way to do that. With a Turing-complete language it is impossible to answer detailed questions about arbitrary code, and is difficult to answer them even for normal code.

        Sure, optimizers can speed up code. But in a normal language they can't recognize a bad algorithm and rewrite it with a more efficient one. But SQL routinely is optimized to be using algorithms which are far better than any that the developer would have thought up.

        SQL could not do this if the developer had, for instance, the freedom to write a series of nested loops with possibly relevant side-effects and a difficult to discern purpose.

        It's that queries cannot be recursive. Of course, there have been a number of papers popping up here and there about Turing-complete SQL extensions.

        antirice    
        The first rule of Perl club is - use Perl
        The
        ith rule of Perl club is - follow rule i - 1 for i > 1