Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id A0DB547599C for ; Sun, 26 May 2002 22:16:45 -0400 (EDT) Received: from kennedy.calorieking.com (adsl-64-164-82-57.dsl.lsan03.pacbell.net [64.164.82.57]) by postgresql.org (Postfix) with ESMTP id E7A52475990 for ; Sun, 26 May 2002 22:16:43 -0400 (EDT) Received: (from root@localhost) by kennedy.calorieking.com (8.11.6/8.11.6) id g4R2GhP14668 for pgsql-sql@postgresql.org; Sun, 26 May 2002 19:16:43 -0700 (PDT) (envelope-from chriskl@familyhealth.com.au) Received: from fhpusa1 (work-50.internal [192.168.0.50]) by kennedy.calorieking.com (8.11.6/8.9.3) with SMTP id g4R2Gfr14535; Sun, 26 May 2002 19:16:41 -0700 (PDT) Message-ID: <00ee01c20524$89b3aad0$3200a8c0@internal> From: "Christopher Kings-Lynne" To: "cwhisperer" , References: <9069492264.20020526125335@vo.lu> Subject: Re: uinique identifier Date: Sun, 26 May 2002 18:35:53 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200205/277 X-Sequence-Number: 7912 What's wrong with using the OID column of pg_class or the OID column of your table? Chris ----- Original Message ----- From: "||//::..-cwhisperer-..:://||" To: 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 >