Get the value of a collumn using a variable (1 Viewer)

neoklis

Registered User.
Local time
Today, 16:05
Joined
Mar 12, 2007
Messages
80
Hi all,

I want to define the collumns name from a variable. The code bellow returns me ‘KG’ but I want the value for the field ‘KG’. Can someone please help me..?

thank you

declare @unit_a nvarchar(3)
set @unit_a='KG'

SELECT @unit_a
FROM table
 

SQL_Hell

SQL Server DBA
Local time
Today, 14:05
Joined
Dec 4, 2003
Messages
1,360
KG is the value you set it to?

Sorry this makes no sense... what you do you want do?
 

SQL_Hell

SQL Server DBA
Local time
Today, 14:05
Joined
Dec 4, 2003
Messages
1,360
Do you mean something like this?

Code:
declare @field varchar(10)
declare @sql varchar(50)
set @field = 'name'
set @sql = 'SELECT '+ @field + ' FROM SYS.SYSOBJECTS'
print @sql
exec(@sql)
 

neoklis

Registered User.
Local time
Today, 16:05
Joined
Mar 12, 2007
Messages
80
Yes that is what i mean... Cause of my bad english, someone must be a diviner to see what i want to do...

Thank you
 

neoklis

Registered User.
Local time
Today, 16:05
Joined
Mar 12, 2007
Messages
80
I am back again..:eek:

Unfortunately the exec command can't be executed into a function. All i want to do is to convert an ms access function to sql function. I will post the MsAccess function so any advice is welcomed. The area marked with red color is the area that i am trying to convert but i think that it can't be done in SQL Function. I don't know if i must try to convert it to a stored procedure.. what do you think guys;

Code:
[COLOR=#0000ff]Function ChangeQuantUnit(xMaterial, xquant_a, xunit_a, xunit_b)[/COLOR]
 
[COLOR=#0000ff]Static M As Recordset, Mat_SQL, quant_a, unit_a, unit_b, LB2KG, FT2MTR[/COLOR]
 
[COLOR=#0000ff]LB2KG = 2.204623  'LB/kg[/COLOR]
[COLOR=#0000ff]FT2MTR = 3.28084  'FT/MTR[/COLOR]
 
[COLOR=#0000ff]Select Case Trim(UCase(xunit_a))[/COLOR]
[COLOR=#0000ff]   Case "LB"   ' if input quant is LB, transform xquant_a first to KG (and then -> xunit_b)[/COLOR]
[COLOR=#0000ff]       quant_a = xquant_a / LB2KG[/COLOR]
[COLOR=#0000ff]       unit_a = "KG"[/COLOR]
[COLOR=#0000ff]   Case "FT"   ' if input quant is FT, transform xquant_a first to MTR (and then -> xunit_b)[/COLOR]
[COLOR=#0000ff]       quant_a = xquant_a / FT2MTR[/COLOR]
[COLOR=#0000ff]       unit_a = "MTR"[/COLOR]
[COLOR=#0000ff]   Case "K"[/COLOR]
[COLOR=#0000ff]       quant_a = xquant_a[/COLOR]
[COLOR=#0000ff]       unit_a = "KG"[/COLOR]
[COLOR=#0000ff]   Case Else[/COLOR]
[COLOR=#0000ff]       quant_a = xquant_a[/COLOR]
[COLOR=#0000ff]       unit_a = xunit_a[/COLOR]
[COLOR=#0000ff]End Select[/COLOR]
 
[COLOR=#0000ff]Select Case Trim(UCase(xunit_b))[/COLOR]
[COLOR=#0000ff]   Case "LB"   ' if output quant is LB, set first transformation to xquant_a -> KG (and then -> LB)[/COLOR]
[COLOR=#0000ff]       unit_b = "KG"[/COLOR]
[COLOR=#0000ff]   Case "FT"   ' if output quant is FT, set first transformation to xquant_a -> MTR (and then -> FT)[/COLOR]
[COLOR=#0000ff]       unit_b = "MTR"[/COLOR]
[COLOR=#0000ff]   Case "K"[/COLOR]
[COLOR=#0000ff]       unit_b = "KG"[/COLOR]
[COLOR=#0000ff]   Case Else[/COLOR]
[COLOR=#0000ff]       unit_b = xunit_b[/COLOR]
[COLOR=#0000ff]End Select[/COLOR]
 
[COLOR=#0000ff]If unit_a = unit_b Then[/COLOR]
[COLOR=#0000ff]   ChangeQuantUnit = quant_a[/COLOR]
[COLOR=#0000ff]Else[/COLOR]
 
[COLOR=red]'Make the transformation where both input + output units is one of (KG, K, MTR, ST)[/COLOR]
[COLOR=red]   Mat_SQL = "SELECT SAP_Materials.Material, SAP_Materials.K, SAP_Materials.Base_K, SAP_Materials.KG, SAP_Materials.Base_KG, SAP_Materials.MTR, SAP_Materials.Base_MTR, SAP_Materials.ST, SAP_Materials.Base_ST FROM SAP_Materials WHERE (((SAP_Materials.Material)=""" + xMaterial + """));"[/COLOR]
[COLOR=red]   Set M = CurrentDb.OpenRecordset(Mat_SQL, dbOpenDynaset)[/COLOR]
 
[COLOR=red]   If M.RecordCount > 0 Then[/COLOR]
[COLOR=red]       If M(unit_a) * M("BASE_" + unit_b) > 0 Then[/COLOR]
[COLOR=red]           ChangeQuantUnit = quant_a * M(unit_b) * M("BASE_" + unit_a) / (M(unit_a) * M("BASE_" + unit_b))[/COLOR]
[COLOR=red]       End If[/COLOR]
 
[COLOR=blue]       Select Case Trim(UCase(xunit_b))[/COLOR]
[COLOR=blue]           Case "LB"   ' if output quant is LB, make the final transform from KG - > LB[/COLOR]
[COLOR=blue]               ChangeQuantUnit = ChangeQuantUnit * LB2KG[/COLOR]
[COLOR=blue]           Case "FT"   ' if output quant is FT, make the final transform from MTR - > FT[/COLOR]
[COLOR=blue]               ChangeQuantUnit = ChangeQuantUnit * FT2MTR[/COLOR]
[COLOR=blue]       End Select[/COLOR]
[COLOR=blue]   End If[/COLOR]
 
[COLOR=blue]   M.Close[/COLOR]
 
[COLOR=#0000ff]End If[/COLOR]
[COLOR=#0000ff]End Function[/COLOR]

and this what i,ve done so far..
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ANSI_NULLS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ON[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]QUOTED_IDENTIFIER[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ON[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]go[/SIZE]
 
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ALTER[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]FUNCTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [dbo][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080].[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][ChangeQuantUnit] [/SIZE]
[SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xMat [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]20[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]@xQuant_A [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]@xUnit_A [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]),[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]@xUnit_B [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]RETURNS[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]AS[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]BEGIN[/COLOR][/SIZE]
[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]DECLARE[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @return [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @quant_a [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]3[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_b [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]3[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @LB2KG [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]6[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @FT2MTR [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]decimal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]10[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]6[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]declare[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @sql [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]varchar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]250[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])[/COLOR][/SIZE][/COLOR][/SIZE]
 
 
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'LB'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]begin[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @Quant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xQuant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]/[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@LB2KG[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'KG'[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]end[/COLOR][/SIZE][/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'FT'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]begin[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @Quant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xQuant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]/[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@FT2MTR[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'MTR'[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]end[/COLOR][/SIZE][/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'K'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]begin[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @Quant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xQuant_a[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'KG'[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]end[/COLOR][/SIZE][/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]begin[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @Quant_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xQuant_a[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xunit_a[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]end[/COLOR][/SIZE]
[/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'LB'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'KG'[/COLOR][/SIZE]
[/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'FT'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'MTR'[/COLOR][/SIZE]
[/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @xunit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'K'[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]'KG'[/COLOR][/SIZE]
[/COLOR][/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_b[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@xunit_b[/SIZE]
 
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @unit_a[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@unit_b[/SIZE]
[INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @return[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]@quant_a[/SIZE]
[/INDENT][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]RETURN[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] @return[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]END[/COLOR][/SIZE]
[/COLOR][/SIZE]
 

Users who are viewing this thread

Top Bottom