473,396 Members | 2,102 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,396 software developers and data experts.

stored procedure that retrieves next unused value

9
If possible I need help to write a stored procedure, or
pseudocode, that looks into a table named numbers_ranges
and retrieves the next unused value.

The table currenlty has the following data:

id start_value end_value status date_created date_updated
1 8057777777450780000000 8057777777450780000010 N 2007-11-29 16:28:46.793 2007-11-29 16:28:46.793
2 8057777777450780000011 8057777777450780000021 N 2007-11-29 16:28:56.497 2007-11-29 16:28:56.497
3 8057777777450780000022 8057777777450780000032 N 2007-11-29 16:29:04.637 2007-11-29 16:29:04.637
4 8057777777450780000033 8057777777450780000043 N 2007-11-29 16:29:13.150 2007-11-29 16:29:13.150
5 8057777777450780000044 8057777777450780000054 N 2007-11-29 16:29:28.340 2007-11-29 16:29:28.340

How is determined what range to use?

The next number value will be retrieved from the range
with the lowest value and with a status of 'N'

When a number has been retrieved then the status of 'N'
needs to change to 'Y' which indicates that now that range
is in use.

When a range of numbers has been used completely, then
the status for that row need to be changed to 'X'

There are 3 possible status:

N = not used
Y = in use
X = already used

Everytime that a number is retrieve from the current range,
or when the staus of a range changes, the date_updated column
needs to be updated with the current date.

I understand what needs to be done, but I am confused in where to begin.
I am aware that to ask for this kind of help is not nice but if someone
could at least provide me with some guidance I will fell less stressed.

Thank you much in advance.

p.s.

please let me know if the explanation above was not clear.
Nov 29 '07 #1
0 1106

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Steve Holden | last post by:
Has anyone, with any driver whatsoever, managed to retrieve output parameters from a SQL Server stored procedure? I've just been rather embarrassed to find out it's not as easy as it might seem,...
3
by: Michael | last post by:
This one's really got me. I have a VB.NET (version 1.1.4322) project that provides an easy way to execute stored procedures on a generic level. When I run the code on computer A (running SQL...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
1
by: imarchenko | last post by:
Hello! I am trying to investigate strange problem with particular stored procedure. It runs OK for several days and suddenly we start getting and lot of locks. The reason being lock placed on...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
by: microsoft.private.windows.netserver.setup | last post by:
I have a very strange thing occurring in the program. I have a dataset retrieved from a stored procedure that just select * from a table. I then try to use the SQlCommandBuilder on the dataset,...
3
by: dew | last post by:
I have a stored procedure that retrieves the id of a client table, which is a guid To get that id, I have dim clientid as guid = GetClientID("OrgName") The GetClientID returns a string,...
1
by: gregoryday | last post by:
I am battling to get a stored procedure to build: I have a stored procedure working in SQL Server 2000, and now need to port it to DB2. I will be accessing the stored procedure via VB.NET. The...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
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: 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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.