BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Lock without commit, so how to commit (when using TADOQuery.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases
View previous topic :: View next topic  
Author Message
Boefje
Guest





PostPosted: Fri Jan 07, 2005 10:42 am    Post subject: Lock without commit, so how to commit (when using TADOQuery. Reply with 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





PostPosted: Fri Jan 07, 2005 4:07 pm    Post subject: Re: Lock without commit, so how to commit (when using TADOQu Reply with quote



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





PostPosted: Fri Jan 07, 2005 4:08 pm    Post subject: Re: Lock without commit, so how to commit (when using TADOQu Reply with quote



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





PostPosted: Wed Jan 12, 2005 1:59 am    Post subject: Re: Lock without commit, so how to commit (when using TADOQu Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.