<?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: A variable value from user - sql query in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/176606#M40176</link>
    <description>&lt;P&gt;The script below has 2 parts: a modal dialog, and a non-modal dialog.&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);

//Modal method
foo = New Window("Insert Data", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result,
	a = Text Edit Box(""), 
	b = Text Edit Box("") 	
);	
show(foo);

If(foo["Button"]!=1, Throw("User did not respond"));

remove from(foo, nitems(foo)); // remove the last item
EvalList(foo);   // now a = the first value and b = the 2nd value
q_str = EvalInsert("DECLARE @StartDateTime datetime = DATEADD(   etc.
		&amp;lt;Column Name=\!"Point\!" Project=\!"^a^\!" Value=\!"^b^\!"/&amp;gt;
		&amp;lt;/Where&amp;gt;
		&amp;lt;/Data&amp;gt;
		&amp;lt;/ScadaPortal&amp;gt;'
		etc.  ");
Show(q_str);		
//uncomment the line below after you have tested the string is correct 		
//dt_ScadaData = Open Database("DRIVER=SQL Server; SERVER=....", q_str);


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Non-Modal Method

//--- Show commands are written to teh LOG not the embedded log


uservalue = New Window("Insert Data", 
	a = Text Edit Box(""), //foo[1]
	b = Text Edit Box(""), //foo[2]
	
	Button Box("OK",
	    foo = Eval List({ a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text});
		show(foo);
		q_str = EvalInsert("DECLARE @StartDateTime datetime = DATEADD(   etc.
		&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
		&amp;lt;/Where&amp;gt;
		&amp;lt;/Data&amp;gt;
		&amp;lt;/ScadaPortal&amp;gt;'
		etc.  ");
		show(q_str);
		wait(0);
        uservalue &amp;lt;&amp;lt; close window();

	 )//end ButtonBox
); //end New Window	

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are the results written in the log, I entered cat and chick, then bull and cow.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 795px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15854i163F95E4F56516BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Feb 2019 06:13:16 GMT</pubDate>
    <dc:creator>gzmorgan0</dc:creator>
    <dc:date>2019-02-27T06:13:16Z</dc:date>
    <item>
      <title>A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174045#M40148</link>
      <description>&lt;P&gt;I try to get a variable value from the user and use it as a SQL query&lt;BR /&gt;How can I add to a query?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Scada.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15830i1EB24F3BB3747E30/image-size/large?v=v2&amp;amp;px=999" role="button" title="Scada.PNG" alt="Scada.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:24:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174045#M40148</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-02-26T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174239#M40149</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;One way to achieve what you want would be by using the Substitiute(). For e.g.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; WhereStatement = " WHERE  [ReadTime] &amp;gt;=  DateTimeStart and [ReadTime] &amp;lt;= DateTimeEnd "; 
WhereStatement = Substitute(WhereStatement, "DateTimeStart", "'" || MyStartTime ||"'", "DateTimeEnd", "'" || MyEndTime||"'");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;In the example shown above, DateTimeStart and DateTimeEnd in the query are being replaced using MyStartTime and MyEndTime which are based on user input.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Similarly in your case you could initialize the SqlQuery as a separate string first, use the Substitute() to replace the strings you want. Once you do that and have the query you want, then query from the database. Let me know if that helps. Small advice for future is, please post JSL using the "JSL" block, so people can easily use the script you post to offer examples&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:34:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174239#M40149</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-02-26T14:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174524#M40151</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;'s suggestion of &lt;A href="https://www.jmp.com/support/help/14-2/list-functions.shtml#2490257" target="_self"&gt;Substitute()&lt;/A&gt; is a good one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another function you may want to familiarize yourself with is &lt;A href="https://www.jmp.com/support/help/14-2/lists-and-expressions.shtml" target="_self"&gt;Eval Insert()&lt;/A&gt;. It can &lt;A href="https://www.jmp.com/support/help/14-2/programming-functions.shtml#5012454" target="_self"&gt;insert variable values into text strings&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myvar="a";

response=eval insert("The correct answer is: ^myvar^");

print(response);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's the log from that code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*:
//:*/
myvar="a";

response=eval insert("The correct answer is: ^myvar^");

print(response);
/*:

"The correct answer is: a"&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 16:07:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/174524#M40151</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2019-02-26T16:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/175102#M40167</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;'s suggestion of &lt;A href="https://www.jmp.com/support/help/14-2/list-functions.shtml#2490257" target="_self"&gt;Substitute()&lt;/A&gt; is a good one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another function you may want to familiarize yourself with is &lt;A href="https://www.jmp.com/support/help/14-2/lists-and-expressions.shtml" target="_self"&gt;Eval Insert()&lt;/A&gt;. It can &lt;A href="https://www.jmp.com/support/help/14-2/programming-functions.shtml#5012454" target="_self"&gt;insert variable values into text strings&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myvar="a";

response=eval insert("The correct answer is: ^myvar^");

print(response);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the log from that code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*:
//:*/
myvar="a";

response=eval insert("The correct answer is: ^myvar^");

print(response);
/*:

"The correct answer is: a"&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for your solution.&lt;/P&gt;&lt;P&gt;Sorry, I'm trying but it doesn't work.&lt;/P&gt;&lt;P&gt;Please, can you explain to me?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 21:38:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/175102#M40167</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-02-26T21:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/175982#M40170</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Please post what you have tried using "JSL" block shown here and a snapshot of the log if possible, that way the users in the community can try and understand what is not working for you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 00:12:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/175982#M40170</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-02-27T00:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/176580#M40175</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;, the uservalue window is non-modal. So the JSL below the New Window tries to run before the user gets a chance to select the button.&lt;/P&gt;
&lt;P&gt;Do you know how to make a dialog modal, or how to run the query as part of the OK button?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 05:11:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/176580#M40175</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-02-27T05:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/176606#M40176</link>
      <description>&lt;P&gt;The script below has 2 parts: a modal dialog, and a non-modal dialog.&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);

//Modal method
foo = New Window("Insert Data", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result,
	a = Text Edit Box(""), 
	b = Text Edit Box("") 	
);	
show(foo);

If(foo["Button"]!=1, Throw("User did not respond"));

remove from(foo, nitems(foo)); // remove the last item
EvalList(foo);   // now a = the first value and b = the 2nd value
q_str = EvalInsert("DECLARE @StartDateTime datetime = DATEADD(   etc.
		&amp;lt;Column Name=\!"Point\!" Project=\!"^a^\!" Value=\!"^b^\!"/&amp;gt;
		&amp;lt;/Where&amp;gt;
		&amp;lt;/Data&amp;gt;
		&amp;lt;/ScadaPortal&amp;gt;'
		etc.  ");
Show(q_str);		
//uncomment the line below after you have tested the string is correct 		
//dt_ScadaData = Open Database("DRIVER=SQL Server; SERVER=....", q_str);


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Non-Modal Method

//--- Show commands are written to teh LOG not the embedded log


uservalue = New Window("Insert Data", 
	a = Text Edit Box(""), //foo[1]
	b = Text Edit Box(""), //foo[2]
	
	Button Box("OK",
	    foo = Eval List({ a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text});
		show(foo);
		q_str = EvalInsert("DECLARE @StartDateTime datetime = DATEADD(   etc.
		&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
		&amp;lt;/Where&amp;gt;
		&amp;lt;/Data&amp;gt;
		&amp;lt;/ScadaPortal&amp;gt;'
		etc.  ");
		show(q_str);
		wait(0);
        uservalue &amp;lt;&amp;lt; close window();

	 )//end ButtonBox
); //end New Window	

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are the results written in the log, I entered cat and chick, then bull and cow.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 795px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15854i163F95E4F56516BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 06:13:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/176606#M40176</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-02-27T06:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/181649#M40263</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Thanks for your solution!&lt;/P&gt;&lt;P&gt;The script still&amp;nbsp;doesn't work :(&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to insert the parameters, it shows me the following message -&amp;nbsp;&lt;STRONG&gt;"Name Unresolved: erver in access or evaluation of 'erver' , erver"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Although I run the script with the following command - &lt;STRONG&gt;Names default to here(1);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&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);
uservalue = New Window("Insert Data", 
	a = Text Edit Box(""), //foo[1]
	b = Text Edit Box(""), //foo[2]
	
	Button Box("OK",
	    foo = Eval List({ a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text});
		show(foo);
		
q_str = EvalInsert("DRIVER=SQL Server;SERVER= ----;Trusted_Connection=Yes",
"DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 
DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 
EXEC ListData @Criteria='
&amp;lt;ScadaPortal&amp;gt;
  &amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
    &amp;lt;Where&amp;gt;
		&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
    &amp;lt;/Where&amp;gt;
  &amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime","Scada Data");
		show(q_str);
		wait(0);
        uservalue &amp;lt;&amp;lt; close window();
        )
        );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 504px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15911iDB0D6FE3CF851792/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 10:09:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/181649#M40263</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-02T10:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/181650#M40264</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log -&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;foo = {"DS", "FD"};

Name Unresolved: erver in access or evaluation of 'erver' , erver

//:*/

Names default to here(1);
uservalue = New Window("Insert Data", 
	a = Text Edit Box(""), //foo[1]
	b = Text Edit Box(""), //foo[2]
	
	Button Box("OK",
	    foo = Eval List({ a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text});
		show(foo);
		
q_str = EvalInsert("DRIVER=SQL Server;SERVER=-----;Trusted_Connection=Yes",
"DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 
DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 
EXEC ListData @Criteria='
&amp;lt;ScadaPortal&amp;gt;
  &amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
    &amp;lt;Where&amp;gt;
		&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
    &amp;lt;/Where&amp;gt;
  &amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime","Scada Data");
		show(q_str);
		wait(0);
        uservalue &amp;lt;&amp;lt; close window();
        )
        );
/*:

DisplayBox[]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 10:19:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/181650#M40264</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-02T10:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182042#M40267</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I think the reason you were running into the error was because of the way your string had commas and other separators. I re-wrote your script and I am providing it below:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );
					     q_str = "DRIVER=SQL Server;SERVER=MyServer;Trusted_Connection=Yes,
				DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 
				DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 
			        EXEC ListData @Criteria='
																		   &amp;lt;ScadaPortal&amp;gt;
																				  &amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
																					&amp;lt;Where&amp;gt;
																						&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
																					&amp;lt;/Where&amp;gt;
																				  &amp;lt;/Data&amp;gt;
																				&amp;lt;/ScadaPortal&amp;gt;'
																				, @StartDateTime=@StartDateTime
																				, @EndDateTime=@EndDateTime
																							Scada Data" ;
				Show(q_str);
				Eval Insert(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also, a couple of suggestions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. When you are constructing display boxes, separate them out and build them independently&amp;nbsp;&lt;BR /&gt;2. When using statements like Eval, always define your string or statement separately, it will help you to isolate the error and see which line of code is introducing the error&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 03:02:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182042#M40267</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-03-03T03:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182546#M40269</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your solution and the&amp;nbsp;&lt;SPAN&gt;explanation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I try to run the script and insert the data into the box panel. When I try to press OK button nothing happens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, see log below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );	
						  				    
q_str = "DRIVER=SQL Server;SERVER=My Server;Trusted_Connection=Yes,				
 DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 				
 DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 			       
  EXEC ListData @Criteria='																		   
  &amp;lt;ScadaPortal&amp;gt;	
&amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
&amp;lt;Where&amp;gt;
&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
&amp;lt;/Where&amp;gt;
&amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime
Scada Data" ;
				Show(q_str);
				Eval Insert(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Mar 2019 12:16:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182546#M40269</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-03T12:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182555#M40270</link>
      <description>&lt;P&gt;I think you need to change the code&amp;nbsp; &lt;STRONG&gt;q_str = Eval Insert(q_str)&lt;/STRONG&gt; or &lt;STRONG&gt;Eval Insert Into(q_str)&amp;nbsp;&lt;/STRONG&gt;. Eval Insert Into() with change the value of its argument and it must be a sttored value like q_str; Eval Insert() just returns a string, it does not change its argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;				Show(q_str);
				q_str = Eval Insert(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Mar 2019 12:39:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182555#M40270</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-03-03T12:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182556#M40271</link>
      <description>&lt;P&gt;It still doesn't work :(&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 12:51:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182556#M40271</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-03T12:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182578#M40273</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp;When you say it didn't work, can you explain what you are seeing.&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;was correct in catching my fault, where I should have used Eval Insert Into instead of Eval Insert :&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 805px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15920iB7C3567EA02C93B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also, are you replacing the Server name in the string shown above ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, you are only constructing the string so far, you need actually run the string after constructing it to see the results as shown in the example below from the Scripting Index :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ex = "Today is ^As Date( Today())^";
Eval Insert Into( ex );
ex;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Mar 2019 14:47:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182578#M40273</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-03-03T14:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182579#M40274</link>
      <description>&lt;P&gt;Please post your log. This script is not running a query, it is just writing the result of the query command to the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which version of JMP are you using?&amp;nbsp; JMP has a Query Builder.&amp;nbsp; You could create that query to prompt for the two fields you need. Then you can save the script, or the query.&amp;nbsp; There are multiple points of failure for a query,&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Incorrect query syntax, note that case can be important.&amp;nbsp; So if a user is typing in harry, but the db field is HARRY, then the result will be empty.&amp;nbsp; Also SQL quires quotes around a value with spaces or special characters. So &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;first&lt;/STRONG&gt;&lt;/FONT&gt;, get a script to work without the prompt, that is hardcode the values of the prompt and run the portion of code&amp;nbsp; &amp;nbsp;dtScadaData =&amp;nbsp; Open Database(etc.)&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;Once the hardcoded script works, then try the prompt typing in exactly what was hardcoded above.&amp;nbsp; Also print out&amp;nbsp; the string and compare.mple,&lt;/LI&gt;
&lt;LI&gt;The query login can be a point of failure&lt;/LI&gt;
&lt;LI&gt;Your connection string to the db driver may not be the same as another users.&amp;nbsp; For example, I set up the driver for Excel to be named Excel Files, someone else might have a different name.&lt;/LI&gt;
&lt;LI&gt;Other user privileges might be different than yours, they might not have access to the files/tables.&lt;/LI&gt;
&lt;LI&gt;I am sure there are more,&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I see that&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;&amp;nbsp;just responded. So I will stope now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 14:56:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182579#M40274</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-03-03T14:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182604#M40275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;What version of SQL Server are you running?&lt;/P&gt;
&lt;P&gt;It appears that you might have an evaluation copy of SQL Server that has expired.&lt;/P&gt;
&lt;P&gt;Can you verify your SQL Server is not running in evaluation mode?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Stan&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 15:12:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/182604#M40275</guid>
      <dc:creator>stan_koprowski</dc:creator>
      <dc:date>2019-03-03T15:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183369#M40281</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;The script that&amp;nbsp;the &amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;sent me, doesn't work - see JSL below&lt;/P&gt;&lt;P&gt;Sure, i replaced the server to my server.&lt;/P&gt;&lt;P&gt;Please, any help to fix the script.&lt;/P&gt;&lt;P&gt;Thx.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );	
						  				    
q_str = "DRIVER=SQL Server;SERVER=My Server;Trusted_Connection=Yes,				
 DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 				
 DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 			       
  EXEC ListData @Criteria='																		   
  &amp;lt;ScadaPortal&amp;gt;	
&amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
&amp;lt;Where&amp;gt;
&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
&amp;lt;/Where&amp;gt;
&amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime
Scada Data" ;
				Show(q_str);
				Eval Insert(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2019 09:15:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183369#M40281</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-04T09:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183427#M40283</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;The script that&amp;nbsp;the &amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;sent me, doesn't work - see JSL below&lt;/P&gt;&lt;P&gt;Sure, i replaced the server to my server.&lt;/P&gt;&lt;P&gt;Please, any help to fix the script.&lt;/P&gt;&lt;P&gt;Thx.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );	
						  				    
q_str = "DRIVER=SQL Server;SERVER=My Server;Trusted_Connection=Yes,				
 DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 				
 DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 			       
  EXEC ListData @Criteria='																		   
  &amp;lt;ScadaPortal&amp;gt;	
&amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
&amp;lt;Where&amp;gt;
&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
&amp;lt;/Where&amp;gt;
&amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime
Scada Data" ;
				Show(q_str);
				Eval Insert(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 10:52:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183427#M40283</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-04T10:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183466#M40287</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13542"&gt;@Botzal&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;You need to look at the advice we already gave you and try to follow it. Please help us help you. When you say, it is not working, we don't know or can't see what is going on. It will help us troubleshoot if you can provide clear detail of what you are saying and why you think it does not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Did you validate the query works by itself ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Please paste the log&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. You are not evaluating the string as I have shown previously. Kindly evaluate the string by calling it out after it is constructed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );	
						  				    
q_str = "DRIVER=SQL Server;SERVER=My Server;Trusted_Connection=Yes,				
 DECLARE @StartDateTime  datetime = DATEADD(day, -2, CAST(GETDATE() AS varchar(11))) 				
 DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 			       
  EXEC ListData @Criteria='																		   
  &amp;lt;ScadaPortal&amp;gt;	
&amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
&amp;lt;Where&amp;gt;
&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;
&amp;lt;/Where&amp;gt;
&amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime
Scada Data" ;
				Show(q_str);
				Eval Insert(q_str); 
				Show(q_str); 
                                q_str; // evaluating the query you constructed 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:57:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/183466#M40287</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-03-04T13:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: A variable value from user - sql query</title>
      <link>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/184343#M40343</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;Thanks for your solution.&lt;/P&gt;&lt;P&gt;I tried to apply your advice but it didn't work. :\&lt;/img&gt;&lt;/P&gt;&lt;P&gt;1. The Query works - When I &lt;STRONG&gt;insert numbers in a script&lt;/STRONG&gt; and &lt;STRONG&gt;don't variables from the user&lt;/STRONG&gt;. For examples - Instead of foo[1], I insert p123 and&amp;nbsp;Instead of oo[2], I insert v123.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_ScadaData = Open Database("DRIVER=SQL Server;SERVER=My Server ;Trusted_Connection=Yes",
"DECLARE @StartDateTime  datetime = DATEADD(day, -1, CAST(GETDATE() AS varchar(11))) -- 17 Days Back 
DECLARE @EndDateTime   datetime = DATEADD(day,1, GETDATE()) 

EXEC ListData @Criteria='
&amp;lt;ScadaPortal&amp;gt;
  &amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
    &amp;lt;Where&amp;gt;
   
&amp;lt;Column Name=\!"Point\!" Project=\!"p123\!" Value=\!"v123\!"/&amp;gt;

    &amp;lt;/Where&amp;gt;
  &amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime","Scada Data");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;2. The log -&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;foo = {"P123", "V123"};
//:*/

LB = Lineup Box(1); 
LB &amp;lt;&amp;lt; Append(
		PB_Inputs = Panel Box("User Inputs",
				       a = Text Edit Box( "" ), //foo[1]
				       b = Text Edit Box( "" ), // foo[2]
				    );
	   );
MyUI = V List Box(LB, 
		  BB_UserInputUnload = Button Box("Ok",
						  foo = Eval List( {a &amp;lt;&amp;lt; get text, b &amp;lt;&amp;lt; get text} );
						  Show( foo );	
					  				    

q_str ="DRIVER=SQL Server;SERVER=My Server;Trusted_Connection=Yes",
"DECLARE @StartDateTime  datetime = DATEADD(day, -1, CAST(GETDATE() AS varchar(11))) -- 17 Days Back 
DECLARE @EndDateTime   datetime = DATEADD(day,0, GETDATE()) 

EXEC ListData @Criteria='
&amp;lt;ScadaPortal&amp;gt;
  &amp;lt;Data Name=\!"PointData\!" Format=\!"Wide\!" Interval=\!"60m\!"&amp;gt;
    &amp;lt;Where&amp;gt;
    
&amp;lt;Column Name=\!"Point\!" Project=\!"^foo[1]^\!" Value=\!"^foo[2]^\!"/&amp;gt;

    &amp;lt;/Where&amp;gt;
  &amp;lt;/Data&amp;gt;
&amp;lt;/ScadaPortal&amp;gt;'
, @StartDateTime=@StartDateTime
, @EndDateTime=@EndDateTime","Scada Data";

	Show(q_str);
				q_str = Eval Insert INTO(q_str); 
				Show(q_str); 
												 ),
				 );
NW = New Window("User Input Collection Window",
				VLB = V List Box(); 
			   ); 
VLB &amp;lt;&amp;lt; Append(MyUI);

/*:&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3. Can you see the script in chapter 2 that I apply your advice,&amp;nbsp;If I understood you correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 21:48:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-variable-value-from-user-sql-query/m-p/184343#M40343</guid>
      <dc:creator>Botzal</dc:creator>
      <dc:date>2019-03-06T21:48:26Z</dc:date>
    </item>
  </channel>
</rss>

