Обсуждение: ...

Поиск
Список
Период
Сортировка

...

От
"Doug Smith"
Дата:
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...

Re: your mail

От
Bruce Momjian
Дата:
[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

RE:

От
"Taral"
Дата:
> 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


Re:

От
James Olin Oden
Дата:
 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