<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805548#M98385</link>
    <description>&lt;DIV&gt;I'm running into a problem with an SQL Select-statement using column names that are including brackets, because the end brackets of the column names end up next to backslashes (due to using quotation marks within quotation marks: " \!" column name [ units ] \!" " ) and this interferes with the surrounding special escape characters (bracket and backslash: \[ ]\ ).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The SQL-statement is written between two brackets and slashes ( \[ Select ... ]\ ) and I'm using Eval(Parse(Eval Insert())) around the whole statement to evaluate a variable (filtering by a start date).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The command is structured like this:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Eval(Parse(Eval Insert(&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;"dt = Open Database( settings,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; \[Select \!"table1\!".\!"column_name[units]\!" ... ]\&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;);"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;)));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you see, the end bracket after column_name[units] ends up next to a backslash for the quotation mark around the column name, effectively making up an unwanted special escape character ( ]\ ).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;UL&gt;&lt;LI&gt;I've tried using single quotation marks around the column names, and the command executed but no data was retrieved. When searching for discussion or documentation on single quotation marks I wasn't able to find any.&lt;/LI&gt;&lt;LI&gt;I've tried using the eval insert replacement string for a quation mark ( both " and \!" ) but it wasn't successful.&lt;/LI&gt;&lt;LI&gt;I've looked through several discussion on this but wasn't able to find a solution, yet.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I would be grateful for any suggestions on how this situation can be solved, what I should be trying or what I need to read up on?&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2024 09:10:39 GMT</pubDate>
    <dc:creator>Dape</dc:creator>
    <dc:date>2024-10-15T09:10:39Z</dc:date>
    <item>
      <title>Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805548#M98385</link>
      <description>&lt;DIV&gt;I'm running into a problem with an SQL Select-statement using column names that are including brackets, because the end brackets of the column names end up next to backslashes (due to using quotation marks within quotation marks: " \!" column name [ units ] \!" " ) and this interferes with the surrounding special escape characters (bracket and backslash: \[ ]\ ).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The SQL-statement is written between two brackets and slashes ( \[ Select ... ]\ ) and I'm using Eval(Parse(Eval Insert())) around the whole statement to evaluate a variable (filtering by a start date).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The command is structured like this:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Eval(Parse(Eval Insert(&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;"dt = Open Database( settings,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; \[Select \!"table1\!".\!"column_name[units]\!" ... ]\&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;);"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;)));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you see, the end bracket after column_name[units] ends up next to a backslash for the quotation mark around the column name, effectively making up an unwanted special escape character ( ]\ ).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;UL&gt;&lt;LI&gt;I've tried using single quotation marks around the column names, and the command executed but no data was retrieved. When searching for discussion or documentation on single quotation marks I wasn't able to find any.&lt;/LI&gt;&lt;LI&gt;I've tried using the eval insert replacement string for a quation mark ( both " and \!" ) but it wasn't successful.&lt;/LI&gt;&lt;LI&gt;I've looked through several discussion on this but wasn't able to find a solution, yet.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I would be grateful for any suggestions on how this situation can be solved, what I should be trying or what I need to read up on?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 09:10:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805548#M98385</guid>
      <dc:creator>Dape</dc:creator>
      <dc:date>2024-10-15T09:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805567#M98392</link>
      <description>&lt;P&gt;&lt;SPAN&gt;First I would suggest that you don't utilize Eval(Parse()). I think you should be able to use ]" inside strings&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = "\[abc]"]\";
write(str); // abc]"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;If not then then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;LI-MESSAGE title="How do you replace square brackets &amp;amp;quot;[&amp;amp;quot; &amp;amp;quot;]&amp;amp;quot; in a string with Regex?" uid="263954" url="https://community.jmp.com/t5/Discussions/How-do-you-replace-square-brackets-quot-quot-quot-quot-in-a/m-p/263954#U263954" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;might give some additional ideas.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 11:31:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805567#M98392</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-15T11:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805570#M98393</link>
      <description>&lt;P&gt;I tried removing Eval(Parse()) and just creating the string to start with. The special escape characters are still creating a problem, it seems, or it's something else. But the problem disappears when I remove the special escape characters ( \[ ]\ ) and it also disappears when I change the brackets in the column name to parentheses.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;str = "\[\!"table\!".\!"column[unit]\!"n]\";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:09:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805570#M98393</guid>
      <dc:creator>Dape</dc:creator>
      <dc:date>2024-10-15T12:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805575#M98395</link>
      <description>&lt;P&gt;Which JMP version are you using? I don't currently have any databases on my PC so I cannot test using Open Database but I can do simple tests using JMP tables and New SQL Query()&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt1 = Open("$SAMPLE_DATA/Big Class.jmp");
Column(dt1, 1) &amp;lt;&amp;lt; Set Name("test[na me]");

dt = New SQL Query(
	Connection("JMP"),
	JMP Tables(["Big Class" =&amp;gt; "$SAMPLE_DATA/Big Class.jmp"]),
	Custom SQL("\[Select "test[na me]" from "Big Class"]\")
) &amp;lt;&amp;lt; Run Foreground;

Close(dt1, No save);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:18:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805575#M98395</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-15T12:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805607#M98400</link>
      <description>&lt;P&gt;I'm working on JMP 17. I see, changing to New SQL Query probably solves these problems, I think that's a good suggestion. I'm not using it here because I'm building on some older scripts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there's a way to handle the string management I'm all ears for that but I think I'll try changing command.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:02:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805607#M98400</guid>
      <dc:creator>Dape</dc:creator>
      <dc:date>2024-10-15T13:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805620#M98401</link>
      <description>&lt;P&gt;If you are already escaping the string using "\[]\" you don't need to do it again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = "\["table"."column[unit]"n]\";
Write(str);&amp;nbsp;//&amp;nbsp;"table"."column[unit]"n&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:14:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805620#M98401</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-15T13:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805664#M98403</link>
      <description>&lt;P&gt;Not sure if I understand your comment, but I think it's a misunderstanding (anyway thanks for the suggestion). I'm only escaping using "\[]\" once, the second time the symbols appear it's because of the column name with a bracket ending up next to a backslash which I can't avoid using.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:34:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805664#M98403</guid>
      <dc:creator>Dape</dc:creator>
      <dc:date>2024-10-15T13:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805701#M98404</link>
      <description>&lt;P&gt;Yeah, it might be just some simple confusion as I'm basing my comments on your original script utilizing Eval(Parse()) which will then end up looking like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(Parse(Eval Insert(
   "dt = Open Database( settings,
      \[Select \!"table1\!".\!"column_name[units]\!" ... ]\
   );"
)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;when it maybe should look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

mydate = "1.1.2000";

dt = Open Database(settings,
    Eval Insert("\[Select "table1"."column_name[units]"... ^mydate^]\")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;with some more separation&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

mydate = "1.1.2000";
sql_template = "\[Select "table1"."column_name[units]"... ¤mydate¤]\";
sql_str = Eval Insert(sql_template, "¤");

dt = Open Database(settings,
    sql_str
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.0/index.shtml#page/jmp/jsl-syntax-rules.shtml" target="_blank"&gt;https://www.jmp.com/support/help/en/18.0/index.shtml#page/jmp/jsl-syntax-rules.shtml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:57:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805701#M98404</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-15T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Collision in SQL Select-statement between special escape characters (bracket and backslash) and bracket in column name with quotation marks around it</title>
      <link>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805783#M98409</link>
      <description>&lt;P&gt;It's great to see better structuring of the code, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 14:44:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Collision-in-SQL-Select-statement-between-special-escape/m-p/805783#M98409</guid>
      <dc:creator>Dape</dc:creator>
      <dc:date>2024-10-15T14:44:56Z</dc:date>
    </item>
  </channel>
</rss>

