Start an down Oracle Instance with Delphi

Start an down Oracle Instance with Delphi

Postby Juergen » Tue 04 Sep 2007 14:49

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?)
Juergen
 
Posts: 1
Joined: Mon 03 Sep 2007 14:25

Postby Plash » Wed 05 Sep 2007 08:30

Core Lab dbExpress Driver for Oracle does not support starting an Oracle instance. You can start an Oracle instance by running SQL*Plus from your Delphi application.
Plash
Devart Team
 
Posts: 2844
Joined: Wed 10 May 2006 07:09

Postby bbts » Thu 13 Sep 2007 20:53

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
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);


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
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;
bbts
 
Posts: 3
Joined: Thu 04 Nov 2004 18:10


Return to dbExpress driver for Oracle