Insert Command Compiles But Doesn't Insert

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

Insert Command Compiles But Doesn't Insert

Post by Leonard Gojer » Wed 24 Nov 2004 19:04

Look at the following program:
The program compiles successfully,
but when data is added, it doesn't
insert anything into the database.
Should there be another command,
such as "Update", (which doesn't
compile by the way) added to the
program?
{$APPTYPE CONSOLE}
{-------------------------------------------------------}
{ Database Test1: declared in Orace PLSQL as }
{ create table test1( }
{ key : varchar(30), }
{ data : varchar(30)); }
{-------------------------------------------------------}
program p1;
uses
System,OdacVcl,DBAccess, Ora, OraAlerter, Db,
Messages, SysUtils, Classes, Controls, MemDS, OraSmart;


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

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;
while not flag do
begin
writeln;
writeln('Menu');
writeln('1 - insert record');
writeln('2 - delete record');
writeln('3 - search record');
writeln('4 - 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.UpdateRecord;
{with test1 do}
{Insert('key1','data1');}
end;
2 : begin
write('Enter key: ');
readln(key1);
with test1 do
{Delete('key1');}
end;
3 : begin
write('Enter key: ');
readln(key1);
with test1 do
{LocateEx('key1');}
end;
4 : begin
flag := true;
end;
end;
end;
OraSession1.Disconnect;
end.

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Fri 26 Nov 2004 07:30

Please read documentation about TDataSet.UpdateRecord, TDataSet.Insert.

Post Reply