473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Gift vouchers

No this isn't spam! :)

I'm currently developing a gift voucher system for an ecommerce retailer.
The vouchers may be emailed to customers or printed and sent along with
postage. Either way the administration for creating vouchers will be
through an admin web UI.
Now I was thinking of using a guid in SQL Server for the voucher number
since it will be unique and hard for people to guess a voucher number.
However since these may be printed and sent they may not want to make the
customer type out something like c70c012d-4b14-4eca-bf4b-c484fbaa069c

Is there an easy way of making a unique 9 or 12 character long voucher
number such as h72j3i9c0l1j and still ensure that it will not be a duplicate
number?

Thanks J


Nov 18 '05 #1
6 2156
"Janaka" <ja****@magicalia.com> wrote in
news:#5**************@tk2msftngp13.phx.gbl:
Is there an easy way of making a unique 9 or 12 character long voucher
number such as h72j3i9c0l1j and still ensure that it will not be a
duplicate number?


I don't have an unique generation algorithm for you... but You can always
add a unique constraint on the column in the database, this will guarantee
any data being inserted will be unique. If the data is not unique, an
exception will be thrown (and then you can regenerate the value).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
That's true. I was going to implement that constraint on the db. My only
concern is that after making say 10 000 voucher numbers I'd have to
repeatedly do try catches around db inserts until it works. Sounds to me
like it could possibly hang the page or lock the table?
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Janaka" <ja****@magicalia.com> wrote in
news:#5**************@tk2msftngp13.phx.gbl:
Is there an easy way of making a unique 9 or 12 character long voucher
number such as h72j3i9c0l1j and still ensure that it will not be a
duplicate number?


I don't have an unique generation algorithm for you... but You can always
add a unique constraint on the column in the database, this will guarantee
any data being inserted will be unique. If the data is not unique, an
exception will be thrown (and then you can regenerate the value).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #3
You could make a function to generate a voucher and then add it to the
database. a 12 character/digit string will not be too hard to make unique,
the chances of re-creating a voucher would not be likely

On Tue, 24 Aug 2004 13:57:15 +0100, Janaka <ja****@magicalia.com> wrote:
That's true. I was going to implement that constraint on the db. My only
concern is that after making say 10 000 voucher numbers I'd have to
repeatedly do try catches around db inserts until it works. Sounds to me
like it could possibly hang the page or lock the table?
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Janaka" <ja****@magicalia.com> wrote in
news:#5**************@tk2msftngp13.phx.gbl:
> Is there an easy way of making a unique 9 or 12 character long voucher
> number such as h72j3i9c0l1j and still ensure that it will not be a
> duplicate number?


I don't have an unique generation algorithm for you... but You can
always
add a unique constraint on the column in the database, this will
guarantee
any data being inserted will be unique. If the data is not unique, an
exception will be thrown (and then you can regenerate the value).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/



--
Mark Harris
Head Developer
GameHost CP
Nov 18 '05 #4
"Janaka" <ja****@magicalia.com> wrote in news:OxNeXndiEHA.1656
@TK2MSFTNGP09.phx.gbl:
My only
concern is that after making say 10 000 voucher numbers I'd have to
repeatedly do try catches around db inserts until it works.


Well you should have an algorithm which gives you unique values... but the
constraint just adds an extra check incase your algorithm is bad.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #5
"Janaka" <ja****@magicalia.com> wrote in news:OxNeXndiEHA.1656
@TK2MSFTNGP09.phx.gbl:
My only
concern is that after making say 10 000 voucher numbers I'd have to
repeatedly do try catches around db inserts until it works.


Nah... 9^36 (assuming A-Z and 0-9) = 101,559,956,668,416. So the odds of
getting a duplicate are quite low.

If you add case sensitivity, that's even more combinations.
Nov 18 '05 #6
Dear Janaka,

In what language are you doing the coding.. Eg : In VFP you can use
SYS(2015).Im sure that there must be same kind of functions in VB etc too

Roshan Jayalath

"Janaka" wrote:
That's true. I was going to implement that constraint on the db. My only
concern is that after making say 10 000 voucher numbers I'd have to
repeatedly do try catches around db inserts until it works. Sounds to me
like it could possibly hang the page or lock the table?
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Janaka" <ja****@magicalia.com> wrote in
news:#5**************@tk2msftngp13.phx.gbl:
Is there an easy way of making a unique 9 or 12 character long voucher
number such as h72j3i9c0l1j and still ensure that it will not be a
duplicate number?


I don't have an unique generation algorithm for you... but You can always
add a unique constraint on the column in the database, this will guarantee
any data being inserted will be unique. If the data is not unique, an
exception will be thrown (and then you can regenerate the value).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bill DeSoto | last post by:
AIDS!
0
by: aol12131 | last post by:
{©¿©} www.gift.boxke.net <<
0
by: laredotornado | last post by:
Hi, This is a nifty perl script for sending greeting cards http://bignosebird.com/carchive/cardcgi.shtml Does anyone know if it has a freeware PHP equivalent? Thanks for any info, - Dave
2
by: Just D. | last post by:
Great thanks to MS, the code written several months ago and working just perfectly before December 2006 suddenly stopped working generating errors or downloading trash instead of real data. Nice...
0
by: =?Utf-8?B?TG9jbyBNZXRhbCBIZWFk?= | last post by:
Well, I am basically wondering if microsoft has any type of credit card or a gift card available. I have looked around and not seen a trace of one but I think it would be really nice to have one.
0
by: aw | last post by:
Hello, I am a psychology student at University of Chicago conducting a survey on animals, technology, and nature. It takes only 5-10 minutes to complete and every 20th participant will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.