inserire la stringa dalla casella di testo nell'istruzione SQL nello script JSLSalve, sto provando per la prima volta un'applicazione jmp.
Vorrei inserire una stringa da una casella di testo in un'istruzione SQL utilizzata per una query JMP a un database. Questa stringa è il mio parametro di ricerca.
Lo script che ho realizzato non sembra funzionare e la soluzione è probabilmente semplice, ma mi manca una comprensione della sintassi JSL di base e speravo di ottenere aiuto per superare questo punto, per me, cruciale.
Lo script per chiamare e ottenere la stringa:
parameterScript = Function( {this},
{text},
// This function is called when the Text Edit Box value is committed
input = this << Get Text
);
Lo script per interrogare il database:
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 + \!";" )
) << Run;
<<GET button="" name=""></GET>
Grazie !
ScriptingRi: inserire la stringa dalla casella di testo nell'istruzione SQL nello script JSLGrazie mille, questo ha funzionato
Ri: inserire la stringa dalla casella di testo nell'istruzione SQL nello script JSLProva qualcosa del genere.Nota l'uso di evalinsert, panelbox, hlistbox, ecc. Cercali nell'indice degli script per maggiori informazioni.
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 )
) << Run;
);
nw = new window("Example Input for SQL",
panelbox("Parameter Specification",
hlistbox(
text box("Enter value for parameter: "),
teb = text edit box("", << set width(200)),
),
),
panelbox("Actions",
hlistbox(
button box("Cancel", nw << close window),
button box("OK",
pvalue = teb << get text;
if (pvalue == "",
ew = new window("Error", << modal,
text box("Nothing specified")
);
,
// else import the data
importdatapress(pvalue);
nw << close window;
);
),
),
),
);Ri: inserire la stringa dalla casella di testo nell'istruzione SQL nello script JSLDovresti iniziare costruendo blocchi più piccoli e imparando la sintassi (come concatenare le stringhe in JMP, come funzionano gli spazi dei nomi/le funzioni e così via)
Alcuni suggerimenti sui materiali:
Riferimento alla sintassi JSL
Guida agli script JMP15
Indice di scripting trovato nel menu Help di JMP
Esempio molto breve (controlla il registro quando modifichi il testo nella finestra):
Names Default To Here(1);
importDataPress=Function({this},
retVal = this << get text;
sqlString = "select * from * where " || retVal;
Show(sqlString);
);
win = New Window("Example", Text Edit Box("Example Text",
<< set function(
function({this},
importDataPress(this)
)
))
);