Re: Unique UUID value - PostgreSQL 9.2

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Unique UUID value - PostgreSQL 9.2
Date: 2016-03-15 02:03:11
Message-ID: 56E76D5F.7090000@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/14/2016 6:41 PM, drum(dot)lucas(at)gmail(dot)com wrote:
> So I'm doing:
>
> CREATE EXTENSION "uuid-ossp";
>
>
> INSERT INTO junk.wm_260_billables2 (account_id, code, info) SELECT
> account_id, code || '_' || nextval('uuid_generate_v4()')::text,
> info FROM junk.wm_260_billables1;
>
> Getting the error:
>
> ERROR: relation "uuid_generate_v4()" does not exist
>
>
> But the extension is working:
>
> select uuid_generate_v4() as one;
> one
> --------------------------------------
> 59ad418e-53fa-4725-aadb-8f779c1a12b2
> (1 row)
>
>
> select * from pg_available_extensions;
> uuid-ossp | 1.0 | 1.0 | generate
> universally unique identifiers (UUIDs)
>
>
> Do you know what might I being doing wrong?

nextval() takes a sequence name. not a function like uuid_generate_v4().

if you insist on using UUID (very slow to generate, very bulky), then try...

INSERT INTO junk.wm_260_billables2 (account_id, code, info) SELECT
account_id, code || '_' || uuid_generate_v4(), info FROM
junk.wm_260_billables1;

--
john r pierce, recycling bits in santa cruz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-03-15 02:57:49 Re: Unique UUID value - PostgreSQL 9.2
Previous Message drum.lucas@gmail.com 2016-03-15 01:41:41 Re: Unique UUID value - PostgreSQL 9.2