Click here to Skip to main content
15,886,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi how can i perform this function in sql stored Procedure using 2 Dimensional Array.
FETCH THE CURRENT DENOMINATIONS & AVAILABLE NUMBERS OF THE ASSIGNED_TO PARTNER AND ASSIGN IT TO ARRAY (NOTE: IF AVAILABLE NUMBER IS 0 THEN IT IS NOT COUNTED) 	
Define 2D Array; FOR EACH available denomination with stock assign the following:
Array(i,1) = Denomination ; Array(i,2) = Available Stock in number ; Array(i,3) = Allocated (INITALLY 0)

SQL
ACTUAL_ALLOT_QTY = 0
For Qty = 0 to MAX_ALLOT_LTR					
	Temp_Denom = 0					
	for i= 1 to Array Size					
		If Array(i,2) > Array (i,3)
   		      IF (ACTUAL_ALLOT_QTY + Array(i,1)) <= MAX_ALLOT_LTR
                                  ACTUAL_ALLOT_QTY = ACTUAL_ALLOT_QTY + Array(i,1)
		           Array (i,3) = Array (i,3) + 1			
		           Qty = Qty + Array (i,1)			
                                 ELSE
		            Temp_Denom = Temp_Denom + 1			
                                 END IF
		Else				
			Temp_Denom = Temp_Denom + 1			
		End If				
	Next i					
        IF Temp_Denom = Array Size THEN Qty = MAX_ALLOT_LTR		
Next Qty	

------------------------------------------------------------------------------------------------
Help me anybody.
Posted
Updated 16-Feb-13 0:49am
v2
Comments
Maciej Los 18-Feb-13 7:07am    
Please, provide more details, like: example data, schema of table. Did you read about SQL CTE.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900