As a beginner, I am looking for assistance on trying to create an order for every time another order appears.
I have 3 order types in the table dbo.OrderType
with
columns OrderTypeID,
OrderTypeName
:
OrderTypeID OrderTypeName---------------------------1 Assignment2 LoanRelease3 DocumentRetrieval
For every order with OrderTypeName
= Assignment
I need to create an Order
withOrderTypeName
= DocumentRetrieval
Here are the tables I believe I need,
dbo.tblOrder
Columns: OrderId,
OrderTypeID, LoanNumber
, and CustomerID
dbo.tblOrderActivity
Columns: OrderID,
ActivityID, ActivityDate
dbo.tblActivity
Columns ActivityID,
ActivityName
ActivityID ActivityName------------------------1 Received2 Keyed3 Printed4 Delivered
dbo.tblCustomer
Columns CustomerID,
CustomerName
I believe I need to create a procedure for this since it relates to creating a new Order
with
theOrderType
= 3
for every Order
with OrderType
= 1
, every new order created must have thereceived
or ActivityID
= 1
.
Can someone help me start the logic and process of this?
When I try to even attempt to create a procedure I get syntax errors and am running around in circles confusing myself on how to start this.
A new Order(OrderID(autoincrement) and OrderTypeID(3)) - consisting of that OrderTypeID(3) for DocumentRetrieval.
created for every Order that is of OrderTypeID(1)"Assignment".
So the new Order being created will have the same
LoanNumber and CustomerID as the one it is being created for.
So then when relating to the OrderActivity Table, the OrderID will be the OrderID created from the new Order being created, having the ActivityID(1) for received. Basically creating a new "DocumentRetrieval" type of order for every "assignment" type order.