Re: RE: How do I select composite array element that satisfy specific conditions.

From: a <372660931(at)qq(dot)com>
To: Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: RE: How do I select composite array element that satisfy specific conditions.
Date: 2018-05-23 12:23:26
Message-ID: tencent_17E2400AC635EDCADCBFF84141305C957506@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for your reply.......

Honestly I do not use java and don't really know json. All I understand is that it is a text format that allow some customization.

However, as long as it can solve my problem, I'm happy to learn it.

now I do have a complex structure of data to store. what I'm aiming at is to:

1, orgnize the data so that it has hierarchy and structrues for people to operate.

2, all updates, insertion, will be recorded (including who, when, for what reason and which element changed from what to what).
currently I wrote a C trigger to dynamically disassemble the complex structure and compare them one by one and generate a string that printing out every change along with the update user info.

since my amount of data are not that big and the trigger is written in C, the final efficient is considerablly accepted. Now my question would be if json would be helpful on creating a relative efficient mechanism on that......


---Original---
From: "Charles Clavadetscher"<clavadetscher(at)swisspug(dot)org>
Date: Wed, May 23, 2018 19:29 PM
To: "'pgsql-general'"<pgsql-general(at)postgresql(dot)org>;"'a'"<372660931(at)qq(dot)com>;
Subject: RE: How do I select composite array element that satisfy specific conditions.

Hi

> -----Original Message-----
> From: a [mailto:372660931(at)qq(dot)com]
> Sent: Mittwoch, 23. Mai 2018 11:43
> To: pgsql-general <pgsql-general(at)postgresql(dot)org>
> Subject: How do I select composite array element that satisfy specific conditions.
>
> Hi, say if I have composite type and table
>
> create type A as(
> x float8,
> y float8
> );
>
> create table B(
> Ay A[]
> );
>
> insert into B
> values(array[
> (1,2)::A,
> (3,4)::A]
> );
>
> How could I select the element of Ay that satisfy x=3??
>
> Thank you so much!!
>
> Shore

I did not really follow this thread, so I am not in clear, why you want to complicate your life that much.
You create a custom data type and then use it in an array in a column. A complex hierarchical structure.
Why don't you simply use JSON or JSONB? Your example sounds terribly academic very much like a school assignment.

Bye
Charles

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-05-23 13:13:45 Re: [GENERAL] Postgre compatible version with RHEL 7.5
Previous Message Charles Clavadetscher 2018-05-23 11:29:12 RE: How do I select composite array element that satisfy specific conditions.