On Tue, Sep 27, 2016 at 2:31 PM, Patrick B wrote:
> 2016-09-28 10:25 GMT+13:00 Patrick B :
>
>>
>> Actually I can't use name_last or name_first because some of the rows
> have name_last/name_first = null
>
> I'm inserting more columns that I shown:
>
> CREATE TABLE
>> public.not_monthly
>>
2016-09-28 10:25 GMT+13:00 Patrick B :
>
>
> 2016-09-28 10:11 GMT+13:00 Kevin Grittner :
>
>> On Tue, Sep 27, 2016 at 3:33 PM, Patrick B
>> wrote:
>>
>> > 4 - Get the table_1.c_id from the STEP NUMBER 2 and put it into
>> table_2.c_id
>> > - This is the problem.. how can I get the inserted id fro
2016-09-28 10:11 GMT+13:00 Kevin Grittner :
> On Tue, Sep 27, 2016 at 3:33 PM, Patrick B
> wrote:
>
> > 4 - Get the table_1.c_id from the STEP NUMBER 2 and put it into
> table_2.c_id
> > - This is the problem.. how can I get the inserted id from STEP2 and put
> it
> > into c_id respecting the ord
On Tue, Sep 27, 2016 at 3:33 PM, Patrick B wrote:
> 4 - Get the table_1.c_id from the STEP NUMBER 2 and put it into table_2.c_id
> - This is the problem.. how can I get the inserted id from STEP2 and put it
> into c_id respecting the order?
For DML you need to think of the data as being unordere
2016-09-28 9:23 GMT+13:00 Kevin Grittner :
> On Tue, Sep 27, 2016 at 2:59 PM, Patrick B
> wrote:
>
> [sel is a relation which can have multiple rows; the fact that it
> is being generated in a CTE isn't relevant for purposes of the
> error.]
>
> UPDATE table_2 SET c_id =
> (
> SE
On Tue, Sep 27, 2016 at 2:59 PM, Patrick B wrote:
[sel is a relation which can have multiple rows; the fact that it
is being generated in a CTE isn't relevant for purposes of the
error.]
UPDATE table_2 SET c_id =
(
SELECT c_id
FROM sel
ORDER BY c_id
)
WHE
On Tue, Sep 27, 2016 at 1:10 PM, Igor Neyman wrote:
>
>
> Patrick,
>
>
>
> You need to explain your problems in more “coherent” way, David suggested
> one.
>
> If you aren’t willing, people will stop responding to your request, they
> are not obligated to read your mind.
>
>
>
I'll put it this
From: pgsql-general-ow...@postgresql.org
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Patrick B
Sent: Tuesday, September 27, 2016 4:00 PM
To: David G. Johnston
Cc: pgsql-general
Subject: Re: [GENERAL] Update two tables returning id from insert CTE Query
2016-09-28 8:54 GMT+13:00
2016-09-28 8:54 GMT+13:00 David G. Johnston :
> On Mon, Sep 26, 2016 at 9:06 PM, Patrick B
> wrote:
>
>>
>> I'm doing this now:
>>
>>
>> sel AS (
>>> SELECT i.id AS c_id
>>> FROM (select id, row_number() OVER (ORDER BY id) AS rn FROM ins_table_1)
>>> i
>>> JOIN rows s USING (rn)
>>> )
>>> UPDATE
On Mon, Sep 26, 2016 at 9:06 PM, Patrick B wrote:
>
> I'm doing this now:
>
>
> sel AS (
>> SELECT i.id AS c_id
>> FROM (select id, row_number() OVER (ORDER BY id) AS rn FROM ins_table_1) i
>> JOIN rows s USING (rn)
>> )
>> UPDATE table_2 SET c_id =
>> (
>> SELECT c_id
>> FROM sel
>> ORDER
2016-09-28 0:29 GMT+13:00 Vitaly Burovoy :
> On 9/26/16, Patrick B wrote:
> > 2016-09-27 16:22 GMT+13:00 Patrick B :
> > I'm doing this now:
> >
> > sel AS (
> >> SELECT i.id AS c_id
> >> FROM (select id, row_number() OVER (ORDER BY id) AS rn FROM ins_table_1)
> >> i
> >> JOIN rows s USING (rn)
>
On 9/26/16, Patrick B wrote:
> 2016-09-27 16:22 GMT+13:00 Patrick B :
> I'm doing this now:
>
> sel AS (
>> SELECT i.id AS c_id
>> FROM (select id, row_number() OVER (ORDER BY id) AS rn FROM ins_table_1)
>> i
>> JOIN rows s USING (rn)
>> )
>> UPDATE table_2 SET c_id =
>> (
>> SELECT c_id
>> FR
On 9/26/16, Patrick B wrote:
> Hi guys,
>
> I've got 2k rows in a table:
...
> So I'd imagine now I would do the update? How can I update table_2.c_id
> with the ins_table_1.id value?
> I'm using Postgres 9.2
>
> Thanks
> Patrick
>
Hello,
It is not possible to change one row more than once by
2016-09-27 16:22 GMT+13:00 Patrick B :
> Hi guys,
>
> I've got 2k rows in a table:
>
>> CREATE TABLE
>> public.not_monthly
>> (
>> id BIGINT DEFAULT "nextval"('"id_seq"'::"regclass") NOT NULL,
>> clientid BIGINT,
>> name_first CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING
Hi guys,
I've got 2k rows in a table:
> CREATE TABLE
> public.not_monthly
> (
> id BIGINT DEFAULT "nextval"('"id_seq"'::"regclass") NOT NULL,
> clientid BIGINT,
> name_first CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING,
> name_last CHARACTER VARYING(80) DEFAULT ''::
15 matches
Mail list logo