<?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: Pull Data using SQL and JMP string in JSL script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/517366#M74363</link>
    <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This works as well. And it is very useful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Valerio&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2022 07:47:18 GMT</pubDate>
    <dc:creator>Valerio</dc:creator>
    <dc:date>2022-07-04T07:47:18Z</dc:date>
    <item>
      <title>Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516734#M74320</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;&lt;P&gt;I am accessing a certain database using SQL from a JSL script.&lt;/P&gt;&lt;P&gt;To pull the data I want, I need to provide a specification.&lt;/P&gt;&lt;P&gt;The specification comes in the form of a list or matrix in JMP/JSL.&lt;/P&gt;&lt;P&gt;If I manually type-in the single items names, it works. =&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* Fetch Single Items from Database*/
	A = Open Database("Server Specs", "SELECT * FROM CertainFolder a WHERE a.CertainColumn IN ('A','B','C','D')");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But, since the items might be thousands, I need to find a way to use a single name representing a list (or a matrix) of the items.&lt;/P&gt;&lt;P&gt;Of course, like this is not working. =&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* Fetch Data from Data Table*/
	Items_M = :Items &amp;lt;&amp;lt; get as matrix();

/* Fetch Data from Database*/
	A = Open Database("Server Specs", "SELECT * FROM CertainFolder a WHERE a.CertainColumn IN ('^Items_M^')");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What is the &lt;EM&gt;simplest&lt;/EM&gt; way to do this?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 20:51:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516734#M74320</guid>
      <dc:creator>Valerio</dc:creator>
      <dc:date>2023-06-10T20:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516781#M74323</link>
      <description>&lt;P&gt;I can't say, what is &lt;EM&gt;simplest&lt;/EM&gt;, but this is how I do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// for test purposes 
lstItems = {"A","B","C","D"};

// build a comma separated list
strItems = ConcatItems(lstItems,",");

/* Fetch Data from Database*/

eval(parse(evalinsert("\[ 

	A = Open Database("Server Specs", "SELECT * FROM CertainFolder a WHERE a.CertainColumn IN (^strItems^)")
	
]\")));;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jul 2022 07:35:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516781#M74323</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-07-03T07:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516908#M74344</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That it what I was looking for... It wouldn't work during the weekend because I had unstable access to the database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 07:45:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516908#M74344</guid>
      <dc:creator>Valerio</dc:creator>
      <dc:date>2022-07-04T07:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516999#M74349</link>
      <description>&lt;P&gt;This is how I usually do it:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;building a unique list of column values&lt;/LI&gt;
&lt;LI&gt;feeding that list into an sql&lt;/LI&gt;
&lt;LI&gt;get data back from database into a new table&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It is so far a I know the simplest way to perform this task, and I use it a lot,&lt;/P&gt;
&lt;P&gt;I have implemented this in my menu, to have it at hand quickly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// take unique values from the column :items
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize( Current Data Table(), item_lst = by( :NAME /* :item */ ) );
// show list
show(item_lst);
// prepare list for sql
item_lst_str=substitute (char(item_lst),"{","(","}",")","\!"","'");

// open SQL Query with inserted item_lst
New SQL Query(
	Connection(
		"ODBC:DSN=DSN_NAME;UID=user;DBQ=database;" // connection string to be modified
	),
	QueryName( "ITEMS_Query" ),
	CustomSQL( eval insert("SELECT * from database_table dt where dt.item in ^item_lst_str^;") )
) &amp;lt;&amp;lt; modify;
// or directly run if neccessary
// ) &amp;lt;&amp;lt; Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jul 2022 08:37:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/516999#M74349</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2022-07-02T08:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/517135#M74356</link>
      <description>&lt;P&gt;I changed by example to use&amp;nbsp;&lt;STRONG&gt;Concat Items&lt;/STRONG&gt; function which does the job of converting a list into a comma separated string. Your code used ^^ which is the smart way of doing an insert, but it only works in conjunction with the &lt;STRONG&gt;Eval Insert&lt;/STRONG&gt; function.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2022 07:40:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/517135#M74356</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-07-03T07:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pull Data using SQL and JMP string in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/517366#M74363</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This works as well. And it is very useful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Valerio&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 07:47:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pull-Data-using-SQL-and-JMP-string-in-JSL-script/m-p/517366#M74363</guid>
      <dc:creator>Valerio</dc:creator>
      <dc:date>2022-07-04T07:47:18Z</dc:date>
    </item>
  </channel>
</rss>

