여러 개의 쿼리를 실행하는 스크립트가 있습니다. 그래서 고객은 "Open Database ()"명령이 호출 될 때마다 DSN을 선택해야했습니다. 그래서이 문제를 해결하는 함수를 썼습니다. 사용자가 선택하면 DSN 문자열을 가로 채서 변수에 저장합니다. 그런 다음 내 스크립트는 사용자가 다시 선택하지 않아도 나중에 DSN에 액세스 할 수 있습니다.
/*
Function
to intercept user's DSN
selection through ODBC interface for database queries.
This is useful for scripts that
run Open Database() multiple times on the same database.
Opens user's Windows ODBC to allow them to select a DSN.
Returns the DSN string to query the database. If fail, it pops up
a window indicating the error, and returns empty string.
Arguments:
_test_query_:
A very simple query that will return a SQL error if
user
selected wrong DSN. It
will return a
results table if there is no error.
_database_:
The name of the database for the error window.
Local
Variables:
_DSN_test_:
temporary table that will contain the table variable with DSN
_DSN_string_:
string extracted from Database query results Table Variable "JSL"
Example
usage:
DSN_setup("SELECT
TOP 1 * FROM dbo.Dim_DiePV","NSGTestDW");
*/
::DSN_setup = Function(
//Arguments
{_test_query_, _database_},
//Locals
{_DSN_test_, _DSN_string_},
_DSN_test_ =
Open Database( , _test_query_ );
If( Char( _DSN_test_ ) == ".",
New Window( "Script Error",
<<MODAL></MODAL>그 점을 지적 해 주셔서 고맙습니다. @JensRiege .
내가 청소 했어.