Showing posts with label cartid. Show all posts
Showing posts with label cartid. Show all posts

Sunday, March 25, 2012

Copying tables each other but with new row numbers or something like that

Take T4.ProductID , T4.ProductName from T4 where T4.CartID = @.CartID
.IF EXISTS
.Insert Into T1 values(T4.ProductId) and Get the T1.RowNo (T1.RowNo autoincrement column)
.Take T5.ProductID , T5.ProductGroup where T5.ProductID = T4.ProductID
.IF EXISTS
.INSERT INTO T2 values(T1.RowNo,T5.ProductGroup)
.Take T6.ProductID,T6.ProductGroup,T6.ProductDetail Where T6.ProductID = T4.ProductName AND T6.ProductGroup = T5.ProductGroup
.IF EXISTS
.INSERT INTO T3 values (T1.RowNo,T5.ProductGroup,T6.ProductDetail)

I Hope i am clear. It is very confusing but try to thing. I really need help. I am trying to make a shopping site.
T1 stores ProductID, this table is ShoppingCart
T2 stores DetailGroup of Product stored in T1.
T3 stores Detail of Product.


T1 - T2 - T3
EX: 1,Samsung HDD - 1,External - 1,External,750GB

User can save this cart. When user saves cart, tables are copying each other. T1 to T4 , T2 to T5 , T3 to T6. So everything is ok up to this point. But when user try to add his/her saved cart to current cart problem begins.

T4 - T5 - T6
EX: 1,Samsung HDD - 1,External - 1,External,750GB

When user adds a product, it is inserted into T1 as a new row and first column(T1.RowNo) is autoincrement. I need to copy user cart values from T1 to T4 and get the inserted rows new RowNo and use it when inserteing the T5 into T2 and T6 into T3. I hopw i am clear. I try to write code but it was very long. If you need code please let me know. I REALLY NEED HELP .

AND

Another simple question. Are stored procedures takes values that comes from another stored procedure as Table. I mean SP1 returns a table. And SP2 takes that table row by row and makes the operation?

Ex: you are calling SP2 5 times for different 5 values(nvarchar(50),int). Likewise can you call SP2 one time and getting a Table whisch stores 5 nvarchar(50),int value as rows.

Happy Coding

"MasterG"

Surely your table names are NOT "T1", T2", etc.

|||Sure names are not T1 or T2 etc. But is it important? Just a table name. Why did you asked that?