<?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: insert string from textbox in SQL statement in JSL script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/372937#M62282</link>
    <description>&lt;P&gt;You should start this by building smaller blocks and learning the syntax (how to concatenate strings in JMP, how namespaces/functions work, and so on)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some material suggestions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.0/#page/jmp/jsl-functions.shtml#" target="_self"&gt;JSL Syntax Reference&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/documentation/onlinedoc/jmp/15/Scripting-Guide.pdf" target="_self"&gt;JMP15 Scripting Guide&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scriping Index found from JMP Help menu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very short example (check log when you change text in the window):&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);

importDataPress=Function({this},
	retVal = this &amp;lt;&amp;lt; get text;
	sqlString = "select * from * where " || retVal;
	Show(sqlString);
);

win = New Window("Example", Text Edit Box("Example Text", 
	&amp;lt;&amp;lt; set function(
		function({this},
			importDataPress(this)
		)
	))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 09:35:59 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-03-31T09:35:59Z</dc:date>
    <item>
      <title>insert string from textbox in SQL statement in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/372908#M62279</link>
      <description>&lt;P&gt;Hi, I am taking my first stab at a jmp application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to insert a string from a textbox in a SQL statement used for a JMP query to a database. This string is my search parameter.&lt;/P&gt;
&lt;P&gt;The script I have made does not seem to work and the solution is probably straight forward - but I am missing some basic JSL syntax understanding and was hoping to get help getting past this, for me, crucial point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script for calling and getting the string:&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;parameterScript = Function( {this},
    {text}, 
// This function is called when the Text Edit Box value is committed
    input = this &amp;lt;&amp;lt; Get Text
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script for querying the database:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;importDataPress = Function( {this}, 
// This function is called when the button is pressed
    name = New SQL Query(
        Connection( "ODBC:DSN=DATABASE;PWD=XXX;" ),
        QueryName( "my_table" ),
        CustomSQL( "SELECT * FROM DATABASE WHERE parameter == \!" + input + \!";" )
    ) &amp;lt;&amp;lt; Run;
    &amp;lt;&amp;lt;Get Button Name;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:10:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/372908#M62279</guid>
      <dc:creator>CSkjodt</dc:creator>
      <dc:date>2023-06-09T22:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: insert string from textbox in SQL statement in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/372937#M62282</link>
      <description>&lt;P&gt;You should start this by building smaller blocks and learning the syntax (how to concatenate strings in JMP, how namespaces/functions work, and so on)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some material suggestions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.0/#page/jmp/jsl-functions.shtml#" target="_self"&gt;JSL Syntax Reference&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/documentation/onlinedoc/jmp/15/Scripting-Guide.pdf" target="_self"&gt;JMP15 Scripting Guide&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scriping Index found from JMP Help menu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very short example (check log when you change text in the window):&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);

importDataPress=Function({this},
	retVal = this &amp;lt;&amp;lt; get text;
	sqlString = "select * from * where " || retVal;
	Show(sqlString);
);

win = New Window("Example", Text Edit Box("Example Text", 
	&amp;lt;&amp;lt; set function(
		function({this},
			importDataPress(this)
		)
	))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 09:35:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/372937#M62282</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-03-31T09:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: insert string from textbox in SQL statement in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/373912#M62356</link>
      <description>&lt;P&gt;Try something like this.&amp;nbsp; Note the use of evalinsert, panelbox, hlistbox, etc.&amp;nbsp; Look them up in the scripting index for more information.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;importDataPress = Function( {parameter_value}, 
	sql_statement = evalinsert(
"SELECT * FROM DATABASE WHERE parameter = '^parameter_value^'");

	show(sql_statement);
// This function is called when the button is pressed
    name = New SQL Query(
        Connection( "ODBC:DSN=DATABASE;PWD=XXX;" ),
        QueryName( "my_table" ),
        CustomSQL( sql_statement )
    ) &amp;lt;&amp;lt; Run;
);

nw = new window("Example Input for SQL",
	panelbox("Parameter Specification",
		hlistbox(
			text box("Enter value for parameter: "),
			teb = text edit box("", &amp;lt;&amp;lt; set width(200)),
		),
	),
	panelbox("Actions",
		hlistbox(
			button box("Cancel", nw &amp;lt;&amp;lt; close window),
			button box("OK",
				pvalue = teb &amp;lt;&amp;lt; get text;
				if (pvalue == "",
					ew = new window("Error", &amp;lt;&amp;lt; modal,
						text box("Nothing specified")
					);
					,
					// else import the data
					importdatapress(pvalue);
					nw &amp;lt;&amp;lt; close window;
				);
			),
		),
	),
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Apr 2021 12:54:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/373912#M62356</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2021-04-02T12:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: insert string from textbox in SQL statement in JSL script</title>
      <link>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/374603#M62437</link>
      <description>Thank you so much, this did the trick :)&lt;/img&gt;</description>
      <pubDate>Tue, 06 Apr 2021 12:33:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/insert-string-from-textbox-in-SQL-statement-in-JSL-script/m-p/374603#M62437</guid>
      <dc:creator>CSkjodt</dc:creator>
      <dc:date>2021-04-06T12:33:20Z</dc:date>
    </item>
  </channel>
</rss>

