"Record is already updated, please re-query the block to see the change." in Oracle Forms - oracleforms

Whenever I try to update a field in oracle form after querying the record,I get an error
"Record is already updated,please re query the block to see the change."
The record does not get updated. Please help

You get the message "Record is already updated, please requery the block to see the change." whenever the record is changed in the database.
For example you can query a record in a form and do a manual update in some trigger that fires when the query has been run (post-query, post-change, key-exeqry, ...)
And if you then try to lock the record when you update a field the message will appear because the record you are trying to change is outdated.

Related

How can I insert a new record in Access using a trigger?

Bearings first...
Microsoft Access.
Version? Unsure. For that I see
"Microsoft Office 365 Pro Plus" and
"Access 2007 - 2016 file format"
I'm a MS Access novice, but rather good at relational DBS (Postgres, MySQL, etc...) in which I've created triggers and their companion stored prodecures.
I'm trying to effectively create an after update trigger for a table. I want the trigger to insert a record in a different table with values that I can either echo or customize based on values in the table that was just updated.
In the "table" tab, "after update", this is what I'm defining...
If [Old].[est_mandays]<>[est_mandays] Then
Create a Record In ajax_hist
Alias ah
SetField
Name ah.est_mandays
Value = [Old].[est_mandays]
SetField
Name ah.id
[Old].[id]
End If
As you can see, I'm just echoing those 2 values in the ajax_hist table.
It seems to swallow this OK as far as syntax. At least I don't get any errors. But when I change the value of est_mandays for a record in the table which has the trigger, no record is inserted in the ajax_hist table. No messages of any kind, error, warning or otherwise.
I "saved" the table after the update in an attempt to force the change (just in case). No difference.
Any ideas what I'm doing wrong ?
More importantly, is there a way to debug this (a log file or debug mode or something that tells me the trigger was actually fired ?)
Thanks in Advance!
Get rid of the "[Old]." where setting values.
Thanks to Erik von Asmuth for the tip on USysApplicationLog which gave me the clue I needed.

MySql After Update Trigger execution order

I am calling an API of my Nodejs app to update a record in my MySQL database.
I defined an "After Update trigger" on it. the trigger calls a post restful API using sys_exec,to pass the updated record's ID to another API. Then, the other API fetch the record and based on the updated values, will insert a new record in the other table of the same database.
But what actually happens is: first the second API insert new record based on the old values of the record and then the old value update new value.
As far as I know, "after update trigger" guarantees to start executing trigger after updating current record.
any suggestion or help, please.
The after update trigger runs after the record is updated, but before the committing of the transaction.
By calling another api from the trigger, the 2nd insert is most likely runs in a different transaction. Unless you change the isolation level to read uncommitted, the 2nd transaction can only read the committed, therefore unchanged values of the record.
I would do the 2nd insertion from the trigger, not from another api because the trigger can obviously see the updated values. The 2nd api can still take care of whatever else it is doing at the moment.
I would not recommend changing the isolation level to read uncommitted - unless you really know what you are doing. It can have unintended side effects.

What is wrong with this update query? I get "no records changed"

UPDATE sb_reviews
SET clients_id=(SELECT clients_id
FROM sb_users
WHERE id=sb_reviews.users_id)
sb_reviews is a table with a users_id and and a newly created clients_id. I'm trying to grab the clients_id from the sb_users table and put it into the sb_reviews table where sb_users.id=sb_reviews.users_id
This query does not work though, I get no records changed.
There is nothing wrong with your query.
In mysql, if the update has no effect (ie the value in the column isn't changing), it reports as not an update.
If you have already run this, you'll get "no records changed" message every run thereafter (unless data in the second table changes, of course).

Error 2501 while trying to delete a record

I have an Access database front-end and I'm trying to put a button on a form to delete the current record. I used the following VBA code to delete the record:
If Me.NewRecord Then
Me.Undo
Exit Sub
End If
DoCmd.RunCommand acCmdDeleteRecord
Me.Requery
Me.Refresh
When I run this on records that I inserted into the database with the form, It returns Run-time error '2501' on the DoCmd. However, if I run it on a record that had already existed in the database then the code completes as intended.
Additionally, no one else is accessing this database table yet and I only had the one form open.
When I went to delete them from the linked table manually in access I got the same error but I was able to delete them from the database using SQL Server Management Studio.
What would cause this to happen?
EDIT
I did some more investigating and found that I am unable to edit the new records in in the base table using access either. I get an error about the records being changed by another user.
Other than the recommendation to have a timestamp field in the table (SSMA assistant adds this to all tables when you use it to upsize from Access, and it's definitely something I'd recommend), I have some criticism of your code. I'd write it this way:
If Me.NewRecord Then
Me.Undo
Else
DoCmd.RunCommand acCmdDeleteRecord
Me.Requery
End If
The refresh is redundant after a requery, as you already have the most recent data.
Using Exit Sub is helpful for guard clauses on things that aren't mutually exclusive, but in this case you have an either/or -- either your going to delete an existing record or undo a new record. That can be handled within a single If/Then/Else block and then you have a single exit point for your subroutine, which is very helpful in case the code grows more complex in the future.
This is not the answer to your specific problem, but regarding the question title of getting Error 2501 while trying to delete a record, another situation where that happens is this:
You try to delete a row in one table that would orphan rows in another
table (because the two tables are linked via a foreign key). SQL
Server rejects the deletion and Access returns that vague 2501 error
code.
In my case, I solved the issue by dropping and recreating each foreign key with ON DELETE CASCADE so that when a row in the "main" table is deleted via Access, SQL Server automatically deletes the corresponding rows in the each "detail" table.
See these questions for more detail on cascade delete:
Good explanation of cascade (ON DELETE/UPDATE) behavior
How do I use cascade delete with SQL Server?

table locked or in use when calling RunSQL

I have some code which re-arranges some items on a form, but only one SQL query. All my tables aren't locked before the code runs but for some reason I get an error when running:
DoCmd.RunSQL ("Select * Into MasterTable From Year07 Where 'ClassName' = '7A'")
Error:
The database engine could not lock table because it is already in use by another person or process. (Error 3211) To complete this operation, a table currently in use by another user must be locked. Wait for the other user to finish working with the table, and then try the operation again.
Any ideas what I can do to stop the table being locked?
Is MasterTable included in your form's Record Source? If so, you can't replace it, or modify its structure, while the form is open.
Apart from the table lock issue, there is a logic error in the SELECT statement.
Where 'ClassName' = '7A'
The string, ClassName, will never be equal to the string, 7A. Therefore your SELECT can never return any records. If ClassName is the name of a field in your Year07 table, discard the quotes which surround the field name.
Where ClassName = '7A'
I'm guessing, but if you're using a form that is bound to MasterTable, you can't run a query to replace it with a new MasterTable while you've got it open in the form.
I would suggest that you get rid of the MakeTable query (SELECT INTO) and instead use a plain append query (INSERT). You'll want to clean out the old data before appending the new, though.
Basically, a MakeTable query is, in my opinion, something that does not belong in a production app, and any process that you've automated with a MakeTable query should be replaced instead with a persistent temp table that is cleared before the new data is appended to it.
I have seen this when you re-open a database after Access has crashed. Typically for me a reboot has fixed this.
What version of MSAccess? Not sure about newer ones, but for Access 2003 and previous, if you were sure nobody was in the database, you could clear up locks after a crash by deleting the .ldb file.