<?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 assign Multiple values to SQL variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466420#M71018</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;is on the right track.&amp;nbsp; Print out the SQL code and try running it manually in SQL server.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would point a variable at the data table to avoid scoping errors.&lt;/P&gt;
&lt;P&gt;This is what your SQL code looks like:&lt;/P&gt;
&lt;PRE&gt;DECLARE @SPEC1 VARCHAR (50)
SET @SPEC1 = '{"F14CDCE", "F141CDC5", "F141CDLU"}'
SELECT t1.[vcLotCode] 
FROM [dbo].[vSMTDatat]  t1 
WHERE  (  (  (  ( t1.[vcLotCode] IN  ( @SPEC1 )  )  )  ) ;&lt;/PRE&gt;
&lt;P&gt;Will that work in SQL Server?&amp;nbsp; In Oracle I create IN lists and substitute them like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Point dt to your table of values
dt = New Table( "SpecValues", Add Rows( 3 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"F14CDCE", "F141CDC5", "F141CDLU"} ) )
);

// Relevant section to create IN list
			Button Box( "OK",
				specVal = dt:Column 1 &amp;lt;&amp;lt; Get Values;
				spec_in_list = "'" || concat items(specval, "', '") || "'";
				specVal1 = Start_date &amp;lt;&amp;lt; get text();
				specVal2 = End_date &amp;lt;&amp;lt; get text();
			),

// SQL Code
	SQL = Eval Insert(
"SELECT t1.[vcLotCode] 
   FROM [dbo].[vSMTDatat]  t1 
  WHERE  (  (  (  ( t1.[vcLotCode] IN  ( ^spec_in_list^ )  )  )  ) ;" // Input from the user
	) ; 
	write(sql);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Mar 2022 21:39:42 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2022-03-02T21:39:42Z</dc:date>
    <item>
      <title>How to assign Multiple values to SQL variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466258#M71005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to input multiple values from the jmp file into SQL variable. Something doesn't seem to work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;User will input the following file and the columns values are stored in the variable&amp;nbsp;&lt;CODE class=" language-jsl"&gt;specVal .&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;I declared&amp;nbsp;@ SPEC = ^specVal^ (Contains 3 values ) in SQL&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_0-1646239513636.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40441iB5A1A6477AA7F679/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1646239513636.png" alt="Jacksmith12_0-1646239513636.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something doesn't seem to be correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 );
Clear Globals();
Clear Log();

specVal = "";
NW = New Window( "DLT Data",
	&amp;lt;&amp;lt;Modal(),
	&amp;lt;&amp;lt;Return Result,
	Text Box( "" ),
	Spacer Box( Size( 20, 10 ) ), 
	
	Lineup Box( N Col( 3 ), Text Box( "Lot id" ), Spacer Box( Size( 20, 20 ) ), lotnum = Text Edit Box( "F141", &amp;lt;&amp;lt;set width( 100 ) ) ),
	Panel Box( , Button Box( "Select file", dt = Open() ) ), 
	
	Spacer Box( Size( 20, 20 ) ),
	H List Box(
		Text Box( "Start data" ), 
	
		Start_date = Text Edit Box( "1/1/2022", &amp;lt;&amp;lt;set width( 60 ) )
	),
	Lineup Box( N Col( 2 ), Text Box( "End data" ), End_date = Text Edit Box( "", &amp;lt;&amp;lt;set width( 60 ) ) ), 
	
	Panel Box( ,
		H List Box(
			Button Box( "OK",
				specVal = :Column 1 &amp;lt;&amp;lt; Get Values;
				specVal1 = Start_date &amp;lt;&amp;lt; get text();
				specVal2 = End_date &amp;lt;&amp;lt; get text();
			),
			Button Box( "Cancel" )
		)
	)
	
,
	&amp;lt;&amp;lt;Size Window( 250, 300 ) 
	//Button Box( "OK", specVal = specCB &amp;lt;&amp;lt; get text())				
);


If( specVal != "", 

	(ODBC = Create Database Connection( "DSN=xxx;;UID=xxx;PWD=;APP=JMP;WSID=xxx;DATABASE=xxx;" ) ; 
	
	SQL =
	Eval Insert(
		"

DECLARE @SPEC1 VARCHAR (50)


SET @SPEC1 = '^specVal^'

SELECT t1.[vcLotCode] 
FROM [dbo].[vSMTDatat]  t1 
WHERE  (  (  (  ( t1.[vcLotCode] IN  ( @SPEC1 )  )  )  ) ;" // Input from the user
	) ; 

	DT = Execute SQL( ODBC, SQL, "DLT Data" ) &amp;lt;&amp;lt; Maximize window ; 

	
	Close Database Connection( ODBC ) ; 
	
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:12:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466258#M71005</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T18:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Multiple values to SQL variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466338#M71009</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 20:00:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466338#M71009</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2022-03-02T20:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Multiple values to SQL variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466409#M71014</link>
      <description>&lt;P&gt;I would suggest printing the SQL-query to see that it is being built as you want it to be built.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 21:11:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466409#M71014</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-02T21:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Multiple values to SQL variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466420#M71018</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;is on the right track.&amp;nbsp; Print out the SQL code and try running it manually in SQL server.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would point a variable at the data table to avoid scoping errors.&lt;/P&gt;
&lt;P&gt;This is what your SQL code looks like:&lt;/P&gt;
&lt;PRE&gt;DECLARE @SPEC1 VARCHAR (50)
SET @SPEC1 = '{"F14CDCE", "F141CDC5", "F141CDLU"}'
SELECT t1.[vcLotCode] 
FROM [dbo].[vSMTDatat]  t1 
WHERE  (  (  (  ( t1.[vcLotCode] IN  ( @SPEC1 )  )  )  ) ;&lt;/PRE&gt;
&lt;P&gt;Will that work in SQL Server?&amp;nbsp; In Oracle I create IN lists and substitute them like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Point dt to your table of values
dt = New Table( "SpecValues", Add Rows( 3 ),
	New Column( "Column 1", Character, "Nominal",
		Set Values( {"F14CDCE", "F141CDC5", "F141CDLU"} ) )
);

// Relevant section to create IN list
			Button Box( "OK",
				specVal = dt:Column 1 &amp;lt;&amp;lt; Get Values;
				spec_in_list = "'" || concat items(specval, "', '") || "'";
				specVal1 = Start_date &amp;lt;&amp;lt; get text();
				specVal2 = End_date &amp;lt;&amp;lt; get text();
			),

// SQL Code
	SQL = Eval Insert(
"SELECT t1.[vcLotCode] 
   FROM [dbo].[vSMTDatat]  t1 
  WHERE  (  (  (  ( t1.[vcLotCode] IN  ( ^spec_in_list^ )  )  )  ) ;" // Input from the user
	) ; 
	write(sql);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 21:39:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466420#M71018</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2022-03-02T21:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Multiple values to SQL variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466628#M71043</link>
      <description>&lt;P&gt;I really appreciate this. Thanks a LOT&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 14:44:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-assign-Multiple-values-to-SQL-variable/m-p/466628#M71043</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2022-03-03T14:44:34Z</dc:date>
    </item>
  </channel>
</rss>

