X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A62CED1D2CC for ; Tue, 20 Apr 2004 04:56:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11537-01 for ; Tue, 20 Apr 2004 04:56:46 -0300 (ADT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.177]) by svr1.postgresql.org (Postfix) with ESMTP id 124CDD1D08E for ; Tue, 20 Apr 2004 04:56:44 -0300 (ADT) Received: from [212.227.126.205] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BFq7Z-0005Ng-00 for pgsql-admin@postgresql.org; Tue, 20 Apr 2004 09:56:45 +0200 Received: from [212.202.168.3] (helo=DEVEL09-RO) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BFq7Z-0004yX-00 for pgsql-admin@postgresql.org; Tue, 20 Apr 2004 09:56:45 +0200 Date: Tue, 20 Apr 2004 09:56:43 +0200 From: Enrico Ortmann X-Mailer: The Bat! (v2.04.7) CD5BF9353B3B7091 Reply-To: Enrico Ortmann Organization: RADAX X-Priority: 3 (Normal) Message-ID: <1574570229.20040420095643@radax.net> To: pgsql-admin@postgresql.org Subject: self defined counter function MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:d15e8270625ad98023d97bc6953cd9a8 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/257 X-Sequence-Number: 13230 Hi admins, I got a conceptual question on creating a stored procedure I need for my app. First the description of the problem: I need a counter which works with 36 possible values per character [0-9 and thereafter A-Z]. That means if incremented it should return values as follows: 0000 0001 0002 ... 0009 000A 000B 000C ... 000X 000Y 000Z 0010 0011 0012 ... and so on. My question is if anybody has already implemented such a user-defined 'sequence' in PL/PGSql or if anyone has a great idea on how to do that. The only solution I see at present is to do that in PHP which is used to code the mentioned userland. I suggest to solute on doing the following. - I create a sequence on the DBS - I get the next value of this sequence - I convert the next value in PHP in the code I need The problem I see on doing this is that I always need to convert if I want to get any kind of information about the counter. For example it could be that I only want to know what the last given value was. Because of the high traffic value on the application I have to take care of, that the information I read is quite correct at any time. So if I have to convert the value of the sequence therefore I need a little time. In the meantime the value could have changed and my information is worthless. I think the best way would be to code a store procedure for the problem. Any ideas would be welcome. Enrico Ortmann