 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Boefje Guest
|
Posted: Fri Jan 07, 2005 10:42 am Post subject: Lock without commit, so how to commit (when using TADOQuery. |
|
|
Hi,
I am using a Oracle database. Now I want to do a fairly simpel update.
The code is like this:
try
ADOQueryUpdate.Close;
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId));
ADOQueryUpdate.ExecSQL;
except
on e: exception do
ShowMessage('Error: Data could not be written!');
end;
If I do this my application does not continue. I think the reason is
simple, it has to commit the executed statement. But how?
This does not work:
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId)+';');
ADOQueryUpdate.SQL.Add(' 'COMMIT;');
ADOQueryUpdate.ExecSQL;
It says: "ORA-00911: invalid character"
So it does not except the ';'. So what should I do?
By the way I am using Delphi 5 and two ADO components, just
TADOConnection and TADOQuery (so no TDatabase component)
Thanks
|
|
| Back to top |
|
 |
Ryan Guest
|
Posted: Fri Jan 07, 2005 4:07 pm Post subject: Re: Lock without commit, so how to commit (when using TADOQu |
|
|
Should this ...
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
Be ???
ADOQueryUpdate.SQL.Add(' contract_id = ')+IntToStr(pId);
Looks like you are missing a bracket.
Ryan
Boefje wrote:
| Quote: | Hi,
I am using a Oracle database. Now I want to do a fairly simpel
update.
The code is like this:
try
ADOQueryUpdate.Close;
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId));
ADOQueryUpdate.ExecSQL;
except
on e: exception do
ShowMessage('Error: Data could not be written!');
end;
If I do this my application does not continue. I think the reason is
simple, it has to commit the executed statement. But how?
This does not work:
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId)+';');
ADOQueryUpdate.SQL.Add(' 'COMMIT;');
ADOQueryUpdate.ExecSQL;
It says: "ORA-00911: invalid character"
So it does not except the ';'. So what should I do?
By the way I am using Delphi 5 and two ADO components, just
TADOConnection and TADOQuery (so no TDatabase component)
Thanks
|
|
|
| Back to top |
|
 |
Ryan Guest
|
Posted: Fri Jan 07, 2005 4:08 pm Post subject: Re: Lock without commit, so how to commit (when using TADOQu |
|
|
Should this ...
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
Be ???
ADOQueryUpdate.SQL.Add(' contract_id = ')+IntToStr(pId);
Looks like you are missing a bracket.
Ryan
Boefje wrote:
| Quote: | Hi,
I am using a Oracle database. Now I want to do a fairly simpel
update.
The code is like this:
try
ADOQueryUpdate.Close;
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId));
ADOQueryUpdate.ExecSQL;
except
on e: exception do
ShowMessage('Error: Data could not be written!');
end;
If I do this my application does not continue. I think the reason is
simple, it has to commit the executed statement. But how?
This does not work:
ADOQueryUpdate.SQL.Text := 'UPDATE contracts SET ';
ADOQueryUpdate.SQL.Add(' contract_id = '+IntToStr(pId);
ADOQueryUpdate.SQL.Add(' WHERE account_id = '+
IntToStr(pAccountId)+';');
ADOQueryUpdate.SQL.Add(' 'COMMIT;');
ADOQueryUpdate.ExecSQL;
It says: "ORA-00911: invalid character"
So it does not except the ';'. So what should I do?
By the way I am using Delphi 5 and two ADO components, just
TADOConnection and TADOQuery (so no TDatabase component)
Thanks
|
|
|
| Back to top |
|
 |
DEHilliard Guest
|
Posted: Wed Jan 12, 2005 1:59 am Post subject: Re: Lock without commit, so how to commit (when using TADOQu |
|
|
I use Delphi 7 with Oracle and ADO, one of the things I find extremely
valuable in debugging SQL, is the: SQL.SaveToFile( filename ) ;
I can then run the SQL that Oracle sees in SQL Plus.
Since you have your SQL in a Try, Except Structure
try using the ADOConnection.BeginTrans
and ADOConnection.CommitTrans
and ADOConnection.RollBackTrans.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|