pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: cwhisperer <cwhisperer@vo.lu>
To: pgsql-sql@postgresql.org
Subject: Re: uinique identifier
Date: Sun, 26 May 2002 18:35:53 -0700
Message-ID: <00ee01c20524$89b3aad0$3200a8c0@internal> (raw)
References: <9069492264.20020526125335@vo.lu>

What's wrong with using the OID column of pg_class or the OID column of your
table?

Chris

----- Original Message -----
From: "||//::..-cwhisperer-..:://||" <cwhisperer@vo.lu>
To: <pgsql-sql@postgresql.org>
Sent: Sunday, May 26, 2002 3:53 AM
Subject: [SQL] uinique identifier


> hi,
>
> I want to create an unique identifier for all the tables in my db.
>
> as paramater I pass the length of the identifier and the table name:
>
> here my function
>
> DROP FUNCTION ui_alz_table (int4,varchar);
>
> CREATE FUNCTION ui_alz_table (int4,varchar) RETURNS varchar AS '
>
> DECLARE
> iLoop int4;
> result varchar;
> nr int4;
> query_string varchar;
>
>         BEGIN
>         result := '''';
>         nr := 1;
>
>         IF ($1>0) AND ($1 < 255) THEN
>             WHILE nr > 0 LOOP
>                FOR iLoop in 1 .. $1 LOOP
>                  result := result || chr(int4(random()*25)+65);
>                END LOOP;
>                query_string := ''Select * from ''|| $2 || '' where id = ''
|| result;
>                EXECUTE query_string;
>                IF NOT FOUND THEN
>                  nr := 0;
>                END IF;
>             END LOOP;
>             RETURN result;
>         END IF;
>         END;
> ' LANGUAGE 'plpgsql';
>
> in the for loop I create the unique identifier and  whith the
> query_string I check whetherit exists or not.
>
> but I get an error 'Attribute xxxx not found' and I don't know what to to
with it.
>
> thx for your help
>
>
>
> --
> Best regards,
>  ||//::..-cwhisperer-..:://||
mailto:cwhisperer@vo.lu
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>




view thread (3+ messages)

Message-ID: <00ee01c20524$89b3aad0$3200a8c0@internal>
Permalink:  ../00ee01c20524$89b3aad0$3200a8c0@internal/
Also on:    postgresql.org/message-id/00ee01c20524$89b3aad0$3200a8c0@internal

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chriskl@familyhealth.com.au, cwhisperer@vo.lu
  Subject: Re: uinique identifier
  In-Reply-To: <00ee01c20524$89b3aad0$3200a8c0@internal>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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