<?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: How to skip item on JSL list in SQL query if it does not exist? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730748#M91357</link>
    <description>&lt;P&gt;*edit&lt;/P&gt;&lt;P&gt;Didn't see Jim's response.&amp;nbsp; Good response, though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't look like the list of names is formatted properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John,Jane,Anna,Dominic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should be 'John','Jane','Anna','Dominic'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to use Concat Items(), you'll need to do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NameItems = "'" || Concat Items(NameList,"','") || "'"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Mar 2024 19:41:52 GMT</pubDate>
    <dc:creator>mmarchandTSI</dc:creator>
    <dc:date>2024-03-07T19:41:52Z</dc:date>
    <item>
      <title>How to skip item on JSL list in SQL query if it does not exist?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730407#M91329</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a script that queries from JSL list. However, it gets an error whenever something is not existing on the database. Is there a way that I can skip what is not existing and proceed to the next value in the list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NameList = {"John","Jane","Anna","Dominic"};
NameItems = ConcatItems(NameList ,",");

Eval (Parse (Evalinsert("\[ 
 db= Open Database("Server Specs", "SELECT * FROM dbNames WHERE name IN (^NameItems ^)")	
]\")));;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So for example, John doesn't exist, it should skip and go with Jane, Anna or Dominic&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 08:05:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730407#M91329</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2024-03-07T08:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to skip item on JSL list in SQL query if it does not exist?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730422#M91335</link>
      <description>&lt;P&gt;An IN operator should not fail unless none of the values in the list are found.&amp;nbsp; You should be able to protect this issue with a Try() function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval (Parse (Evalinsert("\[ 
 db= Try( Open Database("Server Specs", "SELECT * FROM dbNames WHERE name IN (^NameItems ^)") )	
]\")));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, it is my experience that your IN operator should enclose the character elements within the call with quotes.&lt;/P&gt;
&lt;PRE&gt;WHERE name IN ('John','Jane','Anna','Dominic')&lt;/PRE&gt;
&lt;P&gt;Changing your JSL to the below will change the IN operator call to the above form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NameList = {"John","Jane","Anna","Dominic"};
NameItems = "'" || ConcatItems(NameList ,"','") || "'";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2024 12:14:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730422#M91335</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-07T12:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to skip item on JSL list in SQL query if it does not exist?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730748#M91357</link>
      <description>&lt;P&gt;*edit&lt;/P&gt;&lt;P&gt;Didn't see Jim's response.&amp;nbsp; Good response, though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't look like the list of names is formatted properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John,Jane,Anna,Dominic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should be 'John','Jane','Anna','Dominic'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to use Concat Items(), you'll need to do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NameItems = "'" || Concat Items(NameList,"','") || "'"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 19:41:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-skip-item-on-JSL-list-in-SQL-query-if-it-does-not-exist/m-p/730748#M91357</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2024-03-07T19:41:52Z</dc:date>
    </item>
  </channel>
</rss>

