Re: Stored Procedure - Iam totally lost!

From: Robby Russell <robby(at)planetargon(dot)com>
To: Marcel Boscher <mboscher(at)emedia-office(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Procedure - Iam totally lost!
Date: 2004-08-09 15:31:19
Message-ID: 1092065478.25434.41.camel@vacant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2004-08-09 at 02:13, Marcel Boscher wrote:
> Hey guys,
>
> i got a question that bothers me quite a while,
> been looking everywhere but found no answer
>
> My idea is to automate this procedure for better performance...
>
> Can anybody in here tell me if its possible to auto create
> a 4 digit randomly code 1st digit alpha 2nd -4th numeric
> that gets looked up in the db if its there new code is generated
> if its not give the code back to my php proggy?
> I would like to do it in PostGreSQl with a stored procedure
>
> Any Help would be appreciated, since iam totally lost...
> Thx in advance

So, you want to create something like:
n312
b943
z338

Correct?

You would probably want to play around with the server side functions in
plpgsql, or even look into something like plperl, plphp, etc. Start off
with getting a function to return you a 4 character string, then when
that appears to be working, look into the plpgsql syntax to figure out
how to check that it's the only one like that otherwise, rerun the
function and return a different string.

Hope that helps get you started in the right direction,

-Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby(at)planetargon(dot)com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-08-09 16:03:19 Re: Losing records when server hang
Previous Message lec 2004-08-09 15:15:56 Re: Losing records when server hang