Hi,
I'm using dbExpress driver for Oracle 2.50, Delphi 7.0 Built 4.453 and Oracle Database 10g.
I will connect with Delphi TSQLConnection a Oracle Database. The Instance of the Oracle Database is down. I will start the Instance with "startup". If I do this with a SQLPLUS console it will work.
There are some lines of my code
SQLConnection1 := TSQLConnection.Create(self);
with SQLConnection1 do
begin
DriverName := 'Oracle Net (Core Lab)';
GetDriverFunc := 'getSQLDriverORANET';
LibraryName := 'dbexpoda.dll';
VendorLib := 'dbexpoda.dll';
LoginPrompt := False;
with Params do
begin
Values['DataBase'] := 'myDatabase';
Values['User_Name'] := 'sys';
Values['Password'] := 'myPassword';
Values['RoleName'] := 'SYSDBA';
end;
if not Connected then open;
......
Is it possible to start a down Instance from Delphi? (if yes, whats the way?)
Start an down Oracle Instance with Delphi
You can sorta Startup a database thru a TCRSQLConnection. There are a couple of prereqs
--The Oracle Listener has to running and have the LISTENER.ORA configured for the SID (vs. Automatic Listener config for a SID)
--The Database has to be in at least NOMOUNT mode
--Gotta have the SYSDBA thing setup in TCRSQLConnection
If so, this kind of code will work
As far as doing a shutdown. I ended up just creating a Shutdown script, and a Batch file to do the SQLPLUS command. Here's a helpful chunk of code in case you need it
--The Oracle Listener has to running and have the LISTENER.ORA configured for the SID (vs. Automatic Listener config for a SID)
--The Database has to be in at least NOMOUNT mode
--Gotta have the SYSDBA thing setup in TCRSQLConnection
If so, this kind of code will work
Code: Select all
try
Screen.Cursor := crHourglass;
dm.sqlconnTarget_NET.ExecuteDirect('alter database mount');
finally
Screen.Cursor := crDefault;
end;
MessageDlg('Alter Database Mount. Success', mtInformation, [mbOK], 0);
Code: Select all
try
Screen.Cursor := crHourglass;
dm.sqlconnTarget_NET.ExecuteDirect('alter database open');
finally
Screen.Cursor := crDefault;
end;
MessageDlg('Alter Database Open. Success', mtInformation, [mbOK], 0);
Code: Select all
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
procedure ExecuteBatchFile(sBatchFile: String; bWaitFor: Boolean);
var
bCreateOK: Boolean;
StartInfo: TStartupInfo;
dwCreationFlags: Cardinal;
ProcInfo: TProcessInformation;
begin
FillChar(StartInfo, SizeOf(TStartupInfo), #0);
FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
dwCreationFlags := CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS;
StartInfo.wShowWindow := SW_HIDE;
StartInfo.lpTitle := PChar(ExtractFileName(sBatchFile));
bCreateOK := CreateProcess(Pointer(sBatchFile), nil, nil, nil, False,
dwCreationFlags, nil, nil, StartInfo, ProcInfo);
if bCreateOK then begin
if bWaitFor then begin
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
end;
end else begin
RaiseLastOSError;
end;
end;