Error while updating a record in APEX screen - oracle-apex

while updating a record using MRU its failing with below error.
1 error has occurred
Current version of data in database has changed since user initiated update process. current row version identifier = "C5F3645B026AA5646C00DC7B631C4D19" application row version identifier = "6A9323B62F641015FA4601421DFB03DE" (Row 1)
This is strange because I do not see any change in the data at backend.
Any help will be highly appreciated.
Thanks.
AJ

If you're using a tabular form, check your query, then check the item. The item must match with the correct column in a database that is updatable.
Make sure that your column aliases match your column names (for updateable columns).

I had the same problem, the problem in my case that detail table has composite primary key,
so in application > column > Primary KeyPrimary Key
property must all primary key field enable , not only one field.

Related

Getting 'Cannot insert duplicate key' from UPDATE query

I'm writing an ODBC class to connect to a remote SQL Server database. I have most of it working.
The class has the ability to generate queries such as the following:
UPDATE Customers SET Id=?,Name=?,TaxId=?,ContactFName=?,ContactLName=?,Phone_Office=?,Phone_Mobile=?,Phone_Home=?,Email=?,Website=?,Address1_Physical=?,Address2_Physical=?,City_Physical=?,State_Physical=?,Zip_Physical=?,Address1_Billing=?,Address2_Billing=?,City_Billing=?,State_Billing=?,Zip_Billing=?,StartingBalance=?,Discount=?,BillingSequence=?,BillingCategory=?,ShowOnReport=?,Active=?,CreateDate=?
As you can see, it's an UPDATE query. Yet, running this query gives me an error:
Microsoft ODBC Driver 17 for SQL Server (SQL Server) : ReturnCode: -1 : Violation of PRIMARY KEY constraint 'PK_Customers'. Cannot insert duplicate key in object 'dbo.Customers'. The duplicate key value is (82). (State: 23000, NativeError: 2627) : The statement has been terminated. (State: 01000, NativeError: 3621)
I'm confused why I'm getting an error about inserting when I'm doing an update. Has anyone seen this?
Notes:
Id is the primary key. I first read all column values from the database, and then update those I want to change. The ID does not change.
The error above was put together by my code, but is based on the messages returned by SQLGetDiagRec().
There's no WHERE clause on the UPDATE statement, so it's trying to update EVERY SINGLE ROW in the database, and since ID is one of the columns being changed, it's trying to set every row's ID to the same value. This is resulting in an attempt to create a duplicate primary key.
Make sure your UPDATE statement has an appropriate WHERE clause... like "WHERE ID = ?"... and it's probably best practice to NOT include the ID in that UPDATE statement if it's not changing.
That is the message you should expect when an UPDATE statement violates a primary key. EG
use tempdb
go
drop table if exists t
create table t(id int primary key)
insert into t(id) values (1),(2)
go
update t set id = 2 where id = 1
--Msg 2627, Level 14, State 1, Line 11
--Violation of PRIMARY KEY constraint 'PK__t__3213E83F127C5D76'. Cannot insert duplicate key in object 'dbo.t'. The duplicate key value is (2).
--The statement has been terminated.
In the UPDATE I see a field called ID. If you are making a change to the ID and it's the primary key then the DBMS will fuss because you are trying to store duplicate keys.

Update Else Insert without Update Strategy

I'm inserting from a source table to the target table. If the source record already exists in the target, then it will update else insert. I have done this without using Update strategy. In session properties, I have set as treat rows as 'Update' and in the mapping target properties, I selected 'Insert' and 'Update Else Insert' checkbox. Also, I have chosen a primary key in the target table as well. But while running the session every time, it is always inserting the same rows again and again. I.e. duplicate rows are inserting instead of update the record. am I doing anything wrong?
The database table should have primary keys defined for this to work.

Ideal Siebel EIM component level Log setting

What is the ideal eventlevel log settings for the siebel component "Enterprise Integration Mgr".
The problem is while running the EIM job, I provide the highest value for sqlflag, traceflags and error flags, still I am not getting the detailed log for the PICKLIST_VALUE error, to find the column.
Kindly advise.
Thanks,
Kriti
This issue is faced when there is a LOV value (Bounded Picklist) which is not getting resolved. To resolve this first you need to identify the columns which are populating the LOV i.e picklist or dropdown, then verify that the value being pushed in that column is present in the List Of Values..
If still the error is not resolved then please provide the ifb file details
You can set the below log levels to debug the issue that you are facing.
SQLFlags = 8
ErrorFlags = 1
TraceFlags = 3
Apart from this, you can check the column associated to the Picklist based field. Check the below property in Siebel Tools under for a Column.
LOV Type
LOV Bounded
Translate
If LOV Bounded is TRUE, then, during import, EIM checks the values against the values contained in a list defined in the LOV Type property.
If LOV Type and Translate property is populated, then Siebel stores the LIC value in that particular column for a specific LOV value.
Hope in this way you can track and debug the issue.

Siebel Operation Error for Inserting Field based on picklist

I am facing an issue where I am getting the below error while inserting a record in the table via Siebel Operation step.
Here the error is showing for field which is based on a picklist. Could anyone please suggest why i am getting this error:
SBL-DAT-00225: The value entered in field District of buscomp Contact_Address_LT does not match any value in the bounded pick list PickList Comm Resolution.
SBL-BPR-00100: This error is returned when the workflow/task is executing the Siebel Operation business service.
I am aware that this happens when the value is not defined in the picklist. But i have verified this, and LOV is having the value which I am trying to get insert.
This error is quite common. And could happen for a couple of reason.
As you have mentioned, that you have already checked the value which is getting inserted is already there in the LOV defined for the picklist.
I have recently faced this error, and spent hours to debug it. Try below to sort your problem.
Check for the below points:
1) Check for the pick map for this field, check if any contraint field is also present in it.
2) If yes, then check those constraint field is also getting inserted in same Siebel Operation step. Siebel does not follow sequence in the input argument. So if this is the case do step 3 to resolve your issue.
3) Split the insert statement into 2 parts, 1 where you insert the record with the values which is present in the pick map constraint and then update the same record. This will ensure that all the required field are populated.
Solution from 8.1.1.4 is to add parameter into OM's config file, e.g fins.cfg:
[Task]
ProcessArgAsc = true
More details in my oracle support.

Oracle APEX - Setting up a Tabular Form with default values

I pretty new to APEX and I'm having a bit of trouble working with my first Tabular form. The table I've linked it to is fairly simple. The columns are as follows:
Primary key representing an internal
code for a college major
Foreign key representing the "real"
code for the college major
Description for the college major
The user that inserted/updated the
row in the table
The date the row was inserted/updated
At the moment, I'm facing two problems.
I want the user to be able to specify their own primary key for the row but not to be able to change any existing primary keys. When I specify the column type as "Text Field" users are able to edit existing rows' primary keys and it also seems to break the report when trying to add a new row as I get a checksum error.
I would like the user and date
columns to default to the currently
logged in user and the current date,
but specifying default values for
either of these columns also seems
to cause syntax/SQL errors. Does
anyone have any examples of how to
use the default value functionality
for a column? Fixed. I can just use SYSDATE as a value on it's own when specifying the PL/SQL type for default. Username can be obtained through functions in APEX_UTIL
Perhaps you could use 2 conditional fields. If the field value is null, display the edit box, if the field value is not null display the display-only field.