<?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 JMP 13 JSL that passes variables to oracle SQL statement in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50692#M28806</link>
    <description>&lt;P&gt;I am working with a collegue that has a JMP 13 script to is defining variables using Modal windows.&amp;nbsp; User selection then sets variables that we want to pass into a open database section of our script in the SQL statement.&amp;nbsp; Data table is updated for which oven is selected in the Modal window.&amp;nbsp; We then select the oven column to pass this value into our SQL statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;OvenList={18,22};
nw=New Window( " Reference Units",&amp;lt;&amp;lt;Modal,
     Text Box(" Define the Oven you want"),
     Text Box( ""),
          Panel Box("Select",
          oven_bx = Radio Box( {"Oven 18", "Oven 22"})),
          Text Box(""),
     V List Box(ok_btn=Button Box("OK",
          ov1=oven_bx &amp;lt;&amp;lt; Get;),
          cncl_btn=Button Box ("Cancel")));
 
New Column("Oven",numeric, nominal);
:Oven&amp;lt;&amp;lt; Set Each Value(OvenList[ov1]);
 
oven_id= :Oven &amp;lt;&amp;lt; Get Values;
test_part_id = :ExpNo &amp;lt;&amp;lt; Get Values;
 
Open Database( -- connection string info -- ,
 
"
Select 
db.table.field1
db.table.field2
db.table.field3
FROM db.table
WHERE
db.table.exprmt = 'blah'
AND db.table.field = " || oven_id || "
AND db.table.field In(" || test_part_id || ")
ORDER BY test_part_id ASC
",  "dataset");&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;&lt;SPAN&gt;Issue we have is the following...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;oven_id: script passes [2,2]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;test_part_id: script passes {"partid1","partid2"}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Questions&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1) how do we select the first value in the oven column to set as the oven_id that gets passed to SQL statement?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2) Oracle appears to not like the parenthese and double quotes. It works if we hard code single quotes and part ids&amp;nbsp; ex: IN('partid1','partid2')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HELP!!!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2018 22:00:09 GMT</pubDate>
    <dc:creator>steve_reinhart</dc:creator>
    <dc:date>2018-02-06T22:00:09Z</dc:date>
    <item>
      <title>JMP 13 JSL that passes variables to oracle SQL statement</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50692#M28806</link>
      <description>&lt;P&gt;I am working with a collegue that has a JMP 13 script to is defining variables using Modal windows.&amp;nbsp; User selection then sets variables that we want to pass into a open database section of our script in the SQL statement.&amp;nbsp; Data table is updated for which oven is selected in the Modal window.&amp;nbsp; We then select the oven column to pass this value into our SQL statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;OvenList={18,22};
nw=New Window( " Reference Units",&amp;lt;&amp;lt;Modal,
     Text Box(" Define the Oven you want"),
     Text Box( ""),
          Panel Box("Select",
          oven_bx = Radio Box( {"Oven 18", "Oven 22"})),
          Text Box(""),
     V List Box(ok_btn=Button Box("OK",
          ov1=oven_bx &amp;lt;&amp;lt; Get;),
          cncl_btn=Button Box ("Cancel")));
 
New Column("Oven",numeric, nominal);
:Oven&amp;lt;&amp;lt; Set Each Value(OvenList[ov1]);
 
oven_id= :Oven &amp;lt;&amp;lt; Get Values;
test_part_id = :ExpNo &amp;lt;&amp;lt; Get Values;
 
Open Database( -- connection string info -- ,
 
"
Select 
db.table.field1
db.table.field2
db.table.field3
FROM db.table
WHERE
db.table.exprmt = 'blah'
AND db.table.field = " || oven_id || "
AND db.table.field In(" || test_part_id || ")
ORDER BY test_part_id ASC
",  "dataset");&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;&lt;SPAN&gt;Issue we have is the following...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;oven_id: script passes [2,2]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;test_part_id: script passes {"partid1","partid2"}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Questions&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1) how do we select the first value in the oven column to set as the oven_id that gets passed to SQL statement?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2) Oracle appears to not like the parenthese and double quotes. It works if we hard code single quotes and part ids&amp;nbsp; ex: IN('partid1','partid2')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HELP!!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 22:00:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50692#M28806</guid>
      <dc:creator>steve_reinhart</dc:creator>
      <dc:date>2018-02-06T22:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 13 JSL that passes variables to oracle SQL statement</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50704#M28814</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Get values&lt;/STRONG&gt; returns a list, so you need to refer to individual array elements in order to use them.&amp;nbsp; You can use &lt;STRONG&gt;concat items&lt;/STRONG&gt; to create an IN list.&amp;nbsp;&amp;nbsp;This will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test_part_in_list = "('" || concat items(test_part_id, "', '") || "')";
sql = 
"Select db.table.field1
        db.table.field2
        db.table.field3
   FROM db.table
  WHERE db.table.exprmt = 'blah'
    AND db.table.field = " || char(oven_id[1]) || "
    AND db.table.field In " || test_part_in_list || "ORDER BY test_part_id ASC";

Open Database( -- connection string info -- , sql, "dataset");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 14:00:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50704#M28814</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-02-05T14:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 13 JSL that passes variables to oracle SQL statement</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50809#M28876</link>
      <description>&lt;P&gt;pmroz,&lt;/P&gt;&lt;P&gt;Thanks for your quick reply and code suggestion.&amp;nbsp; It worked perfect for our application.&amp;nbsp; Thank you very much.&amp;nbsp; We tried all kinds of solutions from various forums using ^var_name^, ^||var_name||^, etc.&amp;nbsp; Your solution by building the list was the solution step we were missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 20:26:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50809#M28876</guid>
      <dc:creator>steve_reinhart</dc:creator>
      <dc:date>2018-02-06T20:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 13 JSL that passes variables to oracle SQL statement</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50810#M28877</link>
      <description>&lt;P&gt;Glad it worked for you.&amp;nbsp; The ^varname^ construct needs to be used with &lt;STRONG&gt;evalinsert&lt;/STRONG&gt;.&amp;nbsp; The use of evalinsert allows somewhat cleaner looking code, and you don't need to convert numbers to strings with char().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test_part_in_list = "('" || concat items(test_part_id, "', '") || "')";
sql = evalinsert(
"Select db.table.field1
        db.table.field2
        db.table.field3
   FROM db.table
  WHERE db.table.exprmt = 'blah'
    AND db.table.field = ^oven_id[1]^
    AND db.table.field In ^test_part_in_list^ ORDER BY test_part_id ASC");

Open Database( -- connection string info -- , sql, "dataset");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 20:36:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50810#M28877</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-02-06T20:36:47Z</dc:date>
    </item>
  </channel>
</rss>

