Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
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)
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 16-Feb-13 0:26am
Edited 16-Feb-13 0:49am
497.5K
v2
Comments
Maciej Los at 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)

  Print Answers RSS
0 OriginalGriff 404
1 Sergey Alexandrovich Kryukov 387
2 Shemeemsha RA 148
3 Abdul Samad KP 125
4 CPallini 100
0 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100