Lock records in non-db blocks....
Hi,
I make a test:
Run the same form twice - as two users would do - and try to update the same record almost simultaneously .. then a row lock is established - as expected.
I try another test:
Run the same form twice - as two users would do - and try to update the same record almost simultaneously , but the block is non db (control block). The update is done via a button.
I have written the following simple code:
DECLARE
EMPNO_VAR EMP.EMPNO%TYPE;
BEGIN
SELECT EMPNO INTO EMPNO_VAR FROM EMP
WHERE EMPNO=:EMP.EMPNO FOR UPDATE;
UPDATE EMP SET ENAME=:EMP.ENAME , JOB=:EMP.JOB ,
HIREDATE=:EMP.HIREDATE , SAL=:EMP.SAL
WHERE EMPNO=EMPNO_VAR;
COMMIT;
END;The result of the following is what Tom Kyte names "lost updates".... The update of the second user overwrite the update done by the first user ....
No lock row is established....
I have also tried:
DECLARE
EMPNO_VAR EMP.EMPNO%TYPE;
BEGIN
LOCK_RECORD;
UPDATE EMP SET ENAME=:EMP.ENAME , JOB=:EMP.JOB ,
HIREDATE=:EMP.HIREDATE , SAL=:EMP.SAL
WHERE EMPNO=EMPNO_VAR;
COMMIT;
END; But , no update is done ....
How can i lock the record in a block which is non-db (control block)...???
Note: I use Oracle db10g v.2 and DevSuite Form 10g
Thanks...
Sim
Sim, you are missing a whole second part of this scenario. You initially retrieve the row's data in the WNFI trigger.
If you want to prevent the "Lost Updates" problem, you need to do what Forms default (automatic) processing does before it allows the second user to update a field. When the user makes the very first keystroke to make the first change in a base-table row, Forms does a select * for update nowait. THEN, it compares all the data fetched in this SECOND fetch with the database values stored for the row in the FIRST fetch. If they do not compare exactly, then some other user has updated the row and committed. In that case, Forms displays the message:
FRM-40654: Record has been updated by another user. Re-query to see change.
So, you need to do the same thing in your form, but you will need to do it manually.
When you initially fetch the data in the WNFI trigger, you need to store a copy of the values retrieved someplace where they will not be changed by the user. Then when your button is pressed to update the record, you need to select all the columns your form updates in the select... for update nowait.
At this point, you check for a locked row by checking for ORA-00054. If not locked, you then need to compare all the stored values against the new values fetched. If they compare equal (and here, be sure to treat null = null as true), you can continue. If they do not compare equal, then you need to prevent the update, and issue a message similar to the FRM-40654.
If the row is not locked and they compare equal, then you can go ahead and update the row. And be sure to update the values stored for a possible next comparison.
Whether or not you commit after the update is up to you. If you commit, it frees up the lock so another user can make the change. If this is the only change the form can make, then a commit is ok. But if this is only part of the changes a user can make, then I would not commit, and require the user to click a save button at some point, which would then commit all the changes.
Good luck!
Similar Messages
-
HOW TO CREATE MULTIPLE RECORDS IN A NONE DATABASE BLOCK?
I have a Form where I have a none database block with unbound items. The block
has 10 records. In the when-new-block instance I run a query by which I would
like to fill up the block with data. The code fragment looks like the
following:
begin
declare
tmp_curr_rec_id number;
begin
-- a hibak kiolvasasa
for c_hibak in ( select h.*, h.rowid
from hibak h
where 1=1 -- WF - Ide kerul a szurofeltetel
order by bejelentes_datum asc
) loop
-- bemasoljuk az adatokat az unbound item-ekbe
:mc_adat.ub_azonosito := c_hibak.azonosito;
:mc_adat.ub_verzio_letrehozas_datum :=
c_hibak.verzio_letrehozas_datum;
:mc_adat.ub_bejelento := c_hibak.bejelento;
:mc_adat.ub_bejelentes_datum := c_hibak.bejelentes_datum;
:mc_adat.ub_wf_verzio_csomopont :=
c_hibak.wf_verzio_csomopont;
:mc_adat.ub_wf_utolso_esemeny_szoveg :=
c_hibak.wf_utolso_esemeny_szoveg;
:mc_adat.ub_hiba_leiras := c_hibak.hiba_leiras;
:mc_adat.ub_hiba_hely := c_hibak.hiba_hely;
:mc_adat.ub_rekord_jelleg := 'H';
:mc_adat.ub_rowid := c_hibak.rowid;
-- beallitjuk a rekordot-ot olyanra, mintha semmi nem valtozott
volna
-- nem szeretnenk a form bezaraskor mindenfele figyelmezteteseket
-- olvasni a kepernyon
tmp_curr_rec_id := get_block_property( :system.current_block,
current_record );
set_record_property( tmp_curr_rec_id, :system.current_block,
status, new_status );
create_record;
end loop;
end;
end;
The block's update allowed, insert allowed, delete allowed property is set to
true.
The result of the code above is that only the last record fetched shows up in
the block. The problem is - as I found out - is that aech record is fetched,
the values are copied to the block items, but the create_record built-in
command would not move the cursor to the next row.
Can some one please help me with this?
TIA,
Tamas SzecsyThe problem was with the following code segment:
tmp_curr_rec_id := get_block_property( :system.current_block, current_record );
set_record_property( tmp_curr_rec_id, :system.current_block, status, new_status );
After omitting these two lines, the code worked properly.
Thansk for all whoe replied.
Regards,
Tamas -
Multi-Record (NON-DB) block - duplicate records
I have a non-db block called 'EDITOR_INFO' that captures all the editor's information. The block has the following fields in it: editor_name,editor_type,address_lines1 thru4, city, state, zip, taxid_ssn_type,taxid_ssn.
I need to check to make sure that the user is not entering the duplicate editors. How can I adapt the infamous Kevin Clarke's solution to this (if at all)? What would be my datablock, control block etc?
Can any one pls. provide any guidance.
Thanks,
Chiru
Edited by: Megastar_Chiru on Nov 8, 2010 3:55 PM
Edited by: Megastar_Chiru on Nov 8, 2010 3:56 PMChiru, if all you need is to add/query records in a block, you should consider making a data-block instead of control-block. And use POST to post the data into table which will let you check against the table if a record exists or not.
But if you want to have it done using a control-block then follow below sample steps.
In WHEN-VALIDATE-RECORD of your control block, you can check if entered record is already in the table or not.
If it exists, then raise error message and stop until user corrects the data... if it does not exist, then INSERT into the table.
For this scenario, I created a small table with two columns.
CREATE TABLE TABLE_A (Col1 NUMBER, Col2 VARCHAR2(30));Now I created a form with a control block (BLOCK2). It has 10 records with vertical layout and two control-items on it (TEXT_ITEM4 and TEXT_ITEM5). And below is code used on WHEN-VALIDATE-RECORD.
-- WHEN-VALIDATE-RECORD
DECLARE
temp VARCHAR2(1);
CURSOR c_check_existance IS
SELECT 'X'
FROM table_a
WHERE col1 = :BLOCK2.text_item4;
BEGIN
:GLOBAL.Valid_Records := 'N';
IF :block2.text_item4 IS NOT NULL THEN
OPEN c_check_existance;
FETCH c_check_existance INTO temp;
IF c_check_existance%FOUND THEN
CLOSE c_check_existance;
:GLOBAL.Valid_Records := 'N';
MESSAGE('Record already exists in table');
RAISE FORM_TRIGGER_FAILURE;
ELSE
INSERT INTO table_a (col1, col2)
VALUES (:block2.text_item4, :block2.text_item5);
:GLOBAL.Valid_Records := 'Y';
END IF;
CLOSE c_check_existance;
END IF;
END;Remember, when making a control block like a data block, you have to code everything yourself. -
RM-30410: Warning: Single Record property ignored for non-control block
Hi gurus,
I have one block, as oracle default behavious is that when any user enters record and during that if he/she hits down arrow key then it gets to next new record, i want to prevent this behaviour.
In other words i want that user should not enter second record and if he or she needs to enter second record after saving first then user can only do if he navigate to the form second time.
In property pallete i put yes to single record but when i compile the form it gives me following warning
FRM-30410: Warning: Single Record property ignored for non-control block Employees
Created form file C:\my_forms\employees.fmxPlease seeks help that how can i sort it out.
Thank you
Hinaif he/she hits down arrow key then it gets to next new record, i want to prevent this behaviour. Change the block's key-down and/or key-nxtrec trigger to
begin
null;
end;(or give the user a message "Key not allowed here"). -
Multiple records in a non-DB block
I have about 10 records in a non-DB block (B_main).
I need to get all the records and insert them into a db table. How can I achieve this?
Forms10 text fields inside Retek are appearing with a default 'Yellow' color. I tried setting them to grey....but they are
still defaulting back to yellow when I run the form in the application. How can I change them to appear in grey?
Thanks,
ChiruI have about 10 records in a non-DB block (B_main).
I need to get all the records and insert them into a db table. How can I achieve this?If you want to insert all the records into a DB-table, why do you use a non-DB-block for it? In that case you would have to do NO work, simply issue a COMMIT_FORM.
With the non-DB-block you have to loop over the block like:
FIRST_RECORD;
LOOP
INSERT INTO TAB (
COL1,
COLN
) VALUES (
:BLOCK.COL1,
:BLOCK.COLN
EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
NEXT_RECORD;
END LOOP;But again, why not use a database-block? -
Error: 1012704 Dynamic Calc processor cannot lock more than [25] ESM blocks
Dear All,
I get the Following Error in the Essbase console when I try to Execute any CalcScript.
Error: 1012704 Dynamic Calc processor cannot lock more than [25] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting)_+
Please find the detailed output of the Statics of my Planning Applications Database and outline.
please help guys........
GetDbStats:
-------Statistics of AWRGPLAN:Plan1 -------
Dimension Name Type Declared Size Actual Size
===================================================================
HSP_Rates SPARSE 11 11
Account DENSE 602 420
Period DENSE 19 19
Year SPARSE 31 31
Scenario SPARSE 6 6
Version SPARSE 4 4
Currency SPARSE 10 10
Entity SPARSE 28 18
Departments SPARSE 165 119
ICP SPARSE 80 74
LoB SPARSE 396 344
Locations SPARSE 57 35
View SPARSE 5 5
Number of dimensions : 13
Declared Block Size : 11438
Actual Block Size : 7980
Declared Maximum Blocks : 3.41379650304E+015
Actual Maximum Blocks : 1.87262635317E+015
Number of Non Missing Leaf Blocks : 10664
Number of Non Missing Non Leaf Blocks : 2326
Number of Total Blocks : 12990
Index Type : B+ TREE
Average Block Density : 0.01503759
Average Sparse Density : 6.936782E-010
Block Compression Ratio : 0.001449493
Average Clustering Ratio : 0.3333527
Average Fragmentation Quotient : 19.3336
Free Space Recovery is Needed : No
Estimated Bytes of Recoverable Free Space : 0
GetDbInfo:
----- Database Information -----
Name : Plan1
Application Name : AWRGPLAN
Database Type : NORMAL
Status : Loaded
Elapsed Db Time : 00:00:05:00
Users Connected : 2
Blocks Locked : 0
Dimensions : 13
Data Status : Data has been modified
since last calculation.
Data File Cache Size Setting : 0
Current Data File Cache Size : 0
Data Cache Size Setting : 3128160
Current Data Cache Size : 3128160
Index Cache Size Setting : 1048576
Current Index Cache Size : 1048576
Index Page Size Setting : 8192
Current Index Page Size : 8192
Cache Memory Locking : Disabled
Database State : Read-write
Data Compression on Disk : Yes
Data Compression Type : BitMap Compression
Retrieval Buffer Size (in K) : 10
Retrieval Sort Buffer Size (in K) : 10
Isolation Level : Uncommitted Access
Pre Image Access : No
Time Out : Never
Number of blocks modified before internal commit : 3000
Number of rows to data load before internal commit : 0
Number of disk volume definitions : 0
Currency Info
Currency Country Dimension Member : Entity
Currency Time Dimension Member : Period
Currency Category Dimension Member : Account
Currency Type Dimension Member :
Currency Partition Member :
Request Info
Request Type : Data Load
User Name : admin@Native Directory
Start Time : Mon Aug 15 18:35:51 2011
End Time : Mon Aug 15 18:35:51 2011
Request Type : Customized Calculation
User Name : 6236@Native Directory
Start Time : Tue Aug 16 09:44:10 2011
End Time : Tue Aug 16 09:44:12 2011
Request Type : Outline Update
User Name : admin@Native Directory
Start Time : Tue Aug 16 10:50:02 2011
End Time : Tue Aug 16 10:50:02 2011
ListFiles:
File Type
Valid Choices: 1) Index 2) Data 3) Index|Data
>>Currently>> 3) Index|Data
Application Name: AWRGPLAN
Database Name: Plan1
----- Index File Information -----
Index File Count: 1
File 1:
File Name: C:\Oracle\Middleware\user_projects\epmsystem1\EssbaseServer\essbaseserver1\APP\AWRGPLAN\Plan1\ess00001.ind
File Type: INDEX
File Number: 1 of 1
File Size: 8,024 KB (8,216,576 bytes)
File Opened: Y
Index File Size Total: 8,024 KB (8,216,576 bytes)
----- Data File Information -----
Data File Count: 1
File 1:
File Name: C:\Oracle\Middleware\user_projects\epmsystem1\EssbaseServer\essbaseserver1\APP\AWRGPLAN\Plan1\ess00001.pag
File Type: DATA
File Number: 1 of 1
File Size: 1,397 KB (1,430,086 bytes)
File Opened: Y
Data File Size Total: 1,397 KB (1,430,086 bytes)
File Size Grand Total: 9,421 KB (9,646,662 bytes)
GetAppInfo:
-------Application Info-------
Name : AWRGPLAN
Server Name : GITSHYPT01:1423
App type : Non-unicode mode
Application Locale : English_UnitedStates.Latin1@Binary
Status : Loaded
Elapsed App Time : 00:00:05:24
Users Connected : 2
Data Storage Type : Multidimensional Data Storage
Number of DBs : 3
List of Databases
Database (0) : Plan1
Database (1) : Plan2
Database (2) : Plan3ESM Block Issue
Cheers..!! -
How to lock records in 8.1.7?
Hi,
How can I lock records in 8.1.7 so that only one user can select/update these records at one time? If possible, can it return an error mesg if one user try to select/update records locked by others?
Thanks a lot.
DavidOracle automatically locks a row just before updating or deleting.
You can lock rows explicitly before doing an update etc by selecting it for update:
select * from emp where empno=21 for update;
update emp
set sal=sal*1.1
where empno=21;
commit;
The lock will be released on the commit (or rollback).
Please note that in Oracle, writers never block readers and readers never block writers. Which means, that although you have locked a row (or group of rows) for update, other users will still be able to select against those rows (in the pre-changed or consistant state). -
How to create a relationsship between a DB Bock and Non DB Block
Hi All,
I am working with oracle forms 10g.
I have created a Custom form. I have two block. One is a DB Block and another is control block(ie multi record blk).
I tried to create a master detail relationship between these two block.
Master block:LC_Master_BLK(DB Block).
Detail block: LC_Detail_blk(Non DB Block).
Form object navigator I click relation in Master Block and a pop up window opens and form there i select Detail block.
And i give the join condition like
LC_Master_BLK.PO_HEADER_ID=LC_Detail_blk.PO_HEADER_ID.
I have made po_header_id as primary key in my custom table,refred in my master block.
But it shows error as
FRM-15004: Error while parsing the join condtion.
Can any one tell me how to solve this.
Thanks & Regards
SrikkanthHi Srikkanth.M
I have two block. One is a DB Block and another is control block(ie multi record blk).this is what i call bad form design pls exchange the two blocks making ...
Master block:LC_Master_BLK(Non DB Block).
Detail block: LC_Detail_blk (DB Block).
Now to link the 2 blocks then define the join condition as follows:
:LC_Master_BLK.PO_HEADER_ID = :LC_Detail_blk.PO_HEADER_IDPls Keep in mind that the join condition specifies the relationship between items in 2 blocks db
or
one which is the master Non DB Block (to filter the display of data through user input to display the result output of data related in multi-records in the detail block.
That how u can works with the relation between two blocks as urs..
Hope this helps...
Regards,
Amatu Allah -
Counting number of records in a data block
hi folks,
Simple question for you guys: How can I count number of records in a data block.
In other words, say I have 10 detail records listed on a data block (one of my columns is a non-database item for entering a number). Now I just want to do somethin like:
Select count(*) From <data_block> into lnRecCount
Where <non-database column> <> 0 ;
Can I do this in a button trigger? I can't get it to work?
Thanks,
bobYou should make a routine that go through records of the block and count the records that agree with your condition.
-
Enter_query for non-database block
Hi there,
I have a non-database block. When I click on enter query button from toolbar, i get"this function cannot be performed here' error. I want to bring up records based on certain math calculations. I was planning to write a pre-query trigger and add those to pre-query trigger. Will it work since it is a non-database block? Or should i create a button on form to get records populated?
ThanksYou won't be able to use the Query-Process-triggers PRE-QUERY and POST-QUERY on a non-database-block.
But... If you want to "simulate" the behaviour of querying, you can use the KEY-EXEQRY-trigger and put your logic there. This should also work with the standard forms-menus. To supress the error-message on entering query-mode you should additionally write as KEY-ENTQRY-trigger with code NULL; -
How to make a record as Non Updatable
Hi all
I want to make the whole record(multi record block) as non updatable. My condition is, I have one status field in the base table block, when I query the form if the "status" field containing value 'Y', the user should not be able to update any item in the record. How to acheive the functionality?
Thanks in advance
ram.Hi,
Have you tried using the set_item_instance_property('',update_alowed,..) built_in in the when_new_record_instance trigger on the block level?
You can check there the :block.status field,and set the item instances in that record to non updatable. -
Lock records (urgent)
Dear members,
I hava a problem with lock record. Would you please help me to solve my problem. I had read on OTN messages about locking records that others members have used the following:
On_lock trigger(Block level)
Lock_record;
On_Error trigger(Form level)
DECLARE
errnum NUMBER := ERROR_CODE;
errtxt VARCHAR2(80) := ERROR_TEXT;
errtyp VARCHAR2(3) := ERROR_TYPE;
BEGIN
IF errnum = 40501 THEN
message('This record has been locked by another user');
ELSE
Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt);
END IF;
RAISE Form_Trigger_Failure;
END;
I still received the ORACLE message "COULD NOT RESERVE RECORD(2 TRIES). KEEP TRYING? YES OR NO".
If I select "NO" my message will come up, but I want the ORACLE message suppressed. How do I do that!
THANKSIn the on-lock trigger, instead of Lock_record; you should write your own sql "select for update no wait".
Then I am not sure... either write your own exception clause to trap the ORA-00054, or trap the exception in the on-error trigger. -
Can not delete record from the master block ,frm-40202 field must be entere
hi ,
i have built a form which contain master and details blocks
the problem is
when i try to delete a record from the master block it gives me new serial for the transaction and when i try to save it, it says
>frm-40202 field must be entered
where this field is required and i cant save it
although in another form when i delete from the master it gives me the previous record and it works properly
if any one has any ideas pls help me
thank u
------- the master block has a trigger when-create-recoder
Declare>v_dummy number;
Begin
Select nvl(max(ERNT_NO),0) + 1 >Into v_dummy
From LM_RENT_EXPNMST >Where cmp_no = :LM_RENT_EXPNMST.cmp_no
And brn_no = :LM_RENT_EXPNMST.brn_no>and fiscal_yr = :LM_RENT_EXPNMST.fiscal_yr;
>:LM_RENT_EXPNMST.ERNT_NO := v_dummy;
END;
IF :PARAMETER.RNT_NO IS NOT NULL THEN
:LM_RENT_EXPNMST.RNT_NO:=:PARAMETER.RNT_NO;
:LM_RENT_EXPNMST.RNT_YR:=:PARAMETER.RNT_YR;
:LM_RENT_EXPNMST.CUST_DESC:=:PARAMETER.RNT_ADESC;
END IF;Edited by: ayadsufyan on May 8, 2013 2:03 PMIf this is a FORMS question you should mark this one ANSWERED and repost your question in the FORMS forum
Forms -
Lock records when in Update Mode / problem with 2 users on 1 document
Hi,
when user A updates e.g. a purchase order and user B goes into this purchase order and updates e.g. the remark before user A, then user A cannot save his changes. Imagine user A has put in several new lines and has made several price adjustments, his work will be gone.
In most cases this should not happen very often, but it could. Since B1 recognizes when another user has updated the document before, it should be possible to solve this situation more convenient (either by lock, saving to a new document, comparing to the old version, etc).
Thank you
SebastianHi Sebastian,
Your request is understandable. It may not have big problem to change current process by coding. However to lock records whenever in update mode, that could create too many locks. It is basically not good for performance. The trade off may be allowing save as function. However, this may not be a desirable solution for most end users.
Thanks,
Gordon -
How to lock record in a remote database ???
Hi All!
How to lock record in a remote table ??? Is it possible to lock by using the RPC ??? What are the options available ??
thanks
Sanjeeb Bose
HCL Infosystems Ltd
Kolkata IndiaDBLinks may be one option...
--Shirish
Maybe you are looking for
-
How do I copy my files from my host server acct to my (new) hard drive?
I recently purchased a new laptop after a crash. I was able to install DW (CS3) and my files are all intact. But I need to put the files on my hard drive so that I can edit them offline. As it is, everytime I open DW, I'm connected to the host. P
-
Connect my iPad2 to an adhoc connection
Hello, Currently in a hotel room where they only have wired connection. So, I hooked up the ethernet cable to my laptop (PC) and created an adhoc connection. My buddy is able to get the connection and access the internet with his laptop but even if
-
I found a phone on eBay and AT&T told me if I find a phone they can change it for me but it says Apple ID is locked
-
Automatic batch determination (Fifo) in VL02n and WM/foreground
Dear all, I am trying to set up an automatic batch determination /stock determination strategy on outbound deliveries (FiFo) in a WM managed warehouse. I have not yet decided whether to go for the batch determination or the stock determination. As a
-
Where is Blob Storage REST API?
Where has Azure Blob Storage REST API reference gone? All links to it became being redirected to http://azure.microsoft.com/en-us/documentation/ Is public REST API support discontinued and it becomes proprietary?