<?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 Re: SQLFILE and Variables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14984#M13910</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another approach that uses &lt;STRONG&gt;save text file&lt;/STRONG&gt;, &lt;STRONG&gt;load text file&lt;/STRONG&gt;, and &lt;STRONG&gt;evalinsert&lt;/STRONG&gt;.&amp;nbsp; With evalinsert you surround your variables with the caret character (^), and it substitutes the currently assigned variable values in to your string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Save the query to a file with a placeholder for the identifier &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlQuery &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"Select x from table where identifier = ^primaryidentifier^"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;save text file&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"c:\temp\myquery.sql"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; sqlquery&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Load the contents of the text file into a variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlQuery &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;load text file&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"c:\temp\myquery.sql"&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;)&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Set the identifier using evalinsert&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;primaryidentifier &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"12345"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sql_statement &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;evalinsert&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlquery&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;print&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sql_statement&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;"Select x from table where identifier = 12345"&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Oct 2015 17:41:34 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2015-10-22T17:41:34Z</dc:date>
    <item>
      <title>SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14982#M13908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to tidy my script up. I have embedded in my script a very long sql query which on the top level is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sqlQuery = "Select x from table where identifier =" || primaryidendtifer ||";"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have saved this in an external .sql file and thought that I could load the query into the script to evaluated when required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JMP doesnt recognise that it needs to place the variables into the sql script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help please&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 12:22:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14982#M13908</guid>
      <dc:creator />
      <dc:date>2015-10-22T12:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14983#M13909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;primaryidendtifer = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sqltext = load text file("path.sql");&lt;/P&gt;&lt;P&gt;sqlQuery = substitute(sqltext, "primaryidendtifer", &lt;SPAN style="font-size: 13.3333px;"&gt;primaryidendtifer);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Save ' &lt;SPAN style="color: #555555; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sqlQuery = "Select x from table where identifier =" || primaryidendtifer ||";" ' into a .jsl file. Then use the include statement.&amp;nbsp; Including another JSL file will pass variables between the two scripts.&amp;nbsp; Just be careful not to overwrite common variables like "i" in for loops.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #555555; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;include("path.jsl");&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 16:02:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14983#M13909</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2015-10-22T16:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14984#M13910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another approach that uses &lt;STRONG&gt;save text file&lt;/STRONG&gt;, &lt;STRONG&gt;load text file&lt;/STRONG&gt;, and &lt;STRONG&gt;evalinsert&lt;/STRONG&gt;.&amp;nbsp; With evalinsert you surround your variables with the caret character (^), and it substitutes the currently assigned variable values in to your string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Save the query to a file with a placeholder for the identifier &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlQuery &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"Select x from table where identifier = ^primaryidentifier^"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;save text file&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"c:\temp\myquery.sql"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; sqlquery&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Load the contents of the text file into a variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlQuery &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;load text file&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"c:\temp\myquery.sql"&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;)&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// Set the identifier using evalinsert&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;primaryidentifier &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"12345"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sql_statement &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;evalinsert&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sqlquery&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;print&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;sql_statement&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;"Select x from table where identifier = 12345"&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 17:41:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14984#M13910</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2015-10-22T17:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14985#M13911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like this approach. so my assumption to the use of substitute is that the syntax 'substitutes' names in expression. So the syntax when called&lt;/P&gt;&lt;P&gt;will &lt;EM&gt;substitute&lt;/EM&gt; the &lt;EM&gt;name &lt;/EM&gt;with the required replacement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Substitute(pattern,name,replacement)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope i have this correct. Please correct me if i have not&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The alternative seems a simple approach. Which I like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 06:57:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14985#M13911</guid>
      <dc:creator />
      <dc:date>2015-10-23T06:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14986#M13912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This approach looks very feasable. Thank you for making it look so simple.&lt;/P&gt;&lt;P&gt;Removing long sql scripts from my jsl script will be wonderful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 06:58:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14986#M13912</guid>
      <dc:creator />
      <dc:date>2015-10-23T06:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: SQLFILE and Variables</title>
      <link>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14987#M13913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Per Scripting Index:&lt;BR /&gt;y = Substitue(x , patternExpr1, replacementExpr1, ...)&lt;/P&gt;&lt;P&gt;Returns a copy of string, list or expression x, replacing instances of each pattern expression with the corresponding replacement expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes you are correct.&amp;nbsp; With the addition that you can replace multiple patterns at once.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Oct 2015 14:31:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/SQLFILE-and-Variables/m-p/14987#M13913</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2015-10-23T14:31:13Z</dc:date>
    </item>
  </channel>
</rss>

