値の 1 つが UDF によって返されるクエリがあります。
select name,coord,convertCoord(coord) from testTable;
convertCoord()
Regex
とオブジェクトを使用MatchCollection
してその値を返します。
Dim re As New RegExp
Dim mtch As Match
Dim matches As MatchCollection
Function convertCoord(str As String) As String
re.Pattern = "(find|this)pattern"
Set matches = re.Execute(str)
If matches.Count > 0 Then
Set mtch = matches(1)
convertCoord = mtch.Value
Else
convertCoord = ""
End If
End Function
クエリを高速化しようとしていますが、 、re
、mtch
およびの 1 つのインスタンスを作成matches
し、 を呼び出すたびに参照できるようにする方法があるかどうか疑問に思っていますconvertCoord()
。私が正しく理解していれば、クエリのすべての結果行が を呼び出しconvertCoord()
、すべてのオブジェクトを繰り返し構築および破棄し、このすべてのオブジェクトの作成によりクエリが遅くなります。
それとも、それらは既に静的であり、関数の外で宣言しているため、一度しか構築されていませんか?