Re: uinique identifier - Mailing list pgsql-sql

From Christopher Kings-Lynne
Subject Re: uinique identifier
Date
Msg-id 00ee01c20524$89b3aad0$3200a8c0@internal
Whole thread Raw
In response to uinique identifier  ("||//::..-cwhisperer-..:://||" <cwhisperer@vo.lu>)
List pgsql-sql
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
>



pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: uinique identifier
Next
From: Achilleus Mantzios
Date:
Subject: Re: Trees in SQL