Thread: Stored Procedure - Iam totally lost!

Stored Procedure - Iam totally lost!

From
Marcel Boscher
Date:
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

Re: Stored Procedure - Iam totally lost!

From
Robby Russell
Date:
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@planetargon.com
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/