Re: Unique UUID value - PostgreSQL 9.2

From: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>, James Keener <jim(at)jimkeener(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unique UUID value - PostgreSQL 9.2
Date: 2016-03-17 01:32:07
Message-ID: CAE_gQfWMqiKWK5NUD+Uef=6awGVf6p=-tn2QmO0zzEw-rsxEpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry guys... *WRONG *email

On 17 March 2016 at 14:29, drum(dot)lucas(at)gmail(dot)com <drum(dot)lucas(at)gmail(dot)com>
wrote:

>
>>>
>> SELECT ​'test_'​ || substring(uuid_generate_v4()::text, 1, 1);
>>
>> Or use a sequence, or just compute "ROW_NUMBER() OVER ()" and tack that
>> on.
>>
>> David J.
>> ​
>>
>>
> Well.. I was able to do it by using:
>
>> INSERT INTO dm.billables_links (billable_id) VALUES ((SELECT billable_id
>> FROM junk.wm_260_billables2 WHERE info ilike '%Alisha%')),
>> INSERT INTO dm.billables_links (mobiuser_id) VALUES ((SELECT id FROM
>> public.ja_mobiusers WHERE name_first LIKE 'Alisha%' AND name_last LIKE
>> 'Dson%'))
>
>
>
> The problem is that I need to do that at the same time, because of a
> constraint:
>
> ALTER TABLE dm.billables_links
> ADD CONSTRAINT cc_one_and_only_one_target CHECK ((("customer_id" IS NOT NULL)::integer + ("role_id" IS NOT NULL)::integer + ("mobiuser_id" IS NOT NULL)::integer) = 1);
>
> I'm having trouble by creating that SQL... can anyone help please?
>
> FYI - It has to be in the same transaction because the mobiuser_id must go
> to the selected billable_id on the first select.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message drum.lucas@gmail.com 2016-03-17 01:34:19 Insert data in two columns same table
Previous Message drum.lucas@gmail.com 2016-03-17 01:29:40 Re: Unique UUID value - PostgreSQL 9.2