Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Estimate new time in ordersystem

Author  Topic 

naits
Starting Member

9 Posts

Posted - 2003-12-04 : 10:49:03
I have a ordersystem with repeating orders. Each order has a orderline with a frequency and a intervaltype (day, week, month and so on) for indicating how often a task should be done.

When an task/job is done, an equivalent receipt with receiptlines is
generated.

When a new job/task should be suggested, it has to calculate the
shortest next intervallength for each repeating orderline. This
intervallength must then be added to the date of the last receiptline.

I want to to this all in a SPROC. My result should be the one next
orderline that should be carried out with a date for when this is.

RESULTALTER PROCEDURE dbo.GetNextOrders
AS

CREATE TABLE #Interval
(
ivID int IDENTITY(1,1),
ivTaskID char(20),
ivTaskDescr nvarchar(200),
ivHour int
)

INSERT INTO #TemporaryTable

SELECT RepID, RepIntName
FROM RepeatInterval


SELECT InvoiceDetails.iID, InvoiceDetails.ReceiptID,
InvoiceDetails.OrderID, InvoiceDetails.TaskID,
InvoiceDetails.TaskDescr, InvoiceDetails.DateRegistered
FROM InvoiceDetails LEFT OUTER JOIN
Orders ON InvoiceDetails.OrderID = Orders.OrderID
WHERE (Orders.DateStart < GETDATE()) AND
(Orders.DateEnd > GETDATE() OR Orders.DateEnd IS NULL)


This is the result I want...
OrderID TaskID       TaskDesct                       EstDate
5000 GETGROCERIES Pick up groceries for miss Lama 19.12.2003


*************************************************************
Is this possible to do all in a SPROC and not having to do any in .NET
(which this is developed in), and can you help me with some ideas?
**************************************************************

To se my starting point, se the diagram at:
http://www.promotion.no/div/diagram.gif

My mind is stuck and this is so far I've reached:

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-12-04 : 14:57:58
Can you post some sample data from RepeatInterval and InvoiceDetails Tables that would be used to produce your desired resultset?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-12-04 : 20:45:27
See if this helps:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=10177
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-12-04 : 21:22:33
It just begs the question Rob ...

What is your Yahoo name??
Go to Top of Page
   

- Advertisement -