|
function InstallOracleComponent(szComponent)
NUMBER nResult,nvFileHandle,nIndex,nvCount;
STRING sMsg,szServer,szDB,szUser,szPassword,sCMD,sOPT,sInstance,sTmp,svLine;
LIST listStatus;
begin
sMsg = '安装'+szComponent+' ...';
SdShowMsg(sMsg, TRUE);
// Fetch database connection information
SQLRTGetConnectionInfo( 'oracle', szServer, szDB, szUser, szPassword );
nIndex = StrFind(szServer, ':');
nIndex = StrFindEx(szServer, '/', nIndex);
StrSub(sInstance, szServer, nIndex+, );
sCMD = WINSYSDIR^'cmd.exe';
sOPT = ' /c '+'sqlplus.exe -L -S '+szUser+'/'+szPassword+'@'+sInstance;
sOPT = sOPT+' @'+SRCDIR^szComponent+'.sql > '+SRCDIR^'dbstatus.txt 2>&1';
// Execute the script associated with the given component in database
nResult=LaunchAppAndWait(sCMD, sOPT, WAIT|LAAW_OPTION_HIDDEN);
if (nResult < ) then
MessageBox('Failed installing '+szComponent+' !', SEVERE);
abort;
endif;
// 关闭安装提示
SdShowMsg('', FALSE);
// 在dbstatus.txt中查询字符串holytail,如果存在,说明脚本已执行完
if (FileGrep(SRCDIR^'dbstatus.txt', 'holytail', svLine, nIndex, RESTART) = ) then
// 在dbstatus.txt中查询字符串ORA-,如果存在,说明脚本执行出现错误
if (FileGrep(SRCDIR^'dbstatus.txt', 'ORA-', svLine, nIndex, RESTART) = ) then
sMsg = "更新数据库出错,点“是”打开日志文件并退出安装,点“否”直接退出安装。/n";
sMsg = sMsg+"若错误可忽略,可选择数据库类型“none”以跳过数据库更新并直接更新程序,/n";
sMsg = sMsg+"然后在数据库中手工执行SQL脚本(安装后保存在script目录下)";
nResult = AskYesNo(sMsg, YES);
if (nResult = YES) then
LaunchApp(WINSYSDIR^'notepad.exe', SRCDIR^'dbstatus.txt');
endif;
abort;
endif;
else
sMsg = "更新数据库出错,点“是”打开日志文件并退出安装,点“否”直接退出安装。/n";
sMsg = sMsg+"若错误可忽略,可选择数据库类型“none”以跳过数据库更新并直接更新程序,/n";
sMsg = sMsg+"然后在数据库中手工执行SQL脚本(安装后保存在script目录下)";
nResult = AskYesNo(sMsg, YES);
if (nResult = YES) then
LaunchApp(WINSYSDIR^'notepad.exe', SRCDIR^'dbstatus.txt');
endif;
abort;
endif;
end;
|