Click here to Skip to main content
12,298,927 members (51,371 online)
Rate this:
 
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
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160525.2 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2016
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