Re: [GENERAL] NULL concatenation

From: Sridhar N Bamandlapally <sridhar(dot)bn1(at)gmail(dot)com>
To: Adam Pearson <adam(dot)pearson(at)realisticgames(dot)co(dot)uk>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>, PostgreSQL-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] NULL concatenation
Date: 2016-05-13 03:15:46
Message-ID: CAGuFTBUvBt7amn93psJFpJOmjkq_8k6LBUSkh2=oxMRQvM82+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi Adam

we need simple concatenation of all variables(which values may come NULL or
valid-values based on functional process),

coalesce is different functionality

Thanks
Sridhar
OpenText

On Thu, May 12, 2016 at 4:56 PM, Adam Pearson <
adam(dot)pearson(at)realisticgames(dot)co(dot)uk> wrote:

> Hello Sridhar,
>
> Have you tried the 'coalesce' function to handle the nulls?
>
>
> Kind Regards,
>
> Adam Pearson
> ------------------------------
> *From:* pgsql-general-owner(at)postgresql(dot)org <
> pgsql-general-owner(at)postgresql(dot)org> on behalf of Sridhar N Bamandlapally <
> sridhar(dot)bn1(at)gmail(dot)com>
> *Sent:* 12 May 2016 09:47
> *To:* PG-General Mailing List; PostgreSQL-hackers
> *Subject:* [GENERAL] NULL concatenation
>
> 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
>
> Please
>
> Thanks
> Sridhar
> OpenText
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Viswanath 2016-05-13 04:22:00 Re: Update or Delete causes canceling of long running slave queries
Previous Message Marc Mamin 2016-05-12 22:11:24 Re: Thoughts on "Love Your Database"

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2016-05-13 04:13:37 Re: [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan)
Previous Message David G. Johnston 2016-05-13 03:09:29 Re: Keeping CURRENT_DATE and similar constructs in original format