sample odac program fails to access the sample table

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lgojer02

sample odac program fails to access the sample table

Post by lgojer02 » Sat 17 Dec 2005 13:51

{ The following is a pascal program that is derived from an earlier
version, which was lost - it compiles correctly, but has run-time errors }
( error in kernel32.dll }
{ system asks to install SP2 on system }


program Project1;


uses
Db,
Messages,
SysUtils,
Classes,
Controls,
Ora,
OraSmart;


var
flag : boolean;
k : integer;
OraSession1 : TOraSession;
key1 : string;
key2 : string;
data1 : string;
test1 : TOraTable;
flag2 : boolean;
blank : string;

begin
flag := false;
OraSession1 := TOraSession.Create(nil);
OraSession1.Server := 'dbgojer';
OraSession1.Password := 'shlock';
OraSession1.Username := 'SYSTEM';
OraSession1.Connect;
test1 := TOraTable.Create(nil);
test1.TableName := 'TEST1';
test1.Open;
blank := '';
while not flag do
begin
writeln;
writeln('Menu');
writeln('1 - insert record');
writeln('2 - delete record');
writeln('3 - search record');
writeln('4 - change record');
writeln('5 - list all records');
writeln('6 - quit program');
write('> ');
readln(k);
case k of
1 : begin
write('Enter key: ');
readln(key1);
write('Enter data: ');
readln(data1);
test1.Insert;
test1.FieldByName('KEY').AsString := key1;
test1.FieldByName('DATA').AsString := data1;
test1.Post;
test1.Close;
test1.Open;
end;
2 : begin
write('Enter key: ');
readln(key1);
try
test1.Locate('KEY',key1,[loPartialKey]);
test1.Delete;
test1.Post;
test1.Close;
test1.Open;
except
end;
end;
3 : begin
write('Enter key: ');
readln(key1);
test1.Locate('KEY',key1,[loPartialKey]);
data1 := test1.FieldByName('DATA').AsString;
writeln('Data1: ',data1);
end;
4 : begin
write('Enter key: ');
readln(key1);
write('Enter data: ');
readln(data1);
try
test1.Locate('KEY',key1,[loPartialKey]);
test1.Delete;
test1.Post;
test1.Close;
test1.Open;
except
end;
test1.Insert;
test1.FieldByName('KEY').AsString := key1;
test1.FieldByName('DATA').AsString := data1;
test1.Post;
test1.Close;
test1.Open;
end;
5 : begin
key1 := '';
test1.FindFirst;
key2 := test1.FieldByName('KEY').AsString;
data1 := test1.FieldByName('DATA').AsString;
writeln('Key1: ',key2:0,blank:(20 - length(key2)),' Data1: ',Data1);
flag2 := true;
while flag2 do
begin
flag2 := test1.FindNext;
key2 := test1.FieldByName('KEY').AsString;
data1 := test1.FieldByName('DATA').AsString;
if flag2 then writeln('Key1: ',key2:0,blank:(20 -
length(key2)),' Data1: ',Data1);
end;
end;
6 : begin
flag := true;
end;
end;
end;
test1.Close;
OraSession1.Disconnect;
end.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Tue 20 Dec 2005 09:26

We couldn't reproduce your problem. Please send to ODAC support address your compiled project
that works with default Oracle schema Scott with password tiger. And use one of standard tables,
for example, emp table. Please include detailed description of your situation and steps to
reproduce it.

lgojer03

Explanation of situation

Post by lgojer03 » Tue 20 Dec 2005 13:57

I am able to compile and run successfully the demo programs
that come with ODAC. This program is the only one that gives
me problems. I am able to work with the db in SQLPLUS, just
not through this program.

The unique thing about this situation is that I am running Oracle,
as well as the Delphi compiler in a virtual machine that resides
on a real machine. I have already contacted Oracle Metalink about
this, and they suspect that the problem has to do with the virtual
machine not allowing the right permissions to the directory where
Oracle resides.

Therefore, if you say that you cannot reproduce the problem,
are you telling me that after you create a database named "TEST1"
in Oracle, and convert the user name and password in my program
that the program WORKS? on your computer? If so, that would confirm
what the Oracle Metalink staff was saying. Please tell me if that is
what happened on your system.

I don't think I need to upload the SCOTT/TIGER examples, because
they compile and run just fine on my system. If you have an ulterior
motive for me doing that, let me know.

Sincerely,
Leonard Gojer

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Wed 21 Dec 2005 07:56

We added to your code compiler directive {$APPTYPE CONSOLE} to generate console application and updated your program to make it work with our server. After these changes it works fine.

lgojer04

Thank you for your help

Post by lgojer04 » Wed 21 Dec 2005 13:45

To:
Challenger
Thank you for your help. The fact that the program works on your
system is usefull to the process of our debugging. I am working with
Metalink to find the cause of my bug, which is something to do with
the fact that the system is running in a virtual machine.

Post Reply