pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedIs it possible to get DISTINCT rows from RETURNING clause?
4+ messages / 2 participants
[nested] [flat]
* Is it possible to get DISTINCT rows from RETURNING clause?
@ 2011-02-17 07:05 Gnanakumar <gnanam@zoniac.com>
2011-02-18 05:58 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
0 siblings, 1 reply; 4+ messages in thread
From: Gnanakumar @ 2011-02-17 07:05 UTC (permalink / raw)
To: pgsql-sql
Hi,
Is it possible to get DISTINCT rows from an UPDATE statement using RETURNING
clause?
"MYTABLE" columns are:
APRIMARYKEYCOLUMN
ABOOLEANCOLUMN
EMAIL
COLUMN1
COLUMN2
COLUMN3
UPDATE using RETURNING clause query:
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
Here in this case, I expect to return distinct rows from these columns:
EMAIL, COLUMN1, COLUMN2, COLUMN3.
I even tried out some ways of getting distinct rows, but it doesn't work.
Though I can still solve this at application layer, I'm trying to find
whether this could be controlled at query-level. Any different
ideas/suggestions are appreciated.
Regards,
Gnanam
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to get DISTINCT rows from RETURNING clause?
2011-02-17 07:05 Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
@ 2011-02-18 05:58 ` Gnanakumar <gnanam@zoniac.com>
2011-02-19 10:00 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Dmitriy Igrishin <dmitigr@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Gnanakumar @ 2011-02-18 05:58 UTC (permalink / raw)
To: pgsql-sql
Any ideas?
-----Original Message-----
From: Gnanakumar [mailto:gnanam@zoniac.com]
Sent: Thursday, February 17, 2011 12:36 PM
To: pgsql-sql@postgresql.org
Subject: Is it possible to get DISTINCT rows from RETURNING clause?
Hi,
Is it possible to get DISTINCT rows from an UPDATE statement using RETURNING
clause?
"MYTABLE" columns are:
APRIMARYKEYCOLUMN
ABOOLEANCOLUMN
EMAIL
COLUMN1
COLUMN2
COLUMN3
UPDATE using RETURNING clause query:
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
Here in this case, I expect to return distinct rows from these columns:
EMAIL, COLUMN1, COLUMN2, COLUMN3.
I even tried out some ways of getting distinct rows, but it doesn't work.
Though I can still solve this at application layer, I'm trying to find
whether this could be controlled at query-level. Any different
ideas/suggestions are appreciated.
Regards,
Gnanam
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to get DISTINCT rows from RETURNING clause?
2011-02-17 07:05 Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
2011-02-18 05:58 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
@ 2011-02-19 10:00 ` Dmitriy Igrishin <dmitigr@gmail.com>
2011-02-21 11:50 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
0 siblings, 1 reply; 4+ messages in thread
From: Dmitriy Igrishin @ 2011-02-19 10:00 UTC (permalink / raw)
To: gnanam@zoniac.com; +Cc: pgsql-sql
Hey Gnanakumar,
You can wrap you UPDATE query into SQL function returning TABLE, e.g:
CREATE OR REPLACE FUNCTION public.update_mytable()
RETURNS TABLE(email text, column1 text, column2 text, column3 text)
LANGUAGE sql
AS $function$
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
$function$;
Next you can write, e.g:
SELECT DISTINCT * FROM
(SELECT update_mytable()) AS foo(email, column1, column2, column3);
And so on.
2011/2/18 Gnanakumar <gnanam@zoniac.com>
> Any ideas?
>
> -----Original Message-----
> From: Gnanakumar [mailto:gnanam@zoniac.com]
> Sent: Thursday, February 17, 2011 12:36 PM
> To: pgsql-sql@postgresql.org
> Subject: Is it possible to get DISTINCT rows from RETURNING clause?
>
> Hi,
>
> Is it possible to get DISTINCT rows from an UPDATE statement using
> RETURNING
> clause?
>
> "MYTABLE" columns are:
> APRIMARYKEYCOLUMN
> ABOOLEANCOLUMN
> EMAIL
> COLUMN1
> COLUMN2
> COLUMN3
>
> UPDATE using RETURNING clause query:
> UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
> MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
>
> Here in this case, I expect to return distinct rows from these columns:
> EMAIL, COLUMN1, COLUMN2, COLUMN3.
>
> I even tried out some ways of getting distinct rows, but it doesn't work.
> Though I can still solve this at application layer, I'm trying to find
> whether this could be controlled at query-level. Any different
> ideas/suggestions are appreciated.
>
> Regards,
> Gnanam
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
--
// Dmitriy.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is it possible to get DISTINCT rows from RETURNING clause?
2011-02-17 07:05 Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
2011-02-18 05:58 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
2011-02-19 10:00 ` Re: Is it possible to get DISTINCT rows from RETURNING clause? Dmitriy Igrishin <dmitigr@gmail.com>
@ 2011-02-21 11:50 ` Gnanakumar <gnanam@zoniac.com>
0 siblings, 0 replies; 4+ messages in thread
From: Gnanakumar @ 2011-02-21 11:50 UTC (permalink / raw)
To: 'Dmitriy Igrishin' <dmitigr@gmail.com>; +Cc: pgsql-sql
Hi Dmitriy Igrishin,
Thanks. That's a good idea too.
From: Dmitriy Igrishin [mailto:dmitigr@gmail.com]
Sent: Saturday, February 19, 2011 3:31 PM
To: gnanam@zoniac.com
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Is it possible to get DISTINCT rows from RETURNING clause?
Hey Gnanakumar,
You can wrap you UPDATE query into SQL function returning TABLE, e.g:
CREATE OR REPLACE FUNCTION public.update_mytable()
RETURNS TABLE(email text, column1 text, column2 text, column3 text)
LANGUAGE sql
AS $function$
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
$function$;
Next you can write, e.g:
SELECT DISTINCT * FROM
(SELECT update_mytable()) AS foo(email, column1, column2, column3);
And so on.
2011/2/18 Gnanakumar <gnanam@zoniac.com>
Any ideas?
-----Original Message-----
From: Gnanakumar [mailto:gnanam@zoniac.com]
Sent: Thursday, February 17, 2011 12:36 PM
To: pgsql-sql@postgresql.org
Subject: Is it possible to get DISTINCT rows from RETURNING clause?
Hi,
Is it possible to get DISTINCT rows from an UPDATE statement using RETURNING
clause?
"MYTABLE" columns are:
APRIMARYKEYCOLUMN
ABOOLEANCOLUMN
EMAIL
COLUMN1
COLUMN2
COLUMN3
UPDATE using RETURNING clause query:
UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL =
MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3;
Here in this case, I expect to return distinct rows from these columns:
EMAIL, COLUMN1, COLUMN2, COLUMN3.
I even tried out some ways of getting distinct rows, but it doesn't work.
Though I can still solve this at application layer, I'm trying to find
whether this could be controlled at query-level. Any different
ideas/suggestions are appreciated.
Regards,
Gnanam
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
--
// Dmitriy.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2011-02-21 11:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-17 07:05 Is it possible to get DISTINCT rows from RETURNING clause? Gnanakumar <gnanam@zoniac.com>
2011-02-18 05:58 ` Gnanakumar <gnanam@zoniac.com>
2011-02-19 10:00 ` Dmitriy Igrishin <dmitigr@gmail.com>
2011-02-21 11:50 ` Gnanakumar <gnanam@zoniac.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox