Thread

  1. Doug Smith <doug@the-bridge.net> — 1998-10-17T02:58:51Z

    Why is that I can only cat two variables in a select statement.
    ex. select lastname||' '||firstname||' '||address
    Delivers an parseing error at "||". When trying 
    ex. select lastnamae||firstname 
    It works fine.
    What's up?
    Doug...
    
  2. Re: your mail

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-10-18T03:37:44Z

    [Charset iso-8859-1 unsupported, filtering to ASCII...]
    > Why is that I can only cat two variables in a select statement.
    > ex. select lastname||' '||firstname||' '||address
    > Delivers an parseing error at "||". When trying 
    > ex. select lastnamae||firstname 
    > It works fine.
    > What's up?
    > Doug...
    
    It is a know problem on the TODO list.  We don't have a fix for 6.4 yet,
    and at this point, it would have to be in a post-6.4 release.  If
    someone wants to take it on, go ahead.  It is a parser problem.
    
    
    -- 
      Bruce Momjian                        |  http://www.op.net/~candle
      maillist@candle.pha.pa.us            |  (610) 853-3000
      +  If your life is a hard drive,     |  830 Blythe Avenue
      +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
    
    
  3. RE:

    Taral <taral@mail.utexas.edu> — 1998-10-18T04:30:09Z

    > ex. select lastname||' '||firstname||' '||address
    
    It's because the parser has no defined precedence for operators like ||.
    
    Try:
    
    select (((lastname || ' ') || firstname) || ' ') || address;
    
    Yes, I know it's annoying. But there's a problem with defining precedence in
    the grammar for operators like this. Sorry.
    
    Taral
    
    
    
  4. Re:

    James Oden <joden@lee.k12.nc.us> — 1998-10-19T14:41:46Z

    >  Why is that I can only cat two variables in a select statement.ex.
    > select lastname||' '||firstname||' '||address
    > Delivers an parseing error at "||". When tryingex. select
    > lastnamae||firstnameIt works fine.What's up?
    >
    > Doug...
    
    
    Hi Doug,
    
    The || operator operates more like a functiion than an operator.  What I
    mean by that is that, as you have surmised, it takes two and only two
    arguments.  This does not mean that you cannot concatenate more than two
    strings...you just need to use parenthesis in the proper way.  Your
    query would become:
    
       select ((((lastname||' ')||firstname)||' ')||address
    
    Of course you would need the rest of your query (I assume that was just
    the half that was giving you trouble).
    
    Hope this helps...james