pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedFixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
4+ messages / 3 participants
[nested] [flat]
* Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
@ 2020-04-02 14:48 Andrus <kobruleht2@hot.ee>
0 siblings, 1 reply; 4+ messages in thread
From: Andrus @ 2020-04-02 14:48 UTC (permalink / raw)
To: pgsql-general
Hi!
After upgrading to Postgres 12 statement
update temprid set
ContactFirstName =unnest(xpath(
'/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x))::text,
yhik =unnest(xpath(
'/E-Document/Document/DocumentItem/ItemEntry/BaseUnit/text()',x))::text
from t
throws error
set-returning functions are not allowed in UPDATE
How to fix this ?
Maybe there is simply change which makes this statement work ?
Result should by any value of xpath expression in case if xpath returns
multiple values
In Postgres 9.1 it worked.
Andrus.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
@ 2020-04-02 14:57 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Andrus <kobruleht2@hot.ee>
0 siblings, 1 reply; 4+ messages in thread
From: Laurenz Albe @ 2020-04-02 14:57 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; pgsql-general
On Thu, 2020-04-02 at 17:48 +0300, Andrus wrote:
> After upgrading to Postgres 12 statement
>
> update temprid set
> ContactFirstName =unnest(xpath(
> '/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x))::text,
> yhik =unnest(xpath(
> '/E-Document/Document/DocumentItem/ItemEntry/BaseUnit/text()',x))::text
> from t
>
> throws error
>
> set-returning functions are not allowed in UPDATE
>
> How to fix this ?
Simply replace
SET col = unnest(array_value)
with
SET col = array_value[1]
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
@ 2020-04-03 06:37 Andrus <kobruleht2@hot.ee>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 4+ messages in thread
From: Andrus @ 2020-04-03 06:37 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Hi!
>Simply replace
> SET col = unnest(array_value)
>with
>
> SET col = array_value[1]
I tried
update temprid set
ContactFirstName =xpath(
'/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x)[1]::text
But got error
ERROR: syntax error at or near "["
LINE 3: .../BuyerParty/ContactData/ContactFirstName/text()',x)[1]::text
How to fix ?
Posted also in
https://stackoverflow.com/questions/60993975/fixing-set-returning-functions-are-not-allowed-in-updat...
Andrus.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
@ 2020-04-03 07:17 David G. Johnston <david.g.johnston@gmail.com>
parent: Andrus <kobruleht2@hot.ee>
0 siblings, 0 replies; 4+ messages in thread
From: David G. Johnston @ 2020-04-03 07:17 UTC (permalink / raw)
To: Andrus <kobruleht2@hot.ee>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
On Thu, Apr 2, 2020 at 11:38 PM Andrus <kobruleht2@hot.ee> wrote:
> Hi!
>
> >Simply replace
> > SET col = unnest(array_value)
> >with
> >
> > SET col = array_value[1]
>
> I tried
>
>
> update temprid set
> ContactFirstName =xpath(
>
> '/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x)[1]::text
>
>
Parens around the function call expression are required per the syntax
documentation for array subscript access:
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-EXPRESSIONS-SUBSCRIPTS
update temprid set
ContactFirstName =(xpath(
'/E-Document/Document/DocumentParties/BuyerParty/ContactData/ContactFirstName/text()',x)
)[1]::text
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-04-03 07:17 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 14:48 Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12 Andrus <kobruleht2@hot.ee>
2020-04-02 14:57 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-04-03 06:37 ` Andrus <kobruleht2@hot.ee>
2020-04-03 07:17 ` David G. Johnston <david.g.johnston@gmail.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