Re: NULL concatenation

Поиск
Список
Период
Сортировка
Искать
От
Pavel Stehule
Тема
Re: NULL concatenation
Дата
в 08:53:07
Msg-id
CAFj8pRBtkWk1=jRCXsbEFz_9fEfY5SzL4p=xnOdQsLFXX2WiSg@mail.gmail.com
Ответ на
NULL concatenation (Sridhar N Bamandlapally)
Список
Дерево обсуждения
NULL concatenation Sridhar N Bamandlapally <sridhar.bn1@gmail.com>
Re: [GENERAL] NULL concatenation Adam Pearson <adam.pearson@realisticgames.co.uk>
Re: [GENERAL] NULL concatenation Sridhar N Bamandlapally <sridhar.bn1@gmail.com>
Re: NULL concatenation Pavel Stehule <pavel.stehule@gmail.com>
Re: NULL concatenation Sridhar N Bamandlapally <sridhar.bn1@gmail.com>
Hi

2016-05-12 10:47 GMT+02:00 Sridhar N Bamandlapally <sridhar.bn1@gmail.com>:
Hi

In migration, am facing issue with NULL concatenation in plpgsql, 
by concatenating NULL between any where/position to Text / Varchar, the total string result is setting value to NULL


In Oracle:

declare
    txt1 VARCHAR2(100) := 'ABCD';
    txt2 VARCHAR2(100) := NULL;
    txt3 VARCHAR2(100) := 'EFGH';
    txt VARCHAR2(100) := NULL;
begin
  txt:= txt1 || txt2 || txt3;
  dbms_output.put_line (txt);
end;
/

abcdefgh   ===>return value



In Postgres

do $$
declare
    txt1 text := 'ABCD';
    txt2 text := NULL;
    txt3 text := 'EFGH';
    txt text := NULL;
begin
    txt:= txt1 || txt2 || txt3;
    raise notice '%', txt;
end$$ language plpgsql;

NOTICE:  <NULL>  ===> return value


SQL-Server also does same like Oracle

Is there any way alternate we have for same behavior in PostgreSQL

use function concat http://www.postgresql.org/docs/9.5/static/functions-string.html

 postgres=# select concat('AHOJ', NULL,'XXX');
 concat 
---------
 AHOJXXX
(1 row)

Regards

Pavel


Please

Thanks
Sridhar
OpenText


В списке pgsql-hackers по дате отправления
От: Sridhar N Bamandlapally
Дата:
Сообщение: NULL concatenation
От: Amit Langote
Дата:
Сообщение: Re: Declarative partitioning
FAQ