Re: Stored Procedure - Iam totally lost! - Mailing list pgsql-general

From Robby Russell
Subject Re: Stored Procedure - Iam totally lost!
Date
Msg-id 1092065478.25434.41.camel@vacant
Whole thread Raw
In response to Stored Procedure - Iam totally lost!  (Marcel Boscher <mboscher@emedia-office.de>)
List 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@planetargon.com
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/



pgsql-general by date:

Previous
From: lec
Date:
Subject: Re: Losing records when server hang
Next
From: Tom Lane
Date:
Subject: Re: Losing records when server hang