Referencing a VB variable or constant
Using inline VB in a query, how can I declare a variable or constant at the top and reference it later?
<% Dim sMsg As String = "hello"%>
SELECT * FROM MYTABLE WHERE SOMECOLUMN='<% Return sMsg %>'
This feature is implemented in Log Parser Lizard 4.0.3. You can find more info in comments.
Nick Reid commented
Thank you very much.
Log Parser Lizard v4.0.3 now supports similar functionality. Now you can write query like:
<% Dim id As String = "1"%>
SELECT * FROM System WHERE EventType='<% Output.Append(id) %>'
LPL will automatically transform and run this in one Visual Basic .NET script:
Dim Output As New System.Text.StringBuilder
Dim id As String = "1"
Output.Append("SELECT * FROM System WHERE EventType='")
I believe something like this is what you were looking for.
Please note that to enable this VB.Net script behavior you will have to modify the setting “Execute inline VB.Net scripts separately” in Settings dialog box. We had to default this setting to True to keep compatibility with scripts from previous LPL versions.
If you want to use this behavior from now on, maybe you will have to modify some current queries. If you have more than one script block in a query, just remove the “RETURN” statement from each block since it will break the script execution.
I hope this was helpful and all of you have voted will enjoy the new feature.
Steve C commented
It's a hack, but how about...
SELECT * FROM MYTABLE WHERE SOMECOLUMN='<%RETURN Environment.GetEnvironmentVariable("sMsg")%>'