Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: NCOCI Insert and Post Errors
NCOCI Insert and Post Errors
Posted: 2000/07/25 09:17
 
Hi,
I am using the NCOCI Components with a Oracle 8.05 Database Client and a Oracle 8i Database.
1.) I want to insert a record into the database with the following statement: insert into <database_name> .....
the statment is working fine without any errors, but there is no insert done on the database, unless i set the OCIdatabase to autocommit.

2.) i want to edit a record on the database, using the following statement: select * from <table> where key_field = <value> for update nowait. Then the query is sset to query.open, and then i set the query to query.edit. No errors so far, but if i set the query to query.post i get the error message "OCI_Error ORA00907 : Missing right braket" ????
RE: NCOCI Insert and Post Errors
Posted: 2000/08/01 18:50
 
1) This is because, when AutoCommit = False, then first DML command, that modify database, implicitly start transaction. And this TX become active until session end or COMMIT (in your case - until session end).
You must use explicit transactions handling and AutoCommit = False or implicit transactions handling and AutoCommit = True.

2) The error (ora-907) was due to TOCIQuery automatically creates update query, using following technique:
Original query = <some SQL query>
Update query = UPDATE (<Original query> SET ... WHERE ...
So, in your case update query will equal:
UPDATE (
select * from <table> where key_field = <value> for update nowait
) SET ... WHERE ...
But this is disallowed by Oracle syntax.

As i see, you want to use pessimistic locking. For that you should use TOCIUpdateSQL. Set TOCIQuery.UpdateObject to it. Set TOCIUpdateSQL.LockMode =
lmPesimistic, LockPoint = lpImmediate. Exclude FOR UPDATE NOWAIT phrase from your query. Now query.edit will lock record, query.post will update database and unlock data.

But you can also override SQL's that TOCIQuery uses for database update / insert /... For that use TOCIUpdateSQL.SQL* properties.
RE: NCOCI Insert and Post Errors
Posted: 2000/08/03 16:48
 
Thank you very much, I will try asap
Michael