setCurrentDatabase()

sqlLib.setCurrentDatabase() 시스템 함수는 지정된 데이터베이스를 현재 활성으로 만듭니다. 각 실행 단위에는 현재 연결이 있으며 SQL문은 현재 연결에 대해 조작합니다. 각 새 sqlLib.connect() 호출은 일반적으로 현재 연결을 변경합니다. 연결을 이전 값으로 재설정하려면 sqlLib.setCurrentDatabase()를 사용하십시오.

구문

  sqlLib.setCurrentDatabase(database STRING in)
database
sqlLib.connect()에 지정된 데이터베이스 이름 또는 별명입니다. 입력은 STRING 유형과 호환 가능한 지정인 임의의 변수 또는 표현식이 될 수 있습니다("EGL에서 지정 호환성" 참조).

예제

다음 예제는 sqlLib.setCurrentDatabase()를 사용하는 방법을 표시합니다.

connect( "db1a", "user", "pwd" );
// Drop table xyz from database db1a
execute #sql{ drop table xyz };

connect( "db1b", "user", "pwd" );
// Drop table xyz from database db1b
execute #sql{ drop table xyz };

setCurrentDatabase( "db1a" );
// Drop table xyz2 from database db1a
execute #sql{ drop table xyz2 };

// Disconnect from db1a (the current connection)
disconnect( "db1a" );

// Since the current connection was closed by
// the previous statement, EGL connects to
// the default database before running this statement
execute #sql{ drop table xyz3 };
				
// Disconnect from the current connection,
// whatever it happens to be
disconnect();

setCurrentDatabase( "db1b" );
// Drop table xyz2 from database db1b
execute #sql{ drop table xyz2 };