v$session.program not populating
v$session.program not populating
We have OCAC 9.0.1 for Delphi7. When the application connects, v$session.program is NULL. Application security checks fail when this value is not the name of the executing program. Please advise.
Re: v$session.program not populating
Hello,
We cannot reproduce the problem. The v$session view returns the correct application name. Please try executing the following code on the latest ODAC version, if the code returns errors - contact us again.
We cannot reproduce the problem. The v$session view returns the correct application name. Please try executing the following code on the latest ODAC version, if the code returns errors - contact us again.
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Ora;
const
UserName = 'SYS';
Passwd = 'PASSWORD';
var
OraSession: TOraSession;
Buffer: array [0..MAX_COMPUTERNAME_LENGTH + 1] of AnsiChar;
len: Cardinal;
begin
len := MAX_COMPUTERNAME_LENGTH + 1;
GetComputerName(Buffer, len);
OraSession := TOraSession.Create(nil);
try
OraSession.Connect('Data Source=ORCL1120;User ID=' + UserName + ';Password=' + UserName + ';Connect Mode=cmSysDBA');
OraSession.ExecSQL('BEGIN'#13#10 +
'SELECT PROGRAM INTO :ProgramName'#13#10 +
' FROM V$SESSION'#13#10 +
' WHERE TERMINAL = :Terminal'#13#10 +
' AND SCHEMANAME = :Schema;'#13#10 +
'EXCEPTION'#13#10 +
' WHEN TOO_MANY_ROWS THEN RAISE_APPLICATION_ERROR(-20001, ''More than one application is running'');'#13#10 +
' WHEN NO_DATA_FOUND THEN RAISE_APPLICATION_ERROR(-20001, ''No application is not running'');'#13#10 +
' WHEN OTHERS THEN RAISE_APPLICATION_ERROR(-20001, ''Other errors'');'#13#10 +
'END;',['', string(Buffer), UserName]);
Assert(ExtractFileName(ParamStr(0)) = OraSession.ParamByName('ProgramName').AsString);
Writeln(Format('Application Name : %s == V$SESSION.PROGRAM : %s',[ExtractFileName(ParamStr(0)), OraSession.ParamByName('ProgramName').AsString]));
finally
OraSession.Free;
readln;
end;
end.