<?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: Placing User Interface Data into an SQL query in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417777#M66696</link>
    <description>&lt;P&gt;If i put the number 10 instead of ^current_days^ in your script, it works correctly.&lt;/P&gt;&lt;P&gt;But with the ^current_days^, it gives an Error ORA-00936 (missing expression)&lt;/P&gt;&lt;P&gt;So i still can't get the data from the text box and put it into the query&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 15:27:37 GMT</pubDate>
    <dc:creator>Tom_P</dc:creator>
    <dc:date>2021-09-13T15:27:37Z</dc:date>
    <item>
      <title>Placing User Interface Data into an SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417006#M66613</link>
      <description>&lt;P&gt;I've found tons of creating user interface examples, but there aren't that many discussions explaining how to handle/manipulate user data.&amp;nbsp; I'm struggling getting data from a text box (# of days) and using that in an expression On_OK.&amp;nbsp; I also want to then use data as a string in an sql query for days.&amp;nbsp; In the past i would set a global variable ::DATETIMESTUFF="10" and then i could put that into&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE A.SCANDATETIME&amp;gt;(SYSDATE-"|| ::DATETIMESTUFF || ")&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;ui = New Window( "Choose an option",
	&amp;lt;&amp;lt;Modal,
	V List Box(
		Text Box( "Query Last 'x' Number of days:" ),
		Spacer Box( Size( 20, 20 ) ),
		days = Text Edit Box( "" )		
	),
	Button Box( "Ok", 
	current_days = days &amp;lt;&amp;lt; Get Text; 
	On_OK() 
	)
);

On_OK = Expr(

	::DATETIMESTUFF = current_days;
	
	Open Database("DSN=xxx;UID=xxxxx;PWD=xxxxx;",
	"Select	*
	from DATABASE A
	WHERE A.SCANDATETIME&amp;gt;(SYSDATE-"|| ::DATETIMESTUFF || ")
    ",
		"Table1"
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:56:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417006#M66613</guid>
      <dc:creator>Tom_P</dc:creator>
      <dc:date>2023-06-09T19:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Placing User Interface Data into an SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417318#M66640</link>
      <description>&lt;P&gt;Try this.&amp;nbsp; You need to put on_ok above the new window().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;On_OK = Expr(
	Open Database("DSN=xxx;UID=xxxxx;PWD=xxxxx;", sql_statement, "Table1");
);

ui = New Window( "Choose an option",
	&amp;lt;&amp;lt;Modal,
	V List Box(
		Text Box( "Query Last 'x' Number of days:" ),
		Spacer Box( Size( 20, 20 ) ),
		days = number Edit Box( "" )		
	),
	Button Box( "Ok", 
		current_days = days &amp;lt;&amp;lt; Get; 
		On_OK
	),
);

sql_statement = evalinsert(
"Select	*
   from DATABASE A
  WHERE A.SCANDATETIME &amp;gt; (SYSDATE - ^current_days^)");
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Sep 2021 18:58:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417318#M66640</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2021-09-10T18:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Placing User Interface Data into an SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417777#M66696</link>
      <description>&lt;P&gt;If i put the number 10 instead of ^current_days^ in your script, it works correctly.&lt;/P&gt;&lt;P&gt;But with the ^current_days^, it gives an Error ORA-00936 (missing expression)&lt;/P&gt;&lt;P&gt;So i still can't get the data from the text box and put it into the query&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 15:27:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417777#M66696</guid>
      <dc:creator>Tom_P</dc:creator>
      <dc:date>2021-09-13T15:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Placing User Interface Data into an SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417854#M66699</link>
      <description>&lt;P&gt;Try using a function instead of an expression.&amp;nbsp; Also you can inspect the values of your variables by hovering over the variable itself, or using the show() command and looking at the log window.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;On_OK = function({curr_days},
	sql_statement = evalinsert(
"Select	*
   from DATABASE A
  WHERE A.SCANDATETIME &amp;gt; (SYSDATE - ^curr_days^)");

	show(curr_days, sql_statement);
	Open Database("DSN=xxx;UID=xxxxx;PWD=xxxxx;", sql_statement, "Table1");
);

ui = New Window( "Choose an option",
	&amp;lt;&amp;lt;Modal,
	V List Box(
		Text Box( "Query Last 'x' Number of days:" ),
		Spacer Box( Size( 20, 20 ) ),
		days = number Edit Box( "" )		
	),
	Button Box( "Ok", 
		current_days = days &amp;lt;&amp;lt; Get; 
		On_OK(current_days);
	),
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Sep 2021 18:58:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417854#M66699</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2021-09-13T18:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Placing User Interface Data into an SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417863#M66700</link>
      <description>&lt;P&gt;PMROZ...both solutions worked.&amp;nbsp; I really appreciate it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 19:13:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Placing-User-Interface-Data-into-an-SQL-query/m-p/417863#M66700</guid>
      <dc:creator>Tom_P</dc:creator>
      <dc:date>2021-09-13T19:13:53Z</dc:date>
    </item>
  </channel>
</rss>

