I suggest you ...

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 %>'

9 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Nick Reid shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • AdminLizard Labs (not your business, Lizard Labs) commented  ·   ·  Flag as inappropriate

    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
    Output.Append("")
    Dim id As String = "1"
    Output.Append("")
    Output.Append("")
    Output.Append("SELECT * FROM System WHERE EventType='")
    Output.Append(id)
    Output.Append("'")
    Return Output.ToString()

    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.

    Lizard Labs

  • Steve C commented  ·   ·  Flag as inappropriate

    It's a hack, but how about...
    <%Environment.SetEnvironmentVariable("sMsg","hello")%>
    SELECT * FROM MYTABLE WHERE SOMECOLUMN='<%RETURN Environment.GetEnvironmentVariable("sMsg")%>'

Feedback and Knowledge Base