텍스트 상자에 입력된 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?I'm a beginner with application builders and I want to achieve the following: I'm currently retrieving data from a database using SQL with a specific time period. However, instead of directly modifying the SQL code to change the period, I want to be able to change it via a GUI. I'm currently executing this with JSL, and I want to replace the [HERE] part of the SQL query.
JSL 예시:
// Get a handle to the data table
dt = Current Data Table();
unique = Function({a}, // input: List, output: List
{aa=Associative Array(),nr=NItems(a),i,aKeys,nUnique,aUnique={}},
For( i=1, i<=nr, i++, aa << insert( a[i] ) );
aKeys = aa << GetKeys;
nUnique = NItems( aKeys );
For( i = 1, i <= nUnique, i++, InsertInto(aUnique,aKeys[i]) );
aUnique
);
dofun = Function({},{months,varName,dType},
months = SampleRateInput << Get;
varName = VarList << GetSelected;
dType = Column(dt,varName[1]) << GetDataType( "English");
If(dType!="Character",
Dialog(Title("Alert"),"Data Type of Variable should be Character. ");
Throw()
);
dt << ClearSelect;
dt << SelectRows( selIdx );
);
OKButtonPress=Function({this},
// This function is called when the OK button is pressed
(thisModuleInstance << Get Box) << Close Window;
dofun;
);
CancelButtonPress=Function({this},
// This function is called when the Cancel button is pressed
(thisModuleInstance << Get Box) << Close Window;
);
New SQL Query(
Version( 130 ),
Connection( ),
QueryName( ),
Select( ),
From(
Table( ),
),
Where(
Custom(
"t1.msr_dt >= DATEADD(month, -[HERE], CURRENT_DATE)",
UI( Custom( Base( "Continuous" ) ) )
)
)
) << Run Foreground( UpdateTable( Current Data Table() ) );
데이터 액세스Re: 텍스트 상자에 입력된 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?제 JMP 버전은 19입니다.
Re: 텍스트 상자에 입력된 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?값을 변경하는 데 사용할 사용자 지정 GUI가 있나요? 해당 값을 추출할 수 있나요? (적어도 JMP18에서는) Where(Custom()) 블록 내에서 변수를 평가하면 될 것 같습니다.
Names Default To Here(1);
myval = 150;
dt = New SQL Query(
Version(130),
Connection("JMP"),
JMP Tables(["Big Class" => "\C:\Program Files\JMP\JMPPRO\18\Samples\Data\Big Class.jmp"]),
QueryName("SQLQuery2"),
Select(Column("name", "t1")),
From(Table("SQLQuery1", Alias("t1"))),
Where(
Custom(
Eval Insert("t1.weight >= ^myval^"),
UI(Custom(Base("Continuous"))))
)
) << Run Foreground;
Re: 텍스트 상자에 입력한 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?jthi-san, Arigatougozaimasu.
앞서 JSL에서 설명한 GUI는 샘플 애플리케이션의 JSL을 약간 간소화한 버전입니다. 제가 실제로 만들고 싶은 GUI는 첨부된 이미지와 같습니다.
SQL 명령문 내에서 변수를 '^'로 묶어 전달할 수 있다는 걸 알았습니다!
GUI에서 확인 버튼을 눌렀을 때 새로운 SQL 쿼리를 실행하려면 어떤 JSL 코드를 작성해야 합니까? 
Re: 텍스트 상자에 입력된 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?안녕하세요 @TamedZebra ,
JSL과는 관련이 없지만, 데이터베이스 쿼리 빌더를 적용해 보셨나요? 날짜 범위를 변경하는 필터를 제공하는 GUI를 제공합니다.
감사해요,
벤
Re: 텍스트 상자에 입력한 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?@ Ben_BarrIngh , Arigatougozaimasu.
스크립트를 데이터 테이블에 저장할 수 있으며, 스크립트가 'SQL 쿼리'로 작성된 경우 한 번의 클릭으로 데이터베이스에서 데이터 테이블을 업데이트할 수 있습니다.
하지만 스크립트나 쿼리 빌더에서 SQL을 변경하는 데는 약간의 시간과 노력이 필요합니다.
그래서 Data-table에서 스크립트를 눌러 GUI 팝업으로 SQL을 편집하고 싶습니다.

Re: 텍스트 상자에 입력한 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?저는 애플리케이션 빌더를 사용하지 않고 JSL로 모든 것을 직접 작성합니다. 이 예제 애플리케이션은 데이터베이스에 SQL 쿼리를 실행하지 않고 JMP 테이블을 "데이터베이스"로 사용하며, 상당히 단순화된 버전이지만 몇 가지 일반적인 아이디어를 제공할 수 있습니다.
Names Default To Here(1);
initval = 150;
run_query = Expr(
months_to_query = neb_months << get;
dt = New SQL Query(
Version(130),
Connection("JMP"),
JMP Tables(["Big Class" => "\C:\Program Files\JMP\JMPPRO\18\Samples\Data\Big Class.jmp"]),
QueryName("QueryMonths"),
Select(Column("name", "t1")),
From(Table("Big Class", Alias("t1"))),
Where(
Custom(
Eval Insert("t1.weight >= ^months_to_query^"),
UI(Custom(Base("Continuous"))))
)
) << Run Foreground;
wait(0);
nw << Close Window;
);
nw = New Window("Query Data",
V List Box(
Panel Box("How Long",
Lineup Box(N Col(2),
Text Box("Months: "),
neb_months = Number Edit Box(initval),
)
),
Lineup Box(N Col(2),
Button Box("OK",
run_query
),
Button box("Cancel",
nw << close window;
)
)
)
);
Write();
Re: 텍스트 상자에 입력된 텍스트를 SQL에서 변수로 사용하려면 어떻게 해야 하나요?가져오기 --> 텍스트 가져오기
JMP 19에서 위에 언급된 변경 사항을 실행할 수 있었습니다. 원하는 결과를 얻을 수 있었습니다. 감사합니다!!!